/* Mobile CSS - Load this first in your HTML */

/* Mobile-first approach: styles for screens 768px and below */
@media screen and (max-width: 768px) {
    .main-header-inner {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 15px 20px !important;
        position: relative;
        height: auto !important;
        gap: 0 !important;
    }

    .logo-container {
        display: flex !important;
        align-items: center;
        gap: 10px;
        order: 1;
        /* Keep logo on the left */
        flex: 0 0 auto;
    }

    .logo-image {
        width: 40px !important;
        height: 40px !important;
        object-fit: contain;
    }

    .logo-container h1 {
        font-size: 1.2rem;
        margin: 0;
    }

    /* Hamburger button - positioned on the right */
    .hamburger-menu {
        display: flex !important;
        flex-direction: column;
        justify-content: space-around;
        width: 30px;
        height: 25px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0;
        z-index: 1001;
        order: 3;
        /* Keep hamburger on the right */
        flex: 0 0 auto;
        margin-left: auto;
    }

    .hamburger-menu span {
        width: 100%;
        height: 3px;
        background-color: #333;
        border-radius: 3px;
        transition: all 0.3s ease;
    }

    /* Hamburger animation when open */
    .hamburger-menu.active span:nth-child(1) {
        transform: rotate(45deg) translate(8px, 8px);
    }

    .hamburger-menu.active span:nth-child(2) {
        opacity: 0;
    }

    .hamburger-menu.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -7px);
    }

    /* Hide desktop navigation and auth buttons by default */
    .main-header-inner .header-flex-center,
    .main-header-inner .auth-buttons,
    .main-header-inner .nav-right,
    .header-flex-center,
    .auth-buttons,
    .nav-right {
        display: none !important;
    }

    /* Mobile menu container */
    .mobile-menu {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        background-color: #fff;
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
        padding: 80px 20px 20px;
        transition: right 0.3s ease;
        z-index: 1000;
        overflow-y: auto;
    }

    .mobile-menu.active {
        right: 0 !important;
    }

    /* Mobile menu overlay */
    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        z-index: 999;
    }

    .mobile-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* Mobile navigation styles */
    .mobile-menu .header-flex-center {
        display: block !important;
        width: 100%;
        margin-bottom: 20px;
    }

    .mobile-menu nav {
        display: block !important;
    }

    .mobile-menu nav ul {
        list-style: none;
        padding: 0;
        margin: 0 0 30px 0;
        display: block !important;
    }

    .mobile-menu nav ul li {
        margin-bottom: 20px;
    }

    .mobile-menu nav ul li a {
        display: block;
        padding: 12px 15px;
        color: #333;
        text-decoration: none;
        font-size: 1.1rem;
        border-radius: 5px;
        transition: background-color 0.2s ease;
    }

    .mobile-menu nav ul li a:hover {
        background-color: #f0f0f0;
    }

    /* Mobile auth buttons */
    .mobile-menu .auth-buttons {
        display: flex !important;
        flex-direction: column;
        gap: 10px;
        border-top: 1px solid #e0e0e0;
        padding-top: 20px;
        width: 100%;
    }

    .mobile-menu .user-dropdown {
        width: 100%;
        margin-left: 0;
    }

    .mobile-menu .user-dropdown-toggle {
        display: none !important;
        /* Hide toggle on mobile, show items directly */
    }

    .mobile-menu .user-dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        width: 100%;
        box-shadow: none;
        border: none;
        background: transparent;
        padding: 0;
        display: block !important;
    }

    .mobile-menu .dropdown-header {
        padding: 0 0 10px 0;
        margin-bottom: 15px;
    }

    .mobile-menu .dropdown-item,
    .mobile-menu .login-btn,
    .mobile-menu .logout-item {
        width: 100%;
        padding: 12px 15px;
        text-align: center;
        border-radius: 8px;
        text-decoration: none;
        display: flex !important;
        align-items: center;
        justify-content: center;
        gap: 12px;
        border: none;
        cursor: pointer;
        font-size: 1rem;
        margin-bottom: 10px;
        background-color: #f8f8f8;
        color: #333;
    }

    .mobile-menu .dropdown-item:hover,
    .mobile-menu .logout-item:hover {
        background-color: #f0f0f0;
        transform: none;
    }

    .mobile-menu .logout-item {
        color: #d32f2f;
        background-color: #fff1f1;
        font-weight: 700;
        margin-top: 10px;
    }

    /* Redesign end */

    /* Hero overlay - full screen except header */
    .hero-overlay {
        position: fixed !important;
        top: 60px !important;
        /* Adjust based on your header height */
        left: 0 !important;
        width: 100% !important;
        height: calc(100vh - 60px) !important;
        /* Full height minus header */
        background: rgba(0, 0, 0, 0.3);
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
    }

    /* Fix hero section height and prevent scrolling */
    .hero-section {
        position: relative !important;
        height: calc(100vh - 60px) !important;
        min-height: calc(100vh - 60px) !important;
        max-height: calc(100vh - 60px) !important;
        overflow: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Allow normal scrolling on all pages - REMOVED the fixed locks */
    body.landing-page main,
    body.landing-page {
        position: relative !important;
        height: auto !important;
        overflow: visible !important;
        width: 100% !important;
    }

    /* Allow normal scrolling on other pages */
    body:not(.landing-page) {
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }

    /* If there's a main container, fix it too */
    .main-content {
        overflow: hidden !important;
    }

    /* ========== MOBILE MODAL STYLES ========== */

    /* Modal background - centered overlay */
    .auth-modal {
        display: none !important;
        padding: 20px !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .auth-modal.active {
        display: flex !important;
    }

    /* Modal container - centered card */
    .auth-modal .auth-container {
        position: relative !important;
        width: 90% !important;
        max-width: 400px !important;
        min-height: auto !important;
        border-radius: 15px !important;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3) !important;
        display: block !important;
        flex-direction: column !important;
        background: white !important;
        margin: 0 !important;
    }

    /* Hide the desktop overlay animation completely */
    .auth-modal .overlay-container,
    .auth-modal .overlay,
    .auth-modal .overlay-panel {
        display: none !important;
    }

    /* Reset all form containers */
    .auth-modal .form-container {
        position: relative !important;
        width: 100% !important;
        height: auto !important;
        transform: none !important;
        transition: none !important;
        opacity: 1 !important;
        padding: 30px 25px 20px !important;
        display: flex !important;
        flex-direction: column !important;
        left: 0 !important;
        top: 0 !important;
        max-height: 70vh !important;
        overflow-y: auto !important;
        z-index: 1 !important;
    }

    /* Show login by default, hide signup */
    .auth-modal .sign-in-container {
        display: flex !important;
        opacity: 1 !important;
        transform: translateX(0) !important;
    }

    .auth-modal .sign-up-container {
        display: none !important;
        opacity: 1 !important;
        transform: translateX(0) !important;
    }

    /* When switching to signup */
    .auth-modal .auth-container.right-panel-active .sign-in-container {
        display: none !important;
        opacity: 1 !important;
        transform: translateX(0) !important;
    }

    .auth-modal .auth-container.right-panel-active .sign-up-container {
        display: flex !important;
        opacity: 1 !important;
        transform: translateX(0) !important;
    }

    /* Form styling */
    .auth-modal .form-container form {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
    }

    .auth-modal .form-container h2 {
        margin-bottom: 20px !important;
        font-size: 1.5rem !important;
        text-align: center !important;
    }

    .auth-modal .form-container input {
        margin-bottom: 15px !important;
        padding: 12px !important;
        font-size: 1rem !important;
        width: 100% !important;
    }

    .auth-modal .form-container label {
        text-align: left !important;
        margin-bottom: 5px !important;
        font-size: 0.9rem !important;
        display: block !important;
    }

    .auth-modal .form-container button[type="submit"] {
        margin-top: 10px !important;
        padding: 12px !important;
        font-size: 1rem !important;
        width: 100% !important;
    }

    /* Close button - top right */
    .auth-modal .close-modal {
        position: absolute !important;
        top: 10px !important;
        right: 15px !important;
        z-index: 1000 !important;
        font-size: 1.8rem !important;
        color: #666 !important;
        cursor: pointer !important;
    }

    /* Mobile toggle section at bottom */
    .mobile-auth-toggle {
        width: 100% !important;
        padding: 15px 0 !important;
        text-align: center !important;
        border-top: 1px solid #e0e0e0 !important;
        margin-top: 10px !important;
        display: block !important;
    }

    .mobile-auth-toggle p {
        margin: 0 0 8px 0 !important;
        color: #666 !important;
        font-size: 0.85rem !important;
    }

    .mobile-auth-toggle button {
        background: transparent !important;
        border: none !important;
        color: #8b0000 !important;
        padding: 5px !important;
        cursor: pointer !important;
        font-size: 0.95rem !important;
        font-weight: 600 !important;
        text-decoration: underline !important;
        width: auto !important;
        margin-top: 0 !important;
    }

    .mobile-auth-toggle button:hover {
        background: transparent !important;
        transform: none !important;
        color: #5C0000 !important;
    }

    /* Verification container */
    .auth-modal .verify-container {
        display: none !important;
    }

    .auth-modal .auth-container.show-verify .verify-container {
        display: flex !important;
    }

    .auth-modal .auth-container.show-verify .sign-in-container,
    .auth-modal .auth-container.show-verify .sign-up-container {
        display: none !important;
    }

    /* Error and success messages */
    .auth-modal .error-msg,
    .auth-modal .success-msg {
        font-size: 0.85rem !important;
        margin-top: 10px !important;
        display: block !important;
    }

    /* GLOBAL OVERFLOW FIX */
    * {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    html,
    body {
        overflow-x: hidden !important;
        width: 100vw !important;
        position: relative;
    }

    /* HERO SECTION FIXES */
    .hero-section,
    .university-hero,
    .categories-hero {
        padding: 40px 15px !important;
        height: auto !important;
        min-height: auto !important;
        text-align: center !important;
    }

    .hero-content {
        padding: 0 !important;
        width: 100% !important;
    }

    .hero-title,
    .academic-title h1 {
        font-size: 2rem !important;
        line-height: 1.2 !important;
        margin-bottom: 15px !important;
    }

    .hero-subtitle,
    .categories-hero p {
        font-size: 1rem !important;
        line-height: 1.5 !important;
        margin-bottom: 25px !important;
    }

    /* SEARCH BAR FIXES */
    .hero-search-container,
    .hero-search,
    .search-container {
        width: 100% !important;
        padding: 0 !important;
        margin: 20px 0 !important;
    }

    .hero-search-form,
    .search-form,
    .search-input-group,
    .search-input-row {
        border-radius: 10px !important;
        flex-direction: column !important;
        padding: 10px !important;
        gap: 10px !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .search-input-group input,
    .search-input {
        width: 100% !important;
        border-radius: 8px !important;
        padding: 12px 15px !important;
        background: #f5f5f5 !important;
        margin: 0 !important;
    }

    .search-submit,
    .search-button {
        width: 100% !important;
        border-radius: 8px !important;
        padding: 12px !important;
        margin: 0 !important;
    }

    /* GRID FIXES */
    .thesis-grid,
    .department-grid,
    .department-bookmarks {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }

    .thesis-card,
    .department-card-v2,
    .cat-thesis-item {
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .thesis-card {
        grid-template-columns: 1fr !important;
        height: auto !important;
    }

    .thesis-cover {
        width: 100% !important;
        height: 140px !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border-color) !important;
    }

    /* SECTION HEADERS */
    .section-title {
        font-size: 1.8rem !important;
        text-align: center !important;
    }

    .section-header-flex {
        flex-direction: column !important;
        text-align: center !important;
        gap: 15px !important;
    }

    /* RECENTLY ADDED SECTION */
    .recently-added {
        padding: 40px 15px !important;
    }

    /* STATS FIX */
    .hero-stats {
        flex-direction: column !important;
        gap: 20px !important;
        margin-top: 30px !important;
    }

    .stat-divider {
        display: none !important;
    }

    /* FOOTER FIX */
    .footer-grid {
        grid-template-columns: 1fr !important;
        text-align: center !important;
        padding: 0 20px !important;
        gap: 40px !important;
    }

    .footer-brand-title {
        justify-content: center !important;
    }

    .footer-section {
        margin-right: 0 !important;
    }

    .footer-section h4::after {
        left: 50% !important;
        transform: translateX(-50%) !important;
    }

    .social-links {
        justify-content: center !important;
    }

    .contact-info p {
        justify-content: center !important;
        text-align: center !important;
    }


    /* HIDE BACKGROUND OVERLAPS */
    .hero::before,
    .hero::after,
    .categories-hero::before,
    .categories-hero::after {
        display: none !important;
    }

    /* STUDENT DASHBOARD FIXES */
    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }

    .sidebar {
        padding: 15px !important;
        width: 100% !important;
    }

    .nav-item {
        padding: 12px 15px !important;
        font-size: 0.9rem !important;
    }

    .form-row {
        grid-template-columns: 1fr !important;
        gap: 0 !important;
    }

    .main-content {
        padding: 20px !important;
    }

    /* ADMIN DASHBOARD FIXES */
    .admin-layout {
        flex-direction: column !important;
    }

    .admin-sidebar {
        width: 100% !important;
        height: auto !important;
        position: relative !important;
        max-height: 250px !important;
        overflow-y: auto !important;
        border-right: none !important;
        border-bottom: 2px solid var(--border-color) !important;
    }

    .admin-main {
        padding: 15px !important;
        width: 100% !important;
        overflow-x: hidden !important;
    }

    /* TABLE RESPONSIVENESS */
    table {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .dashboard-section>div {
        flex-direction: column !important;
    }

    .dashboard-section>div>div {
        width: 100% !important;
        flex: 1 1 100% !important;
    }

    /* FIX FOR CLIPPING ON SMALL SCREENS */
    .container,
    .categories-hero,
    .hero-content {
        padding-left: 15px !important;
        padding-right: 15px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
}

/* Desktop styles - hide hamburger on larger screens */
@media screen and (min-width: 769px) {

    .hamburger-menu,
    .mobile-menu,
    .mobile-overlay {
        display: none !important;
    }
}