/* ==========================================================================
   Mobile-specific styles - Breakpoint at 768px
   ========================================================================== */

/* -----------------------------
   Mobile Navigation Components
   ---------------------------- */

/* Hamburger Menu Button */
.hamburger-menu {
    display: none; /* Hidden by default, shown only on mobile */
    cursor: pointer;
    width: 24px;
    height: 20px;
    position: relative;
    margin-right: 1rem;
    background: none;
    border: none;
    padding: 0;
}

/* Hamburger Menu Lines */
.hamburger-menu span {
    display: block;
    position: absolute;
    height: 2px;
    width: 100%;
    background: var(--color-text-primary);
    transition: all 0.3s ease;
}

/* Position the three lines */
.hamburger-menu span:nth-child(1) { top: 0; }
.hamburger-menu span:nth-child(2) { top: 9px; }
.hamburger-menu span:nth-child(3) { top: 18px; }

/* Animated hamburger to X transformation */
.hamburger-menu.active span:nth-child(1) {
    transform: rotate(45deg);
    top: 9px;
}

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

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

/* -----------------------------
   Mobile Logo Handling
   ---------------------------- */

/* Desktop/Mobile Logo Toggle */
.desktop-logo { display: block; }
.mobile-logo { display: none; }

/* -----------------------------
   Mobile Navigation Menu
   ---------------------------- */

/* Full-screen mobile navigation */
.mobile-nav {
    display: none;
    position: fixed;
    top: 60px; /* Height of top bar */
    left: -100%;
    width: 100%;
    height: calc(100vh - 60px);
    background: var(--color-bg-primary);
    padding: 1rem;
    transition: left 0.3s ease;
    overflow-y: auto;
    z-index: 999;
}

/* Active state for mobile menu */
.mobile-nav.active {
    left: 0;
}

/* Mobile navigation links */
.mobile-nav-link {
    display: block;
    padding: 1rem;
    color: var(--color-text-primary);
    text-decoration: none;
    border-bottom: 1px solid var(--color-border);
    font-size: 1.1rem;
}

.mobile-nav-link:hover {
    background: var(--color-bg-secondary);
}

/* -----------------------------
   Responsive Breakpoints
   ---------------------------- */

@media (max-width: 768px) {
    /* Show hamburger menu */
    .hamburger-menu {
        display: block;
    }

    /* Hide desktop navigation */
    .desktop-nav {
        display: none;
    }

    /* Show mobile navigation */
    .mobile-nav {
        display: block;
    }

    /* Switch logos */
    .desktop-logo {
        display: none;
    }
    .mobile-logo {
        display: block;
    }

    /* Adjust search container width */
    .search-container {
        max-width: 200px;
    }

    /* Adjust top bar padding */
    .top-bar-container {
        padding: 0.5rem 1rem;
    }

    /* Prevent scrolling when menu is open */
    body.menu-open {
        overflow: hidden;
    }
}

/* -----------------------------
   Dark Mode Adjustments
   ---------------------------- */

/* Dark mode styles for mobile components */
body.dark-mode .mobile-nav {
    background: var(--color-bg-primary-dark);
    border-color: var(--color-border-dark);
}

body.dark-mode .hamburger-menu span {
    background: var(--color-text-primary-dark);
}

body.dark-mode .mobile-nav-link {
    color: var(--color-text-primary-dark);
    border-color: var(--color-border-dark);
}

body.dark-mode .mobile-nav-link:hover {
    background: var(--color-bg-secondary-dark);
}

/* -----------------------------
   Additional Mobile Optimizations
   ---------------------------- */

/* Improve touch targets on mobile */
@media (max-width: 768px) {
    .mobile-nav-link {
        padding: 1rem;
        margin: 0.5rem 0;
    }

    /* Adjust font sizes for better readability */
    .mobile-nav-link {
        font-size: 16px; /* Ensure readable text size */
    }

    /* Enhance tap targets */
    .search-input {
        height: 40px; /* Larger touch target */
        font-size: 16px; /* Prevent iOS zoom */
    }
}

/* -----------------------------
   Small Screen Optimizations
   ---------------------------- */

@media (max-width: 480px) {
    /* Further reduce search container width */
    .search-container {
        max-width: 150px;
    }

    /* Adjust padding for smaller screens */
    .top-bar-container {
        padding: 0.5rem;
    }

    /* Stack navigation items vertically */
    .mobile-nav-link {
        padding: 0.8rem;
    }
}

/* -----------------------------
   Mobile Sidebar Specific Styles
   ---------------------------- */

/* Hide desktop sidebar and show mobile sidebar on small screens */
.desktop-sidebar {
    display: block;
}

.mobile-sidebar {
    display: none;
}

/* Breadcrumb Container - Hidden by default for desktop */
.breadcrumb-container {
    display: none; /* Hidden by default */
}

@media (max-width: 768px) {
    .breadcrumb-container {
        display: flex; /* Show on mobile/tablet */
        width: 100%;
        padding: 0.75rem 2rem;
        background: var(--color-bg-primary);
        border-bottom: 1px solid var(--color-border);
        align-items: center;
        justify-content: space-between;
        position: sticky;
        top: 60px;
        z-index: 999;
    }

    .desktop-sidebar {
        display: none;
    }

    /* Base hamburger styles */
    .sidebar-hamburger {
        cursor: pointer;
        width: 24px;
        height: 20px;
        background: transparent;
        border: none;
        padding: 0;
        position: relative;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        outline: none;
    }

    .sidebar-hamburger:focus {
        outline: none;
        background: transparent;
        box-shadow: none;
    }

    .sidebar-hamburger span {
        display: block;
        position: absolute;
        height: 2px;
        width: 100%;
        background: #000;
        border-radius: 2px;
        transition: all 0.3s ease;
    }

    .sidebar-hamburger span:nth-child(1) { top: 0; }
    .sidebar-hamburger span:nth-child(2) { top: 9px; }
    .sidebar-hamburger span:nth-child(3) { top: 18px; }

    .sidebar-hamburger {
        display: block;
    }

    /* Show hamburger button on mobile */
    .sidebar-hamburger {
        display: block;
    }

    /* Mobile sidebar as overlay */
    .mobile-sidebar {
        position: fixed;
        top: calc(60px + 53px); /* Header height + breadcrumb height */
        left: -280px;
        width: 280px;
        height: calc(100vh - 60px - 53px); /* Viewport - header - breadcrumb */
        background: var(--color-bg-primary);
        z-index: 1000;
        overflow-y: auto;
        box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
        transition: left 0.3s ease;
        display: block !important;
    }

    /* Show mobile sidebar when active */
    .mobile-sidebar.active {
        left: 0;
    }

    /* Mobile sidebar navigation styles */
    .mobile-sidebar-navigation {
        padding: 1rem;
        height: 100%;
    }

    /* Main content adjustments */
    .main-content {
        margin-left: 0 !important;
        width: 100%;
        padding: 1.5rem;
        overflow-x: hidden;
    }

    /* Content responsiveness */
    .main-content img {
        max-width: 100%;
        height: auto;
    }

    .main-content pre {
        max-width: 100%;
        overflow-x: auto;
    }

    .main-content table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
    }

    /* Right nav adjustments */
    .right-nav {
        display: none;
    }

    /* Page container adjustments */
    .page-container {
        padding: 0;
        max-width: 100%;
        overflow-x: hidden;
    }
}

/* Additional responsive adjustments */
@media (max-width: 480px) {
    .main-content {
        padding: 1rem;
    }

    .breadcrumb-container {
        padding: 0.75rem 1rem;
    }
}

/* Dark mode adjustments */
@media (max-width: 768px) {
    body.dark-mode .breadcrumb-container {
        background: var(--color-bg-primary-dark);
        border-color: var(--color-border-dark);
    }

    body.dark-mode .mobile-sidebar {
        background: var(--color-bg-primary-dark);
        box-shadow: 2px 0 5px rgba(0, 0, 0, 0.3);
    }

    body.dark-mode .sidebar-hamburger span {
        background: #fff; /* White for dark mode */
    }
}

/* Dark mode hamburger color */
body.dark-mode .sidebar-hamburger span {
    background: #fff;
}

/* Hamburger button animation */
.sidebar-hamburger.active span:nth-child(1) {
    transform: rotate(45deg);
    top: 9px;
}

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

.sidebar-hamburger.active span:nth-child(3) {
    transform: rotate(-45deg);
    top: 9px;
}

/* Mobile Sidebar Navigation Styles */
.mobile-sidebar-navigation {
    padding: 1rem;
}

.mobile-sidebar-section {
    margin-bottom: 1.5rem;
}

.mobile-sidebar-section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.8rem;
    color: var(--color-text-primary);
}

.mobile-sidebar-section-items {
    list-style: none;
    padding-left: 0;
}

.mobile-sidebar-item {
    margin-bottom: 0.5rem;
}

.mobile-sidebar-item a {
    display: block;
    padding: 0.5rem 0;
    color: var(--color-text-primary);
    text-decoration: none;
    font-size: 0.95rem;
}

.mobile-sidebar-subsection {
    margin: 0.5rem 0;
}

.mobile-sidebar-subsection-title {
    display: block;
    padding: 0.5rem 0;
    color: var(--color-text-primary);
    font-weight: 500;
    text-decoration: none;
}

.mobile-sidebar-subsection-items {
    list-style: none;
    padding-left: 1rem;
}

.mobile-sidebar-subitem {
    margin: 0.3rem 0;
}

.mobile-sidebar-subitem a {
    padding: 0.3rem 0;
    font-size: 0.9rem;
}

/* Active states */
.mobile-sidebar-item.active > a,
.mobile-sidebar-subitem.active > a {
    color: var(--color-accent);
    font-weight: 500;
}

/* Dark mode adjustments */
body.dark-mode .mobile-sidebar {
    background: var(--color-bg-primary-dark);
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.3);
}

body.dark-mode .mobile-sidebar-section-title,
body.dark-mode .mobile-sidebar-item a,
body.dark-mode .mobile-sidebar-subsection-title,
body.dark-mode .mobile-sidebar-subitem a {
    color: var(--color-text-primary-dark);
}

body.dark-mode .mobile-sidebar-item.active > a,
body.dark-mode .mobile-sidebar-subitem.active > a {
    color: var(--color-accent-dark);
}