/* ===== GOOGLE FONTS (add link in HTML) ===== */

/* ===== DARK MODE VARIABLES ===== */
[data-theme="dark"] {
    --primary-color: #818cf8;
    --primary-hover: #a5b4fc;
    --secondary-color: #7c3aed;
    --danger-color: #f87171;
    --success-color: #4ade80;
    --warning-color: #fb923c;
    --muted-text: #94a3b8;
    --strong-text: #f1f5f9;
    --border-color: #334155;
    --card-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}
[data-theme="dark"] body {
    background-image: linear-gradient(180deg, #0f172a 0%, #1e1b4b 100%);
    color: var(--strong-text);
}
[data-theme="dark"] .container {
    background: rgba(30, 41, 59, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-color: rgba(99, 102, 241, 0.15);
}
[data-theme="dark"] .container.highlight {
    background: rgba(30, 41, 59, 0.85);
    border-color: rgba(99, 102, 241, 0.25);
}
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="number"] {
    background: rgba(15, 23, 42, 0.6);
    border-color: #475569;
    color: #f1f5f9;
}
[data-theme="dark"] input[type="text"]:focus,
[data-theme="dark"] input[type="number"]:focus {
    background: rgba(15, 23, 42, 0.8);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.25);
}
[data-theme="dark"] thead th {
    background: rgba(99, 102, 241, 0.18);
    color: var(--primary-hover);
}
[data-theme="dark"] tbody tr { background: rgba(30, 41, 59, 0.5); }
[data-theme="dark"] tbody tr[data-grade="grade-high"] { background: rgba(34, 197, 94, 0.1); }
[data-theme="dark"] tbody tr[data-grade="grade-mid"] { background: rgba(234, 179, 8, 0.1); }
[data-theme="dark"] tbody tr[data-grade="grade-low"] { background: rgba(239, 68, 68, 0.1); }
[data-theme="dark"] tbody tr[data-grade="grade-neutral"] { background: rgba(100, 116, 139, 0.15); }
[data-theme="dark"] .materia {
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.7) 0%, rgba(15, 23, 42, 0.8) 65%);
    border-color: rgba(100, 116, 139, 0.25);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 12px 24px rgba(0,0,0,0.25);
}
[data-theme="dark"] .corte {
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.6) 0%, rgba(15, 23, 42, 0.7) 100%);
    border-color: rgba(100, 116, 139, 0.2);
}
[data-theme="dark"] .corte-subtotal { border-top-color: rgba(100, 116, 139, 0.25); }
[data-theme="dark"] th, [data-theme="dark"] td { border-bottom-color: #334155; }

/* Mobile cards dark mode */
@media (max-width: 600px) {
    [data-theme="dark"] table tbody tr {
        background: rgba(30, 41, 59, 0.8) !important;
        border-color: rgba(100, 116, 139, 0.25);
    }
    [data-theme="dark"] .nota-item {
        background: rgba(15, 23, 42, 0.5);
        border-color: rgba(100, 116, 139, 0.25);
        border-left-color: var(--materia-color-base, var(--primary-color));
    }
}

/* ===== GLASSMORPHISM LIGHT MODE ===== */
.container {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: background 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

/* ===== DARK MODE TOGGLE ===== */
.theme-toggle {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.4rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}
.theme-toggle:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.25);
}
[data-theme="dark"] .theme-toggle {
    background: rgba(30, 41, 59, 0.85);
    border-color: rgba(129, 140, 248, 0.25);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* ===== ANIMATED BACKGROUND ===== */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.06) 0%, transparent 50%),
                radial-gradient(ellipse at 80% 20%, rgba(168, 85, 247, 0.05) 0%, transparent 50%),
                radial-gradient(ellipse at 50% 80%, rgba(59, 130, 246, 0.04) 0%, transparent 50%);
    animation: auroraMove 20s ease-in-out infinite alternate;
    z-index: -1;
    pointer-events: none;
}
[data-theme="dark"] body::before {
    background: radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.12) 0%, transparent 50%),
                radial-gradient(ellipse at 80% 20%, rgba(168, 85, 247, 0.1) 0%, transparent 50%),
                radial-gradient(ellipse at 50% 80%, rgba(59, 130, 246, 0.08) 0%, transparent 50%);
}

/* ===== ANIMATIONS ===== */
@keyframes auroraMove {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(3%, 2%) rotate(3deg); }
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(80px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes slideOutRight {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(80px); }
}
@keyframes progressPulse {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: 0 0 8px currentColor; }
}

/* Materia entrance */
.materia { animation: fadeInUp 0.4s ease both; }
.materia:nth-child(2) { animation-delay: 0.05s; }
.materia:nth-child(3) { animation-delay: 0.1s; }
.materia:nth-child(4) { animation-delay: 0.15s; }
.materia:nth-child(5) { animation-delay: 0.2s; }

/* Smooth expand/collapse */
.materia-body {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.45s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.35s ease,
                margin-top 0.35s ease;
    margin-top: 0;
}
.materia-body.expanded {
    max-height: 3000px;
    opacity: 1;
    margin-top: 1.1rem;
}
/* Override the old collapsed class */
.materia-body.collapsed {
    display: block !important;
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

/* ===== PROGRESS BAR ===== */
.progress-container {
    margin-top: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
}
.progress-bar {
    flex: 1;
    height: 8px;
    background: rgba(148, 163, 184, 0.18);
    border-radius: 99px;
    overflow: hidden;
    position: relative;
}
.progress-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1), background 0.4s ease;
    min-width: 0;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
}
.progress-fill[data-grade="grade-high"] { background: linear-gradient(90deg, #22c55e, #16a34a); }
.progress-fill[data-grade="grade-mid"] { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.progress-fill[data-grade="grade-low"] { background: linear-gradient(90deg, #f87171, #ef4444); }
.progress-label {
    font-size: 0.8rem;
    font-weight: 700;
    min-width: 42px;
    text-align: right;
    color: var(--muted-text);
}

/* ===== CUSTOM MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.2s ease;
}
.modal-box {
    background: #fff;
    border-radius: 20px;
    padding: 2rem 2.25rem;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 25px 60px rgba(15, 23, 42, 0.25);
    animation: scaleIn 0.25s ease;
    text-align: center;
}
[data-theme="dark"] .modal-box {
    background: #1e293b;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
}
.modal-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}
.modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    color: var(--strong-text);
}
.modal-message {
    font-size: 0.95rem;
    color: var(--muted-text);
    margin: 0 0 1.5rem;
    line-height: 1.5;
}
.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}
.modal-btn {
    padding: 0.6rem 1.5rem;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}
.modal-btn-cancel {
    background: rgba(148, 163, 184, 0.15);
    color: var(--muted-text);
}
.modal-btn-cancel:hover { background: rgba(148, 163, 184, 0.25); }
.modal-btn-confirm {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
}
.modal-btn-confirm:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35); }

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9998;
    display: flex;
    flex-direction: column-reverse;
    gap: 0.65rem;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.85rem 1.25rem;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--strong-text);
    animation: slideInRight 0.35s ease both;
    border-left: 4px solid var(--primary-color);
    max-width: 360px;
}
[data-theme="dark"] .toast {
    background: #1e293b;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.toast.toast-exit { animation: slideOutRight 0.3s ease both; }
.toast-success { border-left-color: #16a34a; }
.toast-danger { border-left-color: #ef4444; }
.toast-warning { border-left-color: #f97316; }
.toast-icon { font-size: 1.2rem; flex-shrink: 0; }

/* ===== ENHANCED HOVER EFFECTS ===== */
.materia {
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.materia:hover {
    transform: translateY(-3px);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 16px 35px rgba(15, 23, 42, 0.12);
}
[data-theme="dark"] .materia:hover {
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 16px 35px rgba(0,0,0,0.35);
}
.btn-primary {
    transition: all 0.25s ease;
    box-shadow: 0 4px 14px rgba(76, 110, 245, 0.25);
}
.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(76, 110, 245, 0.35);
}
.badge {
    transition: all 0.3s ease;
}

/* ===== BODY TRANSITION ===== */
body {
    transition: background-image 0.5s ease, color 0.3s ease;
}

/* ===== SUBNOTAS ===== */
.subnotas-toggle {
    background: none;
    border: none;
    padding: 0.2rem;
    font-size: 0.95rem;
    cursor: pointer;
    opacity: 0.45;
    transition: all 0.2s ease;
    border-radius: 6px;
    line-height: 1;
    flex-shrink: 0;
}
.subnotas-toggle:hover { opacity: 0.85; background: rgba(99,102,241,0.1); }
.subnotas-toggle.active { opacity: 1; background: rgba(99,102,241,0.12); }

.subnotas-panel {
    grid-column: 1 / -1;
    margin-top: 0.35rem;
    padding: 0.6rem 0.75rem;
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.05);
    border: 1px dashed rgba(99, 102, 241, 0.2);
    animation: fadeInUp 0.25s ease both;
}
[data-theme="dark"] .subnotas-panel {
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.2);
}
.subnotas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.45rem;
    gap: 0.5rem;
}
.subnotas-header small {
    font-size: 0.78rem;
    color: var(--muted-text);
    font-weight: 600;
}
.subnotas-promedio {
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 99px;
    background: rgba(99, 102, 241, 0.12);
    color: var(--primary-color);
}
.subnotas-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}
.subnota-input {
    width: 58px !important;
    padding: 0.35rem 0.5rem !important;
    font-size: 0.85rem !important;
    text-align: center;
    border-radius: 8px !important;
}
.subnota-remove {
    background: none;
    border: none;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--muted-text);
    padding: 0.1rem 0.25rem;
    border-radius: 4px;
    transition: all 0.15s ease;
    line-height: 1;
}
.subnota-remove:hover { color: var(--danger-color); background: rgba(239,68,68,0.1); }
.subnota-item {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
}
.subnotas-add-btn {
    background: none;
    border: 1px dashed rgba(99,102,241,0.3);
    border-radius: 8px;
    width: 32px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    color: var(--primary-color);
    padding: 0;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.subnotas-add-btn:hover { background: rgba(99,102,241,0.1); border-color: var(--primary-color); }

/* ===== RESPONSIVE TOAST ===== */
@media (max-width: 600px) {
    .toast-container { left: 1rem; right: 1rem; bottom: 1rem; }
    .toast { max-width: 100%; }
    .theme-toggle { top: 0.75rem; right: 0.75rem; width: 42px; height: 42px; font-size: 1.2rem; }
    .subnota-input { width: 50px !important; }
}
