/* =========================================================
   STUDENT AI LEARNING PLATFORM STYLES
   ========================================================= */

:root[data-role="student"] {
    --primary-color: #A78BFA; /* Purple */
    --primary-color-rgb: 167, 139, 250;
    --student-grad: linear-gradient(135deg, #A78BFA 0%, #8B5CF6 100%);
    --student-grad-hover: linear-gradient(135deg, #8B5CF6 0%, #7C3AED 100%);
    --bg-glass: rgba(255, 255, 255, 0.05);
    --border-glass: rgba(167, 139, 250, 0.2);
    --surface-1: rgba(255, 255, 255, 0.04);
    --surface-2: rgba(255, 255, 255, 0.08);
}

:root[data-theme="light"][data-role="student"] {
    --bg-glass: rgba(0, 0, 0, 0.05);
    --border-glass: rgba(167, 139, 250, 0.3);
    --surface-1: rgba(0, 0, 0, 0.03);
    --surface-2: rgba(0, 0, 0, 0.06);
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

/* =========================================================
   AI TUTOR REDESIGN (ChatGPT-Style Layout)
   ========================================================= */

#page-ai-tutor {
    padding: 0 !important;
    overflow: hidden;
    height: 100vh;
    display: none;
}

#page-ai-tutor.active {
    display: block;
}

.tutor-layout {
    display: flex;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    background: var(--bg-primary);
    position: relative;
}

/* ── Sidebar ── */
.tutor-sidebar {
    width: 260px;
    height: 100%;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    flex-shrink: 0;
}

@media (max-width: 1024px) {
    .tutor-sidebar {
        transform: translateX(-100%);
    }
}

.tutor-sidebar-top {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tutor-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    font-weight: 800;
    font-size: 18px;
    color: var(--text-primary);
}

.new-chat-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface-1);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.new-chat-btn:hover {
    background: var(--surface-2);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.tutor-history-section {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px;
    margin-top: 8px;
}

.tutor-history-label {
    padding: 12px 12px 8px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.tutor-history-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tutor-history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
    font-size: 13.5px;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
}

.tutor-history-item:hover {
    background: var(--surface-1);
    color: var(--text-primary);
}

.tutor-history-item.active {
    background: var(--surface-2);
    color: var(--primary-color);
    font-weight: 600;
}

.tutor-history-item span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tutor-history-actions {
    display: none;
    gap: 6px;
}

.tutor-history-item:hover .tutor-history-actions {
    display: flex;
}

.tutor-history-actions button {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    border-radius: 4px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.tutor-history-actions button:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

.tutor-sidebar-bottom {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.tutor-sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.tutor-sidebar-user:hover {
    background: var(--surface-1);
}

.tutor-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--student-grad);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.tutor-user-info {
    flex: 1;
    min-width: 0;
}

.tutor-user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tutor-user-role {
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Main Area ── */
.tutor-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg-primary);
    position: relative;
    min-width: 0;
}

.tutor-chat-header {
    height: 64px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(var(--bg-primary-rgb), 0.7);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    z-index: 50;
}

.tutor-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tutor-toggle-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
}

.tutor-header-titles .header-title {
    font-size: 15px;
    font-weight: 700;
}

/* ── Chat Container ── */
.tutor-chat-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
    padding-bottom: 180px; /* Space for input footer */
}

/* ── Empty State ── */
.tutor-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.tutor-empty-icon {
    width: 80px;
    height: 80px;
    background: var(--surface-1);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
}

.tutor-empty-title {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.tutor-empty-sub {
    font-size: 15px;
    color: var(--text-secondary);
    max-width: 460px;
    line-height: 1.6;
}

/* ── Messages Area ── */
.tutor-chat-area {
    width: 100%;
    max-width: 840px;
    margin: 0 auto;
    padding: 24px 0;
}

.chat-bubble {
    padding: 24px 16px;
    display: flex;
    gap: 24px;
    transition: background 0.2s;
}

.chat-bubble.ai {
    background: var(--surface-1);
}

.chat-bubble-inner {
    flex: 1;
    min-width: 0;
    font-size: 15.5px;
    line-height: 1.7;
    color: var(--text-primary);
}

.bubble-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.chat-bubble.user .bubble-avatar { background: #3b82f6; }
.chat-bubble.ai .bubble-avatar { background: var(--primary-color); }

/* ── Input Pill ── */
.tutor-input-wrapper {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0 24px 32px;
    background: linear-gradient(transparent, var(--bg-primary) 70%);
    z-index: 60;
}

.tutor-input-box {
    max-width: 840px;
    margin: 0 auto;
    background: var(--surface-1);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 8px 12px 8px 20px;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.tutor-input-box:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 10px 40px rgba(167, 139, 250, 0.15);
}

.tutor-input-box textarea {
    flex: 1;
    background: transparent;
    border: none;
    padding: 12px 0;
    font-size: 15px;
    color: var(--text-primary);
    max-height: 200px;
    resize: none;
    outline: none;
    line-height: 1.5;
}

.tutor-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
    transition: all 0.2s;
}

.tutor-send-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.tutor-input-footer {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 12px;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    .tutor-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
    }
    .tutor-sidebar.open {
        transform: translateX(0);
    }
    .tutor-toggle-btn {
        display: block;
    }
    .tutor-sidebar-overlay.visible {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        backdrop-filter: blur(4px);
        z-index: 90;
    }
}

@media (max-width: 640px) {
    .chat-bubble { padding: 20px 16px; gap: 16px; }
    .tutor-input-wrapper { padding: 0 12px 16px; }
    .tutor-input-box { border-radius: 20px; padding-left: 16px; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Suggestion Cards */
.suggestion-cards {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding-bottom: 10px;
    margin-bottom: 15px;
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

.suggestion-cards::-webkit-scrollbar {
    display: none;
}

.sugg-card {
    background: var(--surface-1);
    border: 1px solid var(--border-color);
    padding: 12px 20px;
    border-radius: 20px;
    white-space: nowrap;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sugg-card:hover {
    border-color: var(--primary-color);
    background: rgba(167, 139, 250, 0.1);
    transform: translateY(-2px);
}

/* =========================================================
   QUIZ AI (Trắc nghiệm AI)
   ========================================================= */
.quiz-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
    min-height: calc(100vh - 54px);
    background: var(--bg-primary);
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.quiz-progress-wrap {
    flex: 1;
    margin: 0 30px;
}

.quiz-progress-bar {
    height: 8px;
    background: var(--surface-2);
    border-radius: 4px;
    overflow: hidden;
}

.quiz-progress-fill {
    height: 100%;
    background: var(--student-grad);
    width: 0%;
    transition: width 0.3s ease;
}

.quiz-score {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
    background: rgba(167, 139, 250, 0.1);
    padding: 8px 16px;
    border-radius: 20px;
}

.quiz-card {
    padding: 40px;
    text-align: center;
}

.quiz-question {
    font-size: 22px;
    margin-bottom: 30px;
    color: var(--text-primary);
    line-height: 1.4;
}

.quiz-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

.quiz-option {
    background: var(--surface-1);
    border: 2px solid var(--border-color);
    padding: 16px 24px;
    border-radius: 12px;
    font-size: 16px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    display: flex;
    align-items: center;
}

.quiz-option:hover {
    border-color: var(--primary-color);
    background: rgba(167, 139, 250, 0.05);
}

.quiz-option.correct {
    border-color: #4ADE80;
    background: rgba(74, 222, 128, 0.1);
    color: #4ADE80;
}

.quiz-option.wrong {
    border-color: #FF6B6B;
    background: rgba(255, 107, 107, 0.1);
    color: #FF6B6B;
}

.quiz-explanation {
    margin-top: 30px;
    padding: 20px;
    background: rgba(167, 139, 250, 0.1);
    border-left: 4px solid var(--primary-color);
    border-radius: 8px;
    text-align: left;
    display: none;
    animation: slideUp 0.3s ease;
}

.quiz-explanation h4 {
    color: var(--primary-color);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* =========================================================
   STUDENT PROFILE (Hồ sơ học tập)
   ========================================================= */
.student-profile-container {
    padding: 30px;
    max-width: 1200px;
    margin: 0 auto;
    min-height: calc(100vh - 54px);
    background: var(--bg-primary);
}

.sp-header {
    margin-bottom: 30px;
}

.sp-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.sp-stat-card {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.2s;
}

.sp-stat-card:hover {
    transform: translateY(-5px);
}

.sp-stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.sp-stat-info h3 {
    font-size: 28px;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.sp-stat-info p {
    color: var(--text-secondary);
    font-size: 14px;
}

.sp-charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.sp-chart-card {
    padding: 24px;
}

.sp-chart-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
}

/* =========================================================
   SPECIALTIES & CASES (Chuyên khoa & Ca bệnh)
   ========================================================= */
.specialty-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    padding: 20px;
}

.specialty-card {
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.specialty-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--student-grad);
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 0;
}

.specialty-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(167, 139, 250, 0.2);
}

.specialty-card:hover::before {
    opacity: 0.05;
}

.specialty-icon {
    font-size: 40px;
    margin-bottom: 15px;
    position: relative;
    z-index: 1;
}

.specialty-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
    position: relative;
    z-index: 1;
}

.specialty-progress {
    width: 100%;
    height: 6px;
    background: var(--surface-2);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
    z-index: 1;
    margin-bottom: 10px;
}

.sp-prog-fill {
    height: 100%;
    background: var(--student-grad);
}

.specialty-meta {
    font-size: 13px;
    color: var(--text-secondary);
    position: relative;
    z-index: 1;
}
