/* =======================================================
   SYSTEM STYLE SHEET - DUBAI CANDY SWEET LIGHT THEME
   ======================================================= */

:root {
    /* Dubai Candy Palette - Dịu ngọt, thanh lịch, không chói */
    --dubai-mint: #2dd4bf; /* Mint dịu */
    --candy-rose: #f472b6; /* Hồng pastel */
    --candy-lavender: #c084fc; /* Tím nhẹ */
    --dubai-gold: #fbbf24; /* Vàng Dubai */
    --candy-gradient: linear-gradient(135deg, #2dd4bf 0%, #f472b6 100%);
    
    /* Nền sáng, ngọt ngào, bừng sáng nhưng không gắt */
    --bg-main: radial-gradient(circle at top right, #fdf4ff 0%, #f0fdfa 50%, #f8fafc 100%);
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-sub: rgba(255, 255, 255, 0.95);
    
    /* Shadows & Borders */
    --shadow-card: 0 15px 35px -5px rgba(244, 114, 182, 0.15);
    --border-light: rgba(244, 114, 182, 0.2);
    
    /* Text Colors */
    --text-main: #334155;
    --text-muted: #64748b;
    --text-accent: #db2777; /* Rose đậm để dễ đọc, không chói */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-main);
    min-height: 100vh;
    color: var(--text-main);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
}

/* --- MÀN HÌNH LOADING --- */
#loading { transition: opacity 0.5s ease, visibility 0.5s ease; }
.hidden-loader { opacity: 0 !important; visibility: hidden !important; pointer-events: none !important; }

/* --- SCROLLBAR --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.05); }
::-webkit-scrollbar-thumb { background: var(--candy-rose); border-radius: 10px; }

/* --- KHUNG THẺ (CARD) KẸO NGỌT --- */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-light);
    border-radius: 24px;
    box-shadow: var(--shadow-card);
    color: var(--text-main);
    transition: all 0.3s ease;
}
.glass-card:hover {
    box-shadow: 0 25px 50px -12px rgba(244, 114, 182, 0.25);
    transform: translateY(-2px);
}

/* --- THANH HEADER SÁNG TRONG TRẺO --- */
.top-navbar {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-light);
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(244, 114, 182, 0.08);
    gap: 15px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-accent);
    font-size: 19px;
    font-weight: 900;
    flex-shrink: 0;
}

.navbar-brand-icon {
    width: 38px;
    height: 38px;
    background: var(--candy-gradient);
    color: white;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(244, 114, 182, 0.3);
}

/* TÌM KIẾM HEADER DỊU MẮT */
.header-search-wrapper { flex: 1; max-width: 500px; margin: 0 10px; }
.search-box { position: relative; width: 100%; }
.search-box input {
    width: 100%;
    padding: 9px 18px 9px 40px;
    border-radius: 25px;
    border: 1.5px solid rgba(244, 114, 182, 0.3);
    background: rgba(255, 255, 255, 0.6);
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-main);
    outline: none;
    transition: all 0.25s ease;
}
.search-box input::placeholder { color: var(--text-muted); }
.search-box input:focus {
    border-color: var(--candy-rose);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(244, 114, 182, 0.15);
}
.search-box i { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--candy-rose); font-size: 14px; }

/* USER WIDGET KẸO NGỌT */
.user-auth-widget { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.btn-auth-nav { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 20px; font-size: 12.5px; font-weight: 800; text-decoration: none; transition: 0.25s; }
.btn-login-nav { background: var(--candy-gradient); color: white; box-shadow: 0 4px 12px rgba(244, 114, 182, 0.3); }
.btn-login-nav:hover { transform: translateY(-2px); opacity: 0.95; }
.user-badge { display: flex; align-items: center; gap: 8px; background: rgba(244, 114, 182, 0.1); padding: 4px 12px 4px 6px; border-radius: 20px; border: 1px solid rgba(244, 114, 182, 0.2); }
.user-badge-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; border: 2px solid #ffffff; }
.user-badge-name { font-size: 12.5px; font-weight: 700; color: var(--text-main); max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-logout-nav { background: none; border: none; color: var(--candy-rose); cursor: pointer; padding: 6px; font-size: 15px; border-radius: 50%; transition: 0.2s; }
.btn-logout-nav:hover { color: var(--text-accent); background: rgba(244, 114, 182, 0.1); }

/* --- MENU TRANG CHỦ --- */
.index-menu-item {
    transition: all 0.25s ease;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-main) !important;
    display: flex;
    align-items: center;
    background: var(--bg-card-sub);
    border: 1px solid var(--border-light);
    margin-bottom: 6px;
    text-decoration: none;
}
.index-menu-item:hover {
    background: #fdf4ff;
    color: var(--text-accent) !important;
    border-color: #fce7f3;
    box-shadow: 0 4px 12px rgba(244, 114, 182, 0.1);
    transform: translateX(4px);
}
.index-menu-item i { color: var(--candy-rose); margin-right: 10px; font-size: 14px; }

/* --- CHAT BOT AI PASTEL --- */
.chat-bubble-user { 
    background: var(--candy-gradient); 
    color: white !important; 
    border-radius: 16px 16px 2px 16px; 
    padding: 10px 14px; 
    font-size: 0.85rem; 
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(244, 114, 182, 0.2);
}
.chat-bubble-bot { 
    background: #f8fafc; 
    color: var(--text-main) !important; 
    border: 1px solid var(--border-light);
    border-radius: 16px 16px 16px 2px; 
    padding: 10px 14px; 
    font-size: 0.85rem; 
    font-weight: 500; 
}

/* --- KHUNG CONTAINER TRANG WELCOME --- */
.main-wrapper { max-width: 1200px; margin: 20px auto 0; padding: 0 20px 40px; }

/* ACCORDION MÔN HỌC */
.subject-group {
    margin-bottom: 18px;
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid var(--border-light);
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(244, 114, 182, 0.05);
}
.subject-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-accent);
    background: linear-gradient(135deg, #fdf4ff, #ffffff);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid #fce7f3;
    transition: 0.2s;
}
.subject-title:hover { background: #fce7f3; }
.title-left { display: flex; align-items: center; gap: 12px; }
.title-left i { color: var(--candy-rose); font-size: 16px; }
.toggle-icon { font-size: 13px; color: var(--candy-rose); transition: transform 0.3s ease; }
.subject-body { padding: 16px 20px; background: #ffffff; }

/* ACCORDION KHỐI LỚP */
.grade-group { margin-bottom: 18px; border-bottom: 1px dashed var(--border-light); padding-bottom: 16px; }
.grade-group:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.grade-title {
    font-size: 13.5px;
    font-weight: 700;
    color: #db2777;
    padding: 8px 14px;
    background: #fdf4ff;
    border-radius: 10px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    border: 1px solid #fce7f3;
}
.grade-title:hover { background: #fce7f3; }

/* COLLAPSE STATES */
.subject-group.collapsed .subject-body, .grade-group.collapsed .cards-grid { display: none; }
.subject-group.collapsed .subject-title .toggle-icon, .grade-group.collapsed .grade-title .toggle-icon { transform: rotate(-90deg); }

/* GRID THẺ BÀI HỌC */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; padding-top: 4px; }
.lesson-card {
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 12px 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.25s ease;
}
.lesson-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(244, 114, 182, 0.15);
    border-color: var(--candy-rose);
}

.card-header { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.card-header-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

/* NÚT THAO TÁC TRÊN BÀI HỌC */
.res-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.2s ease;
    background: transparent !important;
    border: none !important;
}
.res-btn.lesson { color: var(--dubai-mint); }
.res-btn.lesson:hover:not(.btn-disabled) { transform: scale(1.2); filter: drop-shadow(0 0 6px var(--dubai-mint)); }
.res-btn.pdf { color: #fb7185; } /* Hồng đào dịu */
.res-btn.pdf:hover:not(.btn-disabled) { transform: scale(1.2); filter: drop-shadow(0 0 6px #fb7185); }
.res-btn.slide { color: var(--dubai-gold); }
.res-btn.slide:hover:not(.btn-disabled) { transform: scale(1.2); filter: drop-shadow(0 0 6px var(--dubai-gold)); }
.res-btn.btn-disabled { opacity: 0.3; cursor: not-allowed; filter: grayscale(100%); }

.lesson-name { font-size: 13.5px; font-weight: 700; color: var(--text-main); line-height: 1.4; flex: 1; }

.card-links { display: flex; flex-direction: column; gap: 6px; }
.card-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.row-icon { font-size: 14px; display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; flex-shrink: 0; }
.card-row:nth-child(1) .row-icon { color: #34d399; }
.card-row:nth-child(2) .row-icon { color: #fb923c; }
.card-row:nth-child(3) .row-icon { color: #a78bfa; }

.items-container { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }

/* NHÃN (PILL-LINK) */
.pill-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    color: var(--text-muted);
    text-decoration: none;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
    transition: all 0.2s ease;
    border: 1px solid var(--border-light);
}
.pill-link:hover {
    background: #fdf4ff;
    color: var(--text-accent);
    border-color: #fce7f3;
}

.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    border: 1px dashed var(--border-light);
}

/* =======================================================
   MODULE DOC-VIEWER - SÁNG VÀ SẠCH SẼ
   ======================================================= */
.doc-viewer-body { width: 100%; height: 100vh; display: flex; flex-direction: column; overflow: hidden; background: #fdf4ff; }

.viewer-header {
    height: 56px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    box-shadow: 0 4px 20px rgba(244, 114, 182, 0.08);
    z-index: 10;
    border-bottom: 1px solid var(--border-light);
    gap: 12px;
}
.header-left { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1; }

.app-logo-link { font-size: 20px; color: var(--candy-rose); text-decoration: none; display: flex; align-items: center; justify-content: center; transition: 0.2s; flex-shrink: 0; }
.app-logo-link:hover { transform: scale(1.15); color: var(--text-accent); }

.btn-back-welcome { font-size: 17px; color: var(--candy-rose); text-decoration: none; display: flex; align-items: center; justify-content: center; transition: 0.2s; flex-shrink: 0; }
.btn-back-welcome:hover { transform: translateX(-3px) scale(1.1); color: var(--text-accent); }

.divider-slash { color: rgba(244, 114, 182, 0.4); font-size: 14px; user-select: none; flex-shrink: 0; }
.doc-title-wrapper { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 200px; flex-shrink: 0; }
.doc-title { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-accent); }

.header-resources-bar { display: flex; align-items: center; gap: 14px; overflow-x: auto; scrollbar-width: none; }
.header-resources-bar::-webkit-scrollbar { display: none; }

.icon-only-btn { background: transparent; border: none; font-size: 18px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 4px; transition: 0.2s; outline: none; }
.icon-only-btn:hover { transform: scale(1.2); }
.icon-only-btn.active { transform: scale(1.25); filter: drop-shadow(0 0 8px currentColor); }
.icon-only-btn.disabled { opacity: 0.3; cursor: not-allowed; transform: none !important; }

.res-group { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.res-group .group-icon { font-size: 17px; margin-right: 2px; }
.res-link { color: var(--text-muted); cursor: pointer; text-decoration: none; font-weight: 500; transition: 0.2s; }
.res-link:hover { color: var(--text-accent); text-decoration: underline; }
.res-link.active { color: var(--text-accent); font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.res-group .sep { color: rgba(244, 114, 182, 0.4); margin-right: 2px; }

.btn-action-mode {
    background: rgba(244, 114, 182, 0.1);
    color: var(--text-accent);
    border: 1px solid rgba(244, 114, 182, 0.3);
    padding: 6px 12px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.btn-action-mode:hover { background: rgba(244, 114, 182, 0.2); }
.btn-action-mode.active-edit { background: var(--dubai-gold); color: #ffffff; border-color: #f59e0b; }
.hidden { display: none !important; }

.iframe-container { flex: 1; width: 100%; height: calc(100% - 56px); background: #fdf4ff; position: relative; }
iframe { width: 100%; height: 100%; border: none; }
.loading-state { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; color: var(--text-accent); z-index: 1; }