:root {
    /* Refined Palette - High Contrast */
    /* Refined Palette - High Contrast */
    --unab-blue: #001f3f;
    /* True Dark Navy Blue */
    --unab-blue-light: #003366;
    /* Slightly lighter navy */
    --unab-red: #dc2626;
    /* Stronger red */
    --primary-color: var(--unab-blue);
    --secondary-color: var(--unab-red);

    /* Neutral Tones - Increased Contrast */
    --bg-body: #f1f5f9;
    /* Slightly darker gray to pop the white cards */
    --bg-surface: #ffffff;
    --text-primary: #020617;
    /* Almost black */
    --text-secondary: #475569;
    /* Darker gray */
    --border-color: #cbd5e1;
    /* Darker border */

    /* Modern Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-soft: 0 20px 25px -5px rgb(0 0 0 / 0.05), 0 8px 10px -6px rgb(0 0 0 / 0.01);

    --radius-md: 0.75rem;
    /* 12px */
    --radius-lg: 1rem;
    /* 16px */

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --unab-blue: #38bdf8;
    /* Lighter blue for dark mode headings */
    --unab-blue-light: #0ea5e9;
    --unab-red: #f87171;
    /* Softer red for dark mode */
    --primary-color: #e2e8f0;
    /* Light text for primary */

    --bg-body: #0f172a;
    /* Slate 900 */
    --bg-surface: #1e293b;
    /* Slate 800 */
    --text-primary: #f8fafc;
    /* Slate 50 */
    --text-secondary: #94a3b8;
    /* Slate 400 */
    --border-color: #334155;
    /* Slate 700 */

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    background-image:
        radial-gradient(at 0% 0%, rgba(27, 38, 79, 0.03) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(200, 16, 46, 0.03) 0px, transparent 50%);
    background-attachment: fixed;
}

/* Glassmorphic Header */
.main-header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: var(--shadow-sm);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: var(--transition);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    max-width: 1200px;
    margin: 0 auto;
}

.logo {
    height: 56px;
    width: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.header-text h1 {
    font-size: 1.35rem;
    color: var(--unab-blue);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.header-text p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Upload Button - Modern Gradient */
.upload-btn {
    margin-left: auto;
    background: linear-gradient(135deg, var(--unab-blue), var(--unab-blue-light));
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    /* Pill shape */
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    box-shadow: 0 4px 12px rgba(27, 38, 79, 0.25);
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(27, 38, 79, 0.35);
    background: linear-gradient(135deg, var(--unab-blue-light), var(--unab-blue));
}

.upload-btn i {
    font-size: 1rem;
}

/* Theme Toggle Button */
.theme-toggle {
    background: transparent;
    border: 1px solid var(--border-color);
    height: 40px;
    padding: 0 1rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
    margin-left: auto;
    font-size: 0.9rem;
    font-weight: 500;
}

.theme-toggle:hover {
    color: var(--unab-blue);
    border-color: var(--unab-blue);
}

.bg-custom-blue {
    background-color: var(--bg-surface);
}

/* Layout */
.container {
    display: flex;
    max-width: 1280px;
    margin: 2.5rem auto;
    padding: 0 1.5rem;
    gap: 2.5rem;
}

/* Modern Floating Sidebar */
.sidebar {
    width: 280px;
    flex-shrink: 0;
    background: var(--bg-surface);
    padding: 1.75rem;
    border-radius: var(--radius-lg);
    height: fit-content;
    position: sticky;
    top: 110px;
    /* Offset for header */
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.sidebar h2 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
    font-weight: 700;
}

#semester-nav button {
    display: flex;
    align-items: center;
    width: 100%;
    text-align: left;
    padding: 0.85rem 1.25rem;
    margin-bottom: 0.5rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition);
}

#semester-nav button:hover {
    background-color: #f1f5f9;
    color: var(--unab-blue);
}

#semester-nav button.active {
    background-color: rgba(27, 38, 79, 0.08);
    /* Transparent blue bg */
    color: var(--unab-blue);
    font-weight: 600;
    border-color: rgba(27, 38, 79, 0.1);
}

/* Main Content */
.content-area {
    flex-grow: 1;
}

.filters {
    margin-bottom: 2.5rem;
}

#current-semester-title {
    font-size: 2rem;
    color: var(--unab-blue);
    margin-bottom: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.subject-filter-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
}

.filter-btn {
    padding: 0.6rem 1.25rem;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    border-radius: 9999px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.filter-btn:hover {
    border-color: var(--unab-blue);
    color: var(--unab-blue);
    transform: translateY(-1px);
}

.filter-btn.active {
    background-color: var(--unab-red);
    color: white;
    border-color: var(--unab-red);
    box-shadow: 0 4px 10px rgba(158, 27, 50, 0.3);
}

/* Modern Card Grid */
.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}

.note-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.note-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg);
    border-color: transparent;
}

.card-image-container {
    height: 190px;
    overflow: hidden;
    position: relative;
    background-color: #cbd5e1;
}

.card-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.note-card:hover .card-image-container img {
    transform: scale(1.08);
    /* Slower, smoother zoom */
}

/* Card Badge - Glassy */
.badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    color: var(--unab-blue);
    padding: 0.35rem 0.85rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.card-content {
    padding: 1.75rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.card-content h3 {
    font-size: 1.15rem;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    line-height: 1.4;
    font-weight: 600;
}

.author {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.author::before {
    content: '';
    display: block;
    width: 24px;
    height: 24px;
    background-color: #f1f5f9;
    border-radius: 50%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2394a3b8'%3E%3Cpath d='M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z'/%3E%3C/svg%3E");
    background-size: 60%;
    background-position: center;
    background-repeat: no-repeat;
}

.card-footer {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

.year-badge {
    font-weight: 600;
    color: var(--text-secondary);
    background: #f1f5f9;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8rem;
}

.view-note-btn {
    background: linear-gradient(135deg, var(--unab-red), #b91c1c);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
    box-shadow: 0 2px 5px rgba(220, 38, 38, 0.3);
}

.note-card:hover .view-note-btn {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(220, 38, 38, 0.4);
}

.view-note-btn i {
    font-size: 0.75rem;
}

/* Modal - Glassmorphism & Centered */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.6);
    /* Darker backdrop */
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    background-color: var(--white);
    margin: 5vh auto;
    padding: 0;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 550px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    position: relative;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    background: white;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-header h2 {
    font-size: 1.5rem;
    color: var(--unab-blue);
    font-weight: 700;
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(40px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close-btn {
    color: #cbd5e1;
    float: right;
    font-size: 2rem;
    font-weight: 400;
    cursor: pointer;
    transition: var(--transition);
    line-height: 0.8;
}

.close-btn:hover {
    color: var(--unab-red);
    transform: rotate(90deg);
}

/* Modern Form */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.95rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    background-color: #f8fafc;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--unab-blue);
    background-color: white;
    box-shadow: 0 0 0 4px rgba(27, 38, 79, 0.1);
}

.submit-btn {
    width: 100%;
    padding: 1rem;
    background: var(--unab-blue);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 1rem;
    box-shadow: 0 4px 6px -1px rgba(27, 38, 79, 0.2);
}

.submit-btn:hover {
    background: var(--unab-blue-light);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(27, 38, 79, 0.3);
}

/* Processing/Spinner */
.spinner-container {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5rem;
    color: var(--text-secondary);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 5px solid #e2e8f0;
    border-left-color: var(--unab-blue);
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.55, 0.055, 0.675, 0.19) infinite;
    margin-bottom: 1.5rem;
}

/* Footer */
.main-footer {
    background-color: #0a0a0a;
    /* Very dark neutral for footer */
    color: white;
    margin-top: 6rem;
    padding: 4rem 2rem 2rem;
    position: relative;
    overflow: hidden;
}

/* Decorative Footer background element */
.main-footer::after {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 200px;
    height: 200px;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.05));
    border-radius: 50%;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 3rem;
    padding-bottom: 3rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-section h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    color: white;
    opacity: 0.9;
}

.footer-section p {
    font-size: 0.95rem;
    line-height: 1.7;
    color: #cbd5e1;
}

.footer-section a {
    color: white;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    padding-bottom: 1px;
    transition: var(--transition);
}

.footer-section a:hover {
    color: white;
    border-color: white;
}

.footer-bottom {
    max-width: 1200px;
    margin: 0 auto;
    padding-top: 2rem;
    text-align: center;
    font-size: 0.9rem;
    color: #94a3b8;
}

/* Responsive */
@media (max-width: 900px) {
    .container {
        flex-direction: column;
        gap: 2rem;
        margin-top: 1.5rem;
    }

    .sidebar {
        width: 100%;
        position: static;
        order: -1;
        /* Sidebar on top or use a different mobile menu pattern */
    }

    .sidebar h2 {
        display: none;
        /* Hide 'SEMESTRES' title on mobile to save space */
    }

    #semester-nav {
        display: flex;
        overflow-x: auto;
        padding-bottom: 0.5rem;
        gap: 0.5rem;
        scrollbar-width: thin;
        /* Firefox */
    }

    #semester-nav button {
        width: auto;
        white-space: nowrap;
        margin-bottom: 0;
        padding: 0.5rem 1rem;
        background: white;
        border: 1px solid var(--border-color);
        box-shadow: var(--shadow-sm);
    }

    #semester-nav button.active {
        background: var(--unab-blue);
        color: white;
    }

    .logo-container {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }

    .upload-btn {
        margin: 1rem auto 0;
        width: 100%;
        justify-content: center;
    }
}