/* Mobile & small-viewport refinements shared by all static pages */
:root {
    --nav-gap: clamp(0.5rem, 2vw, 0.75rem);
    --primary-orange: #f97316;
    --primary-amber: #d97706;
}

html {
    scroll-behavior: smooth;
}

body {
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Base mobile spacing resets */
@media (max-width: 1023px) {
    /* Hide ALL desktop navigation links in ALL nav bars on mobile/tablet */
    nav .flex.space-x-2,
    nav .flex.space-x-4,
    nav .flex.space-x-6,
    nav .hidden.md\:flex,
    #authButtons,
    #userMenu {
        display: none !important;
    }

    /* Keep the logo/brand name centered or left, but remove space for hidden links */
    nav .flex.justify-between {
        justify-content: center !important;
    }
}

@media (max-width: 768px) {
    /* Hide legacy mobile menu buttons and containers */
    #mobileMenuBtn, 
    #mobileMenu,
    .md\:hidden.p-2.rounded-lg.hover\:bg-amber-700,
    nav button[id*="mobile"],
    nav div[id*="mobile"] {
        display: none !important;
    }

    /* Professional Card styling on mobile - make it full width on very small screens */
    .bg-white.rounded-xl, 
    .bg-white.rounded-2xl,
    .card,
    .glass-card {
        margin-left: 0 !important;
        margin-right: 0 !important;
        border-radius: 1.5rem !important; /* Slightly more rounded for modern look */
        padding: 1.5rem 1rem !important;
        width: calc(100% - 1.25rem) !important;
        margin: 0.75rem auto !important;
    }

    .glass-card {
        background: rgba(255, 255, 255, 0.7) !important;
        backdrop-filter: blur(15px) !important;
        -webkit-backdrop-filter: blur(15px) !important;
        border: 1px solid rgba(255, 255, 255, 0.4) !important;
        box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07) !important;
    }
    
    /* Remove body padding to allow full-width cards */
    body {
        padding: 0 !important;
    }
    
    .max-w-3xl, .max-w-4xl, .max-w-7xl {
        padding: 0 !important;
    }

    /* Teacher Panel Cards (Admin) */
    .grid-cols-1.md\:grid-cols-2.lg\:grid-cols-4.gap-4 {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.75rem !important;
        padding: 0 0.75rem !important;
    }

    /* Target the teacher panel links specifically */
    a[href^="admin-"] {
        display: grid !important;
        grid-template-columns: 60px 1fr !important;
        grid-template-areas: 
            "icon title"
            "icon desc" !important;
        align-items: center !important;
        text-align: left !important;
        padding: 1.25rem 1rem !important;
        gap: 0 0.75rem !important;
        border-radius: 16px !important;
        width: calc(100% - 1.5rem) !important;
        margin: 0.5rem auto !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1) !important;
    }

    a[href^="admin-"] .text-4xl {
        grid-area: icon !important;
        font-size: 2.5rem !important;
        margin-bottom: 0 !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
    }

    a[href^="admin-"] h4 {
        grid-area: title !important;
        margin: 0 !important;
        padding: 0 !important;
        font-size: 1.25rem !important;
        font-weight: 700 !important;
        align-self: end !important; /* Title closer to top half of icon */
        line-height: 1.2 !important;
    }

    a[href^="admin-"] p {
        grid-area: desc !important;
        margin: 0 !important;
        padding: 0 !important;
        font-size: 0.9rem !important;
        opacity: 0.95 !important;
        align-self: start !important; /* Description in bottom half of icon area */
        line-height: 1.3 !important;
        white-space: normal !important; /* Allow normal wrapping */
    }

    .bg-white.rounded-xl h3, 
    .bg-white.rounded-2xl h3 {
        font-size: 1.25rem !important;
        line-height: 1.4 !important;
        margin-top: 0.5rem !important;
    }

    .bg-white.rounded-xl p, 
    .bg-white.rounded-2xl p {
        font-size: 0.95rem !important;
        line-height: 1.5 !important;
        color: #4b5563 !important;
    }

    .bg-white.rounded-xl .text-5xl,
    .bg-white.rounded-2xl .text-5xl {
        font-size: 3rem !important;
        margin-bottom: 0.75rem !important;
    }

    /* Form improvements */
    input, select, textarea {
        font-size: 16px !important; /* Prevents iOS zoom on focus */
        padding: 0.875rem 1rem !important;
        width: 100% !important;
        background-color: #fff !important;
        border: 1.5px solid #e5e7eb !important;
        border-radius: 12px !important;
        appearance: none !important; /* Remove native arrow */
    }

    /* Custom arrow for select dropdowns */
    select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E") !important;
        background-repeat: no-repeat !important;
        background-position: right 1rem center !important;
        background-size: 1.25rem !important;
        padding-right: 2.5rem !important;
    }

    label {
        margin-bottom: 0.6rem !important;
        font-weight: 700 !important;
        color: #1f2937 !important;
        display: flex !important;
        align-items: center !important;
        text-align: left !important;
        font-size: 0.95rem !important;
    }

    /* Tooltip adjustments for mobile */
    .cursor-help {
        width: 22px !important;
        height: 22px !important;
        font-size: 14px !important;
        background-color: #f3f4f6 !important;
        color: #6b7280 !important;
        margin-left: 4px !important;
    }

    /* Grid spacing for mobile fields */
    .space-y-6 > * + * {
        margin-top: 1.75rem !important;
    }

    /* Custom Dropdown Styles */
    .custom-select-container {
        position: relative;
        width: 100%;
    }

    .custom-select-trigger {
        width: 100% !important;
        background-color: #fff !important;
        border: 1.5px solid #e5e7eb !important;
        border-radius: 12px !important;
        padding: 0.875rem 1rem !important;
        font-size: 16px !important;
        color: #374151;
        display: flex;
        justify-content: space-between;
        align-items: center;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .custom-select-trigger:after {
        content: "";
        width: 1.25rem;
        height: 1.25rem;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: center;
        transition: transform 0.3s ease;
    }

    .custom-select-container.open .custom-select-trigger:after {
        transform: rotate(180deg);
    }

    .custom-select-container.open .custom-select-trigger {
        border-color: #f59e0b !important;
        box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
    }

    .custom-options {
        position: absolute;
        top: calc(100% + 5px);
        left: 0;
        right: 0;
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        z-index: 1000;
        max-height: 250px;
        overflow-y: auto;
        display: none;
        padding: 0.5rem;
        animation: selectFadeIn 0.2s ease-out;
    }

    @keyframes selectFadeIn {
        from { opacity: 0; transform: translateY(-10px); }
        to { opacity: 1; transform: translateY(0); }
    }

    .custom-select-container.open .custom-options {
        display: block;
    }

    .custom-option {
        padding: 0.75rem 1rem;
        font-size: 16px;
        color: #4b5563;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.15s ease;
    }

    .custom-option:hover {
        background-color: #fff7ed;
        color: #f59e0b;
    }

    .custom-option.selected {
        background-color: #f59e0b;
        color: #fff;
        font-weight: 600;
    }

    /* Hide native select but keep it for form submission */
    .native-select-hidden {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border-width: 0;
    }

    /* Footer mobile alignment */
    footer {
        text-align: center !important;
    }
    
    footer .grid {
        gap: 2.5rem !important;
    }
    
    footer ul {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    /* Button professional look - targeted to actual buttons, not large cards */
    .btn, 
    button, 
    a.bg-amber-600, 
    a.bg-orange-600, 
    a.bg-gradient-to-r,
    .cta-button {
        min-height: 48px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        letter-spacing: 0.01em;
    }

    /* Ensure cards stay vertical */
    .bg-white.rounded-xl, 
    .bg-white.rounded-2xl {
        display: flex !important;
        flex-direction: column !important;
        text-align: left !important; /* Changed to left for better form readability */
    }

    /* Center only specific informational headings if needed */
    .bg-white.rounded-xl h2, 
    .bg-white.rounded-2xl h2 {
        text-align: center !important;
        width: 100%;
        margin-bottom: 0.5rem !important;
    }

    .bg-white.rounded-xl > p:first-of-type, 
    .bg-white.rounded-2xl > p:first-of-type {
        text-align: center !important;
        width: 100%;
        margin-bottom: 1.5rem !important;
    }

    /* Keep upload box content centered */
    .border-dashed {
        height: auto !important;
        min-height: 140px !important;
        padding: 1rem !important;
    }
    
    .border-dashed div {
        text-align: center !important;
        padding: 0 !important;
    }

    .border-dashed p {
        margin-bottom: 0.25rem !important;
    }

    /* Tables on mobile */
    .overflow-x-auto {
        border-radius: 12px;
        border: 1px solid #e5e7eb;
        margin: 1rem 0;
    }

    /* Admin Filter improvements */
    #groupFilter {
        min-width: 200px;
    }
}

/* Professional slide-in menu improvements */
.global-menu-toggle {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 1100;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    flex-direction: column;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.global-menu-toggle .line {
    width: 24px;
    height: 2.5px;
    border-radius: 4px;
    background: var(--primary-amber);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.global-menu-toggle.active {
    background: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.global-menu-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100dvh;
    width: min(85vw, 340px);
    background: #fff;
    z-index: 1099;
    transform: translateX(105%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    padding: 0;
    box-shadow: -15px 0 45px rgba(0, 0, 0, 0.15);
}

.global-menu-drawer.open {
    transform: translateX(0);
}

.drawer-header {
    padding: 2rem 1.5rem 1rem;
    border-bottom: 1px solid #f3f4f6;
    margin-bottom: 1rem;
}

.drawer-logo {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary-amber);
    display: flex;
    align-items: center;
    gap: 8px;
}

.drawer-links {
    flex: 1;
    overflow-y: auto;
    padding: 0 1rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.global-menu-link {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    color: #4b5563;
    font-weight: 500;
    font-size: 1.05rem;
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.global-menu-link:hover {
    background: #fff7ed;
    color: var(--primary-amber);
    padding-left: 1.5rem;
}

.global-menu-link.active {
    background: var(--primary-amber);
    color: #fff;
    font-weight: 600;
}

.global-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1098;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.global-menu-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

    /* Typography adjustments */
    h2.text-3xl {
        font-size: 1.75rem !important;
        line-height: 1.2 !important;
    }

    /* Section specifically for exam/registration descriptions */
    .bg-white > p.text-gray-600 {
        font-size: 0.95rem !important;
        margin-bottom: 2rem !important;
        padding: 0 0.5rem;
    }

    /* Fix download section on mobile */
    #downloadSection {
        padding: 1.25rem !important;
        margin: 1rem 0 !important;
    }
    
    #downloadSection .flex {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
    }
    
    #downloadSection .bg-blue-500 {
        margin-bottom: 1rem;
    }

main, section, .form-container, .admin-dashboard {
    animation: fadeIn 0.4s ease-out forwards;
}

/* Tabs and Pills for mobile */
@media (max-width: 768px) {
    .flex-wrap {
        gap: 0.5rem !important;
    }

    button[data-exam-course],
    button[data-course],
    .tab-btn {
        flex: 1 1 calc(50% - 0.5rem); /* 2 columns for tabs */
        min-width: 140px;
        font-size: 0.9rem !important;
        padding: 0.75rem 0.5rem !important;
    }
}

/* Professional status messages */
#statusMessage {
    border-radius: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (min-width: 1024px) {
    .global-menu-toggle, .global-menu-drawer, .global-menu-overlay {
        display: none !important;
    }
}

