/* Global Design System - Examarth Redesign */


:root {
    /* New Color Palette */
    --primary-color: #4F46E5; /* Deep Indigo */
    --primary-hover: #4338ca;
    --secondary-color: #0EA5E9; /* Vibrant Teal */
    --secondary-hover: #0284c7;
    --accent-color: #F43F5E; /* Soft Coral */
    
    --background-color: #F8FAFC; /* Slate-50 */
    --surface-color: #FFFFFF;
    
    --text-color: #1E293B; /* Slate-800 */
    --text-light: #64748B; /* Slate-500 */
    
    --border-color: #E2E8F0; /* Slate-200 */
    
    /* 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-glow: 0 0 15px rgba(79, 70, 229, 0.3);

    /* Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    position: relative;
    min-height: 100vh;
}

/* Global Background Blobs */
body::before {
    content: '';
    position: fixed;
    top: -10%;
    left: -10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.08) 0%, rgba(168, 85, 247, 0.08) 50%, transparent 70%);
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    animation: blob-bounce 20s infinite alternate;
    pointer-events: none;
}

body::after {
    content: '';
    position: fixed;
    bottom: -10%;
    right: -5%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(14, 165, 233, 0.08) 0%, rgba(56, 189, 248, 0.08) 50%, transparent 70%);
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    animation: blob-bounce 25s infinite alternate-reverse;
    pointer-events: none;
}

@keyframes blob-bounce {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(30px, -30px) scale(1.1); }
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Outfit', sans-serif; /* Modern Headings */
    color: var(--text-color);
    line-height: 1.2;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition-fast);
}

ul {
    list-style: none;
}

/* Container */
.container {
    width: 100%;
    max-width: 1400px; /* Increased from 1200px for 4-column layout */
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Navbar */
.navbar {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%) !important;
    backdrop-filter: blur(12px);
    border-bottom: 1px solid #bae6fd;
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: transform 0.3s ease, background 0.3s ease, box-shadow 0.3s ease; /* Added transform transition */
}

/* Smart Navbar Hidden State */
.navbar-hidden {
    transform: translateY(-100%);
    box-shadow: none;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative; /* Needed for absolute centering */
    height: 100%;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    font-family: 'Poppins', sans-serif; /* Changed font */
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.logo span {
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
    -webkit-text-fill-color: unset;
    text-shadow: none; /* Removed shadow */
    color: var(--text-color); /* Fallback */
}

/* Dual Color Styling logic */
.logo span .highlight-exam {
    color: #0f172a; /* Dark Navy for 'Exam' */
}

.logo span .highlight-arth {
    color: var(--primary-color); /* Primary Blue/Purple for 'Arth' */
}

.logo img {
    height: 48px;
    width: auto;
    object-fit: contain;
    filter: none; /* Removed drop-shadow */
}

.nav-links {
    display: flex;
    gap: 1rem; /* Further reduced for tighter spacing */
    align-items: center;
}

/* Auth Buttons Group (Desktop) */
.auth-buttons-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: 1rem; /* Separation from links */
}

/* Ensure buttons inside group align properly */
.auth-buttons-group .btn {
    padding: 0.4rem 1.25rem; /* Thinner buttons as requested */
    font-size: 0.9rem;
}

/* Custom Modal */
.custom-modal-overlay,
.auth-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw; /* Use fixed dimensions */
    height: 100vh; /* Use fixed dimensions */
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(8px);
    display: flex !important;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease-out;
}

.custom-modal-overlay.active,
.auth-modal-overlay.active {
    visibility: visible;
    opacity: 1;
}

.custom-modal {
    background: white;
    padding: 2.5rem 2rem;
    border-radius: 24px;
    width: 90%;
    max-width: 480px; /* Increased to fit 6 digits */
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: scale(0.95);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative; /* Ensure relative positioning for absolute children */
}

.modal-close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-light);
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
    padding: 0.5rem;
    z-index: 10;
}

.modal-close-btn:hover {
    color: var(--text-color);
}


.active .custom-modal {
    transform: scale(1);
}

.modal-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    margin: 0 auto 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
}
.modal-icon.error { background: #fee2e2; color: #ef4444; }
.modal-icon.success { background: #d1fae5; color: #10b981; }
.modal-icon.loading { 
    background: #ebe9fe; 
    color: #4f46e5;
    animation: spin 1s linear infinite; 
}
@keyframes spin { 100% { transform: rotate(360deg); } }

.custom-modal h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.custom-modal p {
    color: var(--text-light);
    margin-bottom: 2rem;
    font-size: 1rem;
    line-height: 1.5;
}

.modal-btn {
    width: 100%;
    padding: 1rem;
    border-radius: 12px;
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
}
.modal-btn:hover { 
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 8px -1px rgba(79, 70, 229, 0.3);
}

/* Auth Modal Specifics */
.otp-input-container {
    display: flex;
    justify-content: center;
    gap: 8px; /* Reduced gap */
    margin: 1.5rem 0;
    flex-wrap: nowrap; /* Prevent wrapping */
}

.otp-input-container input {
    width: 42px; /* Reduced width */
    height: 52px; /* Reduced height */
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    text-align: center;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-color);
    transition: all 0.2s;
    padding: 0; /* Ensure no padding issues */
}

.otp-input-container input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.nav-item {
    font-weight: 500;
    color: var(--text-color); /* Changed from var(--text-light) to be darker */
    font-size: 0.9rem; /* Reduced for better fit */
    position: relative;
}

.nav-item:hover, .nav-item.active {
    color: var(--primary-color);
}

.nav-item::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -4px;
    left: 0;
    background-color: var(--primary-color);
    transition: var(--transition-fast);
}

.nav-item:hover::after, .nav-item.active::after {
    width: 100%;
}

/* Mobile Toggle */
.mobile-toggle {
    display: none;
    font-size: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-color);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-full); /* Pill shape */
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition-fast);
    border: none;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), #6366f1);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px -1px rgba(79, 70, 229, 0.4);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: var(--secondary-hover);
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-color);
}

.btn-outline:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(79, 70, 229, 0.05);
}

/* Cards */
.card {
    background: var(--surface-color);
    border-radius: var(--radius-md);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition-smooth);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(79, 70, 229, 0.2);
}

/* Footer */
footer {
    background: linear-gradient(180deg, #f0f9ff 0%, #e0f2fe 100%) !important;
    padding: 4rem 0 2rem;
    margin-top: auto;
    border-top: 1px solid #bae6fd;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 3rem;
    margin-bottom: 3rem;
}

.footer-col h3 {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

.footer-col ul li {
    margin-bottom: 0.75rem;
}

.footer-col ul li a {
    color: var(--text-light);
}

.footer-col ul li a:hover {
    color: var(--primary-color);
}

.copyright {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Mobile Responsive */

/* --- Profile Dropdown (Desktop) --- */
.profile-dropdown {
    position: absolute;
    top: 125%; /* Below avatar with slight gap */
    right: 0;
    width: 220px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0,0,0,0.05);
    padding: 0.5rem;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: none; /* Hide by default to prevent clicks */
}

/* Show state */
.profile-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-color);
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s ease;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: none; /* Ensure links don't have underline */
}

.dropdown-item i {
    color: var(--text-light);
    width: 20px; /* Fixed width for icons alignment */
    text-align: center;
    transition: color 0.2s ease;
}

.dropdown-item:hover {
    background: #f8fafc;
    color: var(--primary-color);
}

.dropdown-item:hover i {
    color: var(--primary-color);
}

.dropdown-divider {
    height: 1px;
    background: #f1f5f9;
    margin: 0.5rem 0;
}

.text-danger { color: #ef4444; }
.text-danger:hover { background: #fef2f2; color: #dc2626; }
.text-danger:hover i { color: #dc2626; }

/* Responsive Visibility Logic */
.mobile-logout-btn { display: none; } /* Hide mobile logout on desktop */
.dashboard-link-mobile { display: none !important; } /* Hide standalone dashboard link on desktop */

@media (max-width: 1024px) {
    /* Mobile: Hide dropdown completely */
    .profile-dropdown {
        display: none !important;
    }
    
    /* Mobile: Show logout button */
    .mobile-logout-btn {
        display: block;
    }

    /* Mobile: Show dashboard link in side menu */
    .dashboard-link-mobile {
        display: block !important;
    }
    
    /* Reset cursor for avatar in mobile */
    #avatarWrapper {
        cursor: default !important;
    }
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    .navbar {
        height: 70px; /* Fixed height for consistency */
    }

    .nav-container {
        /* Centering Logic */
        justify-content: space-between;
    }

    .navbar .logo {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        font-size: 1.4rem;
        width: max-content;
    }

    .mobile-toggle {
        display: block;
        z-index: 1001; /* Above sidebar */
        position: relative;
    }
    
    /* Push hamburger to the right explicitly if needed, 
       but justify-content: space-between with an empty left element 
       or just flex behavior handles it. 
       Since absolute logo takes it out of flow, we need to balance the flex container.
    */
    
    .nav-links {
        display: flex;
        flex-direction: column;
        gap: 0; /* Override desktop gap */
        position: fixed; /* Fixed positioning to avoid navbar overlap */
        top: 70px; /* Below the navbar */
        left: 0;
        right: auto;
        width: 280px;
        height: calc(100vh - 70px); /* Full height minus navbar */
        background: #ffffff;
        padding: 2rem 1.5rem;
        box-shadow: 4px 0 15px rgba(0,0,0,0.1);
        border-right: 1px solid #f1f5f9;
        /* Animation: Slide from left */
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 999; /* Below navbar (1000) */
        overflow-y: auto;
    }
    
    /* Mobile Auth Group */
    .auth-buttons-group {
        display: flex; /* Override desktop inline-flex/flex */
        flex-direction: column; /* Stack buttons */
        width: 100%;
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        height: auto;
        margin-top: 1.5rem;
        gap: 1rem;
        padding-top: 1.5rem;
        border-top: 1px solid var(--border-color);
    }
    
    .auth-buttons-group .btn {
        width: 100%;
        justify-content: center;
        padding: 0.75rem; /* Restore standard padding */
    }

    .nav-links.active {
        transform: translateX(0);
    }
    
    /* Removed backdrop pseudo-element */
    .nav-links.active::before {
        display: none;
    }

    .nav-item {
        font-size: 1rem;
        padding: 0.5rem 0; /* Reduced from 0.75rem */
        border-bottom: 1px solid #f1f5f9;
        display: block;
        width: 100%;
        transition: all 0.2s ease;
    }
    
    .nav-item:hover {
        padding-left: 8px;
        color: var(--primary-color);
        background: rgba(79, 70, 229, 0.05);
    }
    
    .nav-item:last-of-type {
        border-bottom: none;
    }
    
    /* User profile section in mobile */
    .nav-links .user-profile-nav {
        margin-top: 0.75rem; /* Reduced from 1.5rem */
        padding-top: 0.75rem; /* Reduced from 1.5rem */
        border-top: 2px solid #f1f5f9;
        flex-direction: row !important;
        gap: 0.75rem !important; /* Reduced from 1rem */
        align-items: center !important;
    }
    
    .nav-links .avatar-circle {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px;
        border-radius: 50% !important;
        font-size: 0.9rem !important;
        font-weight: 700;
    }
    
    /* Ensure buttons stack nicely */
    .nav-links .btn {
        margin-top: 0; /* Removed margin since we are in row layout */
        width: auto; /* Allow button to fit content */
        flex: 1; /* Make it take remaining space if needed */
        justify-content: center;
    }
}

/* Cookie Consent Banner */
.cookie-banner {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    right: 2rem;
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-color);
    z-index: 9999;
    animation: slideUp 0.5s ease-out;
    max-width: 800px;
    margin: 0 auto;
}

.cookie-content {
    flex: 1;
    margin-right: 2rem;
}

.cookie-content h4 {
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.cookie-content p {
    font-size: 0.9rem;
    color: var(--text-light);
}

@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 768px) {
    .cookie-banner {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }
    .cookie-content {
        margin-right: 0;
    }
    .cookie-banner .btn {
        width: 100%;
    }
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 45px;
    height: 45px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    opacity: 0;
    visibility: hidden;
    z-index: 900; /* Below mobile menu (1000) but above content */
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    transform: translateY(-5px);
    background: var(--primary-hover);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Mobile Footer Fixes and Back-to-Top Adjustment */
@media (max-width: 768px) {
    .back-to-top {
        bottom: 2rem;
        right: 1rem;
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .footer-content {
        text-align: center;
        gap: 2rem;
    }

    .footer-col .logo {
        justify-content: center; /* Center the flex logo */
        margin-bottom: 1rem;
    }
    
    .back-to-top {
        bottom: 1.5rem;
        right: 1.5rem;
    }
}

/* Admin Preview Button */
.admin-preview-btn {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
    z-index: 9999;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.admin-preview-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.5);
    background: var(--primary-hover);
}

@media (max-width: 768px) {
    .admin-preview-btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
        top: 0.75rem;
        right: 0.75rem;
    }
}
