/* ---- CSS VARIABLES & THEME ---- */
:root {
    /* Color Palette - Premium Dark Theme */
    --bg-base: #0f172a; /* Slate 900 */
    --bg-surface: rgba(30, 41, 59, 0.7); /* Slate 800 with opacity */
    --bg-surface-hover: rgba(51, 65, 85, 0.8);
    --border-color: rgba(255, 255, 255, 0.1);
    
    /* Brand Colors (Premium vibe) */
    --brand-primary: #3b82f6; /* Blue */
    --brand-secondary: #facc15; /* Gold/Yellow */
    
    /* Text Colors */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    /* Transition & Shadows */
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-glass: 0 4px 30px rgba(0, 0, 0, 0.3);
    
    /* Tags Colors */
    --tag-listening: #a78bfa;
    --tag-speaking: #34d399;
    --tag-writing: #fbbf24;
}

/* ---- RESETS & BASE ---- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

/* Typography */
h1, h2, h3 { font-weight: 600; }
a { text-decoration: none; color: inherit; }
button { font-family: 'Inter', sans-serif; cursor: pointer; border: none; background: none; }

/* ---- LAYOUT ---- */
.topbar {
    height: 70px;
    background: var(--bg-surface);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 100;
}

.main-layout {
    display: flex;
    height: 100vh;
    padding-top: 70px;
}

.sidebar {
    width: 250px;
    background: var(--bg-surface);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2rem 0;
}

.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 3rem;
    background: radial-gradient(circle at top right, rgba(59, 130, 246, 0.1), transparent 40%),
                radial-gradient(circle at bottom left, rgba(234, 179, 8, 0.05), transparent 40%);
}

#app {
    max-width: 1200px;
    margin: 0 auto;
}

/* ---- TOPBAR ITEMS ---- */
.logo {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}
.logo-highlight {
    color: var(--brand-secondary);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--brand-primary);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.user-level {
    font-size: 0.75rem;
    color: var(--brand-secondary);
}

/* ---- SIDEBAR ITEMS ---- */
.nav-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 2rem;
    color: var(--text-muted);
    transition: var(--transition-smooth);
    position: relative;
    font-weight: 500;
}

.nav-link i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.nav-link:hover, .nav-link.active {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: var(--brand-primary);
    border-radius: 0 4px 4px 0;
}

/* ---- UI COMPONENTS ---- */
.glass {
    background: var(--bg-surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-glass);
    border-radius: 16px;
}

.card {
    padding: 1.5rem;
    transition: var(--transition-smooth);
}

.card:hover {
    transform: translateY(-5px);
    background: var(--bg-surface-hover);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--brand-primary);
    color: #fff;
}

.btn-primary:hover {
    filter: brightness(1.1);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
}

.btn-outline {
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.btn-icon {
    font-size: 1.1rem;
    color: var(--text-muted);
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-icon:hover {
    color: var(--text-main);
}

.badge {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    transition: var(--transition-smooth);
}

.badge.active {
    background: var(--text-main);
    color: var(--bg-base);
}

.badge:hover:not(.active) {
    background: rgba(255, 255, 255, 0.1);
}

/* ---- UTILITIES ---- */
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }

/* Animations */
.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

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

/* ---- VIEWS STYLES ---- */
.view-header {
    margin-bottom: 2.5rem;
}

.view-header h1 {
    font-size: 2.2rem;
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.grid-col-span-full {
    grid-column: 1 / -1;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: var(--brand-secondary);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    margin-top: 0.25rem;
}

.stat-unit {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 400;
}

.action-card {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(30, 41, 59, 0.8));
    border-left: 4px solid var(--brand-primary);
}

/* Practices Grid */
.filters {
    display: flex;
    gap: 0.75rem;
}

.practices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.practice-card {
    display: flex;
    flex-direction: column;
}

.practice-tag {
    align-self: flex-start;
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.practice-tag.listening { background: rgba(167, 139, 250, 0.2); color: var(--tag-listening); }
.practice-tag.speaking { background: rgba(52, 211, 153, 0.2); color: var(--tag-speaking); }
.practice-tag.writing { background: rgba(251, 191, 36, 0.2); color: var(--tag-writing); }

.practice-card p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin: 0.75rem 0 1.5rem 0;
    flex: 1;
}

.practice-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

.difficulty {
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--brand-secondary);
}

/* ---- AUTH STATE OVERRIDES ---- */
body.auth-state .topbar,
body.auth-state .sidebar {
    display: none;
}

body.auth-state .main-layout {
    padding-top: 0;
}

body.auth-state .content-area {
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---- LOGIN VIEW ---- */
.login-wrapper {
    width: 100%;
    max-width: 450px;
    margin: 0 auto;
}

.login-card {
    padding: 3rem 2.5rem;
    text-align: center;
}

.login-header {
    margin-bottom: 2.5rem;
}

.login-form {
    text-align: left;
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.input-group input {
    width: 100%;
    padding: 0.85rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    transition: var(--transition-smooth);
}

.input-group input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.login-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.forgot-link {
    color: var(--brand-primary);
}

.forgot-link:hover {
    text-decoration: underline;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }

/* ---- SOCIAL PROFILE VIEW ---- */
.profile-container {
    max-width: 900px;
    margin: 0 auto;
}

.profile-cover {
    height: 250px;
    border-radius: 16px 16px 0 0;
    position: relative;
    background-color: var(--bg-surface-hover);
    background-size: cover;
    background-position: center;
    border-bottom: none;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 1rem;
}

.change-cover-btn {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
}

.profile-header-meta {
    border-radius: 0 0 16px 16px;
    padding: 1.5rem 2.5rem;
    display: flex;
    align-items: center;
    position: relative;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.avatar-wrap {
    position: relative;
    margin-top: -60px; /* Overlap the cover */
    margin-right: 2rem;
}

.profile-avatar-large {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid var(--bg-surface);
    background-color: var(--bg-base);
    object-fit: cover;
}

.avatar-edit-btn {
    position: absolute;
    bottom: 5px;
    right: 5px;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: var(--brand-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.profile-titles {
    flex: 1;
}

.profile-titles h1 {
    font-size: 1.8rem;
    margin-bottom: 0.2rem;
}

.profile-level {
    color: var(--brand-secondary);
    font-weight: 500;
}

.profile-stats {
    text-align: center;
}

.stat-num {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}

.stat-lbl {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.profile-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 1.5rem;
}

.d-flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Post Creator Box */
.post-creator-box textarea {
    width: 100%;
    background: rgba(0,0,0,0.15);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    padding: 1rem;
    font-family: inherit;
    resize: none;
    min-height: 80px;
    margin-bottom: 1rem;
    transition: var(--transition-smooth);
}
.post-creator-box textarea:focus {
    outline: none;
    border-color: var(--brand-primary);
}

.post-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Social Posts */
.social-post .post-header {
    display: flex;
    align-items: center;
    position: relative;
}

.post-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    margin-right: 1rem;
    object-fit: cover;
}

.post-header-info {
    flex: 1;
}
.post-author {
    font-weight: 600;
    font-size: 1rem;
}
.post-time {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.post-options-menu {
    position: absolute;
    right: 0;
    top: 40px;
    background: var(--bg-surface-hover);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    z-index: 10;
}
.post-options-menu button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: var(--text-main);
    text-align: left;
    border-radius: 4px;
}
.post-options-menu button:hover {
    background: rgba(255,255,255,0.05);
}
.text-danger { color: #ef4444; }

.post-footer {
    display: flex;
    align-items: center;
    gap: 1.5rem; /* Spacing between like and comment buttons */
}
.post-content {
    font-size: 0.95rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

.post-edit-input {
    width: 100%;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--brand-primary);
    color: #fff;
    padding: 0.5rem;
    border-radius: 4px;
    min-height: 60px;
}

/* Comments */
.post-comment-item {
    display: flex;
    margin-bottom: 0.8rem;
    font-size: 0.9rem;
}
.post-comment-item .post-avatar {
    width: 30px;
    height: 30px;
}
.comment-bubble {
    background: rgba(255,255,255,0.05);
    padding: 0.6rem 1rem;
    border-radius: 12px;
    border-top-left-radius: 4px;
    max-width: 90%;
}
.comment-author {
    font-weight: 600;
    margin-bottom: 0.2rem;
}
.btn-like i.fa-solid {
    color: #ef4444; /* Heart turns red when liked */
}

/* --- GROUPS --- */
.groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}
.group-card {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.group-card-cover {
    height: 120px;
    background: var(--bg-surface-hover);
    background-size: cover;
    background-position: center;
}
.group-card-body {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.group-card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}
.group-card-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    flex: 1;
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.group-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 1rem;
}

/* --- MATERIALS / FILES --- */
.material-item {
    display: flex;
    align-items: center;
    padding: 1.2rem;
    border-radius: 12px;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.05);
    margin-bottom: 1rem;
    transition: var(--transition-smooth);
    overflow: hidden;
}
.material-item:hover {
    background: rgba(255,255,255,0.07);
    transform: translateY(-2px);
}
.material-preview-box {
    width: 60px;
    height: 60px;
    margin-right: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(255,255,255,0.03);
    overflow: hidden;
}
.material-real-thumb {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
}
.pdf-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
    background: white; /* Give PDF's a white background context */
}

.material-icon {
    font-size: 2.2rem;
    color: var(--brand-primary);
}
.material-icon.pdf { color: #ef4444; }
.material-icon.audio { color: #8b5cf6; }
.material-icon.archive { color: #f59e0b; }
.material-info {
    flex: 1;
}
.material-title {
    font-weight: 600;
    margin-bottom: 0.2rem;
    font-size: 1.1rem;
}
.material-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.material-actions .btn {
    margin-left: 0.5rem;
}

/* Material View Toggle overrides */
.view-toggles .btn-icon {
    opacity: 0.4;
    transition: var(--transition-smooth);
    font-size: 1.2rem;
}
.view-toggles .btn-icon:hover {
    opacity: 0.8;
}
.view-toggles .btn-icon.active {
    opacity: 1;
    color: var(--brand-primary);
}

.materials-list.view-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
}
.materials-list.view-grid .material-item {
    flex-direction: column;
    text-align: center;
    padding: 1.5rem 1rem;
    margin-bottom: 0;
}
.materials-list.view-grid .material-preview-box {
    width: 100%;
    height: 140px;
    margin-right: 0;
    margin-bottom: 1rem;
    border-radius: 12px;
}
.materials-list.view-grid .material-icon {
    font-size: 3.5rem;
}
.materials-list.view-grid .material-info {
    margin-bottom: 1rem;
}
.materials-list.view-grid .material-title {
    font-size: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.materials-list.view-grid .material-actions.d-flex {
    justify-content: center;
    width: 100%;
}

/* --- MEDIA VIEWER LIGHTBOX --- */
.media-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.media-lightbox.active {
    opacity: 1;
}
.lightbox-close {
    position: absolute;
    top: 2rem;
    right: 3rem;
    font-size: 2.5rem;
    color: #fff;
    opacity: 0.6;
    transition: var(--transition-smooth);
    z-index: 10000;
}
.lightbox-close:hover {
    opacity: 1;
    transform: scale(1.1) rotate(90deg);
}
.lightbox-content {
    width: 90%;
    height: 85%;
    max-width: 1200px;
    display: flex;
    justify-content: center;
    align-items: center;
}
.lightbox-content img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}
.lightbox-content video {
    max-width: 100%;
    max-height: 100%;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    background: #000;
}
.lightbox-content iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}
.lightbox-audio-wrapper {
    background: var(--bg-surface-glass);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 3rem 4rem;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    text-align: center;
}
.lightbox-audio-wrapper i {
    font-size: 5rem;
    color: var(--brand-primary);
    margin-bottom: 2rem;
}
.lightbox-audio-wrapper audio {
    width: 100%;
    min-width: 300px;
    outline: none;
}

