@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap');
/* ── Espaciado general ── */

/* Entre cards de materias */
#subjects-container {
    gap: 18px;
    margin-top: 2rem;
}

/* Entre category cards en el detalle */
#categories-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 1rem;
}

/* Detalle de materia más aire */
.subject-detail {
    margin-top: 2.5rem;
    padding-top: 2rem;
}

.detail-header {
    margin-bottom: 1.75rem;
}

/* Tasks */
#tasks-container {
    gap: 14px;
    margin-top: 1.5rem;
}

.tasks-form-body {
    gap: 16px;
    padding: 1.5rem;
}

/* Schedule */
.schedule-grid {
    gap: 7px;
}

.schedule-header {
    margin-bottom: 1.75rem;
}

.hidden-section {
    display: none !important;
}
/* ── TOKENS ───────────────────────────────────────────────── */
:root {
    --base-clr:        #0C533A;
    --sidebar-clr:     #082e21;
    --main-bg:         #0f5c3f;
    --line-clr:        rgba(120, 176, 149, 0.16);
    --hover-clr:       rgba(255, 255, 255, 0.07);
    --text-clr:        #e8efe9;
    --accent-clr:      #a9ccbb;
    --secondary-text-clr: #7fb89a;

    --card-bg:         rgba(255, 255, 255, 0.045);
    --card-bg-hover:   rgba(255, 255, 255, 0.07);
    --card-border:     rgba(169, 204, 187, 0.12);
    --card-border-hover: rgba(169, 204, 187, 0.28);

    --green-bright:    #3ddc97;
    --green-mid:       #1fa36f;
    --green-dim:       rgba(61, 220, 151, 0.12);
    --active-bg:       rgba(61, 220, 151, 0.1);
    --active-bar:      #3ddc97;

    --r-sm:  8px;
    --r-md:  12px;
    --r-lg:  18px;
}

/* ── RESET ────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html {
    font-family: Poppins, 'Segoe UI', sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, span, small, strong, a { word-break: break-word; }

/* ── BODY ─────────────────────────────────────────────────── */
body {
    min-height: 100vh;
    min-height: 100dvh;
    background-color: var(--main-bg);
    background-image: radial-gradient(rgba(255,255,255,0.025) 1px, transparent 1px);
    background-size: 28px 28px;
    color: var(--text-clr);
    display: grid;
    grid-template-columns: auto 1fr;
    overflow-x: hidden;
}

#mobile-topbar,
#overlay { display: none; }

/* ── SIDEBAR ──────────────────────────────────────────────── */
#sidebar {
    height: 100vh;
    width: 250px;
    background-color: var(--sidebar-clr);
    background-image: linear-gradient(180deg, rgba(255,255,255,0.025) 0%, transparent 100%);
    border-right: 1px solid var(--line-clr);
    box-shadow: 4px 0 28px rgba(0,0,0,0.3);
    position: sticky;
    top: 0;
    align-self: start;
    transition: width 300ms cubic-bezier(.4,0,.2,1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#sidebar.close { width: 60px; }

/* Listas */
#sidebar > ul:first-child {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    padding: 8px;
    list-style: none;
}
#sidebar > ul:first-child::-webkit-scrollbar { display: none; }

#sidebar > ul:last-child {
    list-style: none;
    padding: 8px;
    border-top: 1px solid var(--line-clr);
}

/* Fila logo + toggle */
#sidebar > ul > li:first-child {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 8px 14px 14px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--line-clr);
    gap: 8px;
    min-width: 0;
    overflow: hidden;
}

#sidebar > ul > li:first-child .logo {
    font-weight: 800;
    font-size: 15px;
    letter-spacing: 0.03em;
    color: var(--text-clr);
    white-space: nowrap;
    overflow: hidden;
    opacity: 1;
    max-width: 160px;
    flex-shrink: 0;
    transition: opacity 200ms ease, max-width 280ms cubic-bezier(.4,0,.2,1);
}

/* Ocultar logo al contraer */
#sidebar.close > ul > li:first-child .logo {
    display: none;
}

/* Centrar el li cuando está colapsado */
#sidebar.close > ul > li:first-child {
    justify-content: center;
    padding: 14px 8px;
}

/* Toggle */
#toggle-btn {
    flex-shrink: 0;
    margin-left: auto;
    padding: 7px;
    border: none;
    border-radius: var(--r-sm);
    background: none;
    cursor: pointer;
    transition: background-color 150ms ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Al colapsar, quitar el margin-left: auto para que quede centrado */
#sidebar.close #toggle-btn {
    margin-left: 0;
}
#toggle-btn:hover { background-color: var(--hover-clr); }
#toggle-btn img {
    transition: rotate 260ms cubic-bezier(.4,0,.2,1);
    width: 18px; height: 18px;
    filter: brightness(0) saturate(100%) invert(85%) sepia(10%) saturate(300%) hue-rotate(100deg);
}
#toggle-btn.rotate img { rotate: 180deg; }

/* Nav buttons */
#sidebar .nav-btn,
#sidebar .dropdown-btn {
    width: 100%;
    background: none;
    border: none;
    font: inherit;
    cursor: pointer;
    text-align: left;

    border-radius: var(--r-md);
    padding: 10px 12px;
    color: rgba(232,239,233,0.6);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13.5px;
    font-weight: 400;
    transition: background-color 160ms ease, color 160ms ease;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}

#sidebar .nav-btn:hover,
#sidebar .dropdown-btn:hover {
    background-color: var(--hover-clr);
    color: var(--text-clr);
}

/* Activo */
#sidebar ul li.active .nav-btn {
    background: var(--active-bg);
    color: var(--green-bright);
    font-weight: 600;
}
#sidebar ul li.active .nav-btn::before {
    content: '';
    position: absolute;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 55%;
    background: var(--active-bar);
    border-radius: 0 3px 3px 0;
}
#sidebar ul li.active .nav-btn i { color: var(--green-bright); }

/* Íconos */
#sidebar i {
    flex-shrink: 0;
    font-size: 1rem;
    width: 20px;
    text-align: center;
    color: inherit;
}
#sidebar img { flex-shrink: 0; width: 18px; }

/* Texto — se oculta al contraer */
#sidebar .nav-btn span,
#sidebar .dropdown-btn span:not(.dropdown-arrow) {
    flex-grow: 1;
    overflow: hidden;
    opacity: 1;
    max-width: 180px;
    transition: opacity 200ms ease, max-width 280ms cubic-bezier(.4,0,.2,1);
    white-space: nowrap;
}

#sidebar.close .nav-btn span,
#sidebar.close .dropdown-btn span:not(.dropdown-arrow) {
    opacity: 0;
    max-width: 0;
    pointer-events: none;
}

/* Dropdown */
.dropdown-btn {
    width: 100%; text-align: left;
    background: none; border: none;
    font: inherit; cursor: pointer;
}
#sidebar .dropdown-btn .dropdown-arrow {
    margin-left: auto; flex-shrink: 0;
    transition: rotate 200ms ease;
    opacity: 0.55; font-size: .85rem;
}
.rotate .dropdown-arrow { rotate: 180deg; }

#sidebar .sub-menu {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 300ms ease-in-out;
}
#sidebar .sub-menu > div { overflow: hidden; }
#sidebar .sub-menu.show { grid-template-rows: 1fr; }
#sidebar .sub-menu a {
    padding-left: 2.5em;
    font-size: 13px;
    color: rgba(232,239,233,0.5);
}

/* ── MAIN ─────────────────────────────────────────────────── */
main {
    padding: 2rem;
    width: 100%;
    min-height: 100vh;
}

.container {
    border: 1px solid var(--card-border);
    border-radius: var(--r-lg);
    padding: 1.5rem;
    background: var(--card-bg);
    backdrop-filter: blur(16px);
}
.container h2, .container p { margin-top: 1em; }

/* ── DASHBOARD ────────────────────────────────────────────── */
.dashboard {
    display: flex; flex-direction: column; gap: 1.25rem;
}

/* Card base */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--r-lg);
    padding: 1.25rem 1.4rem;
    backdrop-filter: blur(14px);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 2px 18px rgba(0,0,0,0.2);
    transition: border-color 200ms ease, background-color 200ms ease;
}
.card:hover {
    border-color: var(--card-border-hover);
    background: var(--card-bg-hover);
}

/* Welcome — borde superior con gradiente */
.welcome-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
    padding: 1.5rem 1.75rem;
    border-radius: var(--r-lg);
    backdrop-filter: blur(14px);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.07), 0 4px 28px rgba(0,0,0,0.22);
    /* Borde degradado */
    background:
        linear-gradient(var(--sidebar-clr), var(--sidebar-clr)) padding-box,
        linear-gradient(100deg, var(--green-bright), var(--green-mid) 60%, rgba(120,176,149,0.4)) border-box;
    border: 1px solid transparent;
}

.welcome-card h1 {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 2.1rem;
    letter-spacing: -0.02em;
}
.welcome-card p {
    color: var(--secondary-text-clr);
    font-size: 13.5px;
    margin-top: 5px;
}

/* XP */
.xp-box { width: 100%; min-width: 0; }

.xp-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11.5px;
    color: var(--accent-clr);
    font-weight: 600;
    margin-bottom: 7px;
    letter-spacing: 0.02em;
}

.xp-bar {
    height: 8px;
    background: rgba(255,255,255,0.08);
    border-radius: 999px;
    overflow: hidden;
}

.xp-fill {
    width: 82%; height: 100%;
    background: linear-gradient(90deg, #3ddc97, #78b095);
    border-radius: 999px;
    position: relative;
}
.xp-fill::after {
    content: '';
    position: absolute;
    top: 0; left: -60%;
    width: 50%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
    animation: xp-shine 2.8s ease-in-out infinite;
}
@keyframes xp-shine {
    0%   { left: -60%; }
    65%  { left: 110%; }
    100% { left: 110%; }
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    width: 100%;
}
.stat-card { display: flex; align-items: center; gap: 14px; }
.stat-card i {
    font-size: 1.2rem;
    padding: .85rem;
    border-radius: var(--r-md);
    background: var(--green-dim);
    color: var(--green-bright);
    flex-shrink: 0;
    border: 1px solid rgba(61,220,151,0.16);
    box-shadow: 0 0 14px rgba(61,220,151,0.1);
}
.stat-card .stat-value {
    font-size: 1.3rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.01em;
}
.stat-card .stat-label {
    font-size: 11px;
    color: var(--secondary-text-clr);
    font-weight: 600;
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Dashboard grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
    width: 100%;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.card-header span:first-child,
.card-header h3 {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-clr);
}
.card-header a {
    color: var(--green-bright);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    opacity: 0.75;
    transition: opacity 150ms;
}
.card-header a:hover { opacity: 1; }

/* Tasks */
.task {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: .85rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.task:last-child { border-bottom: none; }

/* Priority badges */
.priority {
    padding: .28rem .72rem;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
}
.high   { background: rgba(255,80,80,0.13);  color: #ff9090; border: 1px solid rgba(255,80,80,0.22);  }
.medium { background: rgba(255,185,50,0.13); color: #ffd080; border: 1px solid rgba(255,185,50,0.22); }
.low    { background: rgba(61,220,151,0.13); color: #7affc5; border: 1px solid rgba(61,220,151,0.22); }

/* Schedule */
.class-item {
    display: flex; gap: 1rem;
    padding: .9rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.class-item:last-child { border-bottom: none; }
.class-item span {
    min-width: 60px;
    color: var(--accent-clr);
    font-size: 13px;
    font-weight: 600;
}

/* Subject progress */
.subject { margin-bottom: 14px; }
.subject:last-child { margin-bottom: 0; }
.subject-info {
    display: flex; justify-content: space-between;
    font-size: 12.5px; font-weight: 500; margin-bottom: 6px;
}
.subject-info span:last-child { color: var(--accent-clr); font-weight: 700; }

.progress-bar {
    height: 7px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255,255,255,0.07);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.25);
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3ddc97, #78b095);
    border-radius: 999px;
}

/* AI card */
.ai-message {
    display: flex; align-items: flex-start; gap: 12px;
    margin-bottom: 1rem;
    font-size: 13.5px; line-height: 1.65;
    color: var(--accent-clr);
    padding: 12px 14px;
    background: rgba(61,220,151,0.05);
    border-radius: var(--r-md);
    border: 1px solid rgba(61,220,151,0.12);
}
.ai-message i {
    margin-top: .2rem;
    color: var(--green-bright);
    flex-shrink: 0;
}

.ai-btn {
    width: 100%;
    padding: .9rem 1rem;
    border: none;
    border-radius: var(--r-md);
    background: linear-gradient(135deg, #0f7a55, #1fa36f 50%, #18bf72);
    color: #fff;
    font-weight: 700;
    font-size: 13.5px;
    letter-spacing: 0.02em;
    cursor: pointer;
    font-family: inherit;
    transition: transform 180ms ease, box-shadow 180ms ease;
    box-shadow: 0 4px 18px rgba(18,132,92,0.32);
    position: relative;
    overflow: hidden;
}
.ai-btn::before {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.13) 0%, transparent 55%);
    pointer-events: none;
}
.ai-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 26px rgba(18,132,92,0.42);
}
.ai-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(18,132,92,0.3);
}

/* ── MOBILE ───────────────────────────────────────────────── */
@media (max-width: 800px) {

    body { display: block; }

    #mobile-topbar {
        height: 60px;
        padding: 0 1rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: fixed;
        top: 0; left: 0; right: 0;
        background-color: rgba(8,46,33,0.9);
        backdrop-filter: blur(16px);
        border-bottom: 1px solid var(--line-clr);
        z-index: 1000;
        box-shadow: 0 2px 18px rgba(0,0,0,0.32);
    }

    #mobile-topbar span { font-weight: 700; letter-spacing: 0.03em; font-size: 15px; }

    #mobile-menu-btn {
        background: none; border: none;
        color: var(--text-clr); font-size: 1.2rem;
        cursor: pointer; padding: 6px; border-radius: var(--r-sm);
    }

    main { padding: 80px .85rem 2rem .85rem; }
    .container { padding: 1rem; }

    #sidebar {
        position: fixed;
        top: 0; left: 0;
        width: 260px; height: 100vh;
        transform: translateX(-100%);
        transition: transform .3s cubic-bezier(.4,0,.2,1);
        z-index: 2000;
        padding: 0;
    }

    #sidebar.mobile-open { transform: translateX(0); }

    /* En mobile nunca colapsa a iconos */
    #sidebar.close { width: 260px; }

    #sidebar.close a span,
    #sidebar.close .dropdown-btn span:not(.dropdown-arrow) {
        opacity: 1;
        max-width: 180px;
        pointer-events: auto;
    }

    #sidebar.close > ul > li:first-child .logo {
        opacity: 1;
        max-width: 160px;
        pointer-events: auto;
    }

    #toggle-btn { display: none; }

    #overlay {
        position: fixed; display: block; inset: 0;
        background: rgba(0,0,0,0.5);
        backdrop-filter: blur(4px);
        opacity: 0; pointer-events: none;
        transition: opacity .3s ease;
        z-index: 1500;
    }
    #overlay.show { opacity: 1; pointer-events: all; }

    .welcome-card { flex-direction: column; align-items: flex-start; padding: 1.25rem; }
    .welcome-card h1 { font-size: 1.4rem; line-height: 1.75rem; }
    .dashboard-grid, .stats-grid { grid-template-columns: 1fr; overflow: hidden; }
    .task { flex-direction: column; align-items: flex-start; }
    .card { padding: 1rem; min-width: 0; }
    .welcome-card, .welcome-card > div { width: 100%; }
}