/* ==================== */
/* Mobile Navigation Drawer (Left-Side Variant) */
/* ==================== */

/* Hamburger button - only visible on mobile */
.mobile-nav-toggle {
    display: none; /* Hidden by default (desktop) */
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: none;
    border-radius: 0.25rem;
    background: var(--color-bg-white);
    cursor: pointer;
    outline: none;
    transition: background-color 150ms;
}

.mobile-nav-toggle:hover {
    background-color: var(--color-bg-light);
}

.mobile-nav-toggle svg {
    width: 1.25rem;
    height: 1.25rem;
    color: var(--color-icon-medium-oklch);
}

/* Show hamburger on mobile/tablet */
@media (max-width: 1199px) {
    .mobile-nav-toggle {
        display: flex;
    }
}

/* Overlay - same as offcanvas but for mobile nav */
.mobile-nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    justify-content: flex-start; /* Left-side drawer */
}

.mobile-nav-overlay.is-visible {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

.mobile-nav-overlay.is-closing {
    display: flex;
    animation: fadeOut 0.3s ease-out forwards;
}

/* Mobile sidebar drawer (slides from LEFT) */
.mobile-nav-sidebar {
    background: var(--color-bg-white);
    width: 18rem;
    max-width: 76vw;
    height: 100%;
    max-height: 100vh;
    box-shadow: 0.125rem 0 1rem rgba(0, 0, 0, 0.15); /* Right shadow */
    display: flex;
    flex-direction: column;
    transform: translateZ(0);
    will-change: transform;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-nav-sidebar .sidebar-header {
    justify-content: space-between;
    padding: 0 0.5rem 0 0.875rem;
}

.mobile-nav-sidebar .sidebar-header a {
    display: inline-flex;
    align-items: center;
    min-width: 0;
}

.mobile-nav-sidebar .sidebar-logo {
    height: 1.375rem;
    max-width: calc(100% - 3rem);
    object-fit: contain;
    object-position: left center;
}

.mobile-nav-close {
    flex: 0 0 auto;
}

.mobile-nav-close [data-lucide],
.mobile-nav-close svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* Slide-in from LEFT */
.mobile-nav-overlay.is-visible .mobile-nav-sidebar {
    animation: slideInFromLeft 0.3s ease-out;
}

.mobile-nav-overlay.is-closing .mobile-nav-sidebar {
    animation: slideOutToLeft 0.3s ease-out forwards;
}

@keyframes slideInFromLeft {
    from {
        transform: translateX(-100%) translateZ(0);
    }
    to {
        transform: translateX(0) translateZ(0);
    }
}

@keyframes slideOutToLeft {
    from {
        transform: translateX(0) translateZ(0);
    }
    to {
        transform: translateX(-100%) translateZ(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Prevent body scroll when mobile nav open */
body.mobile-nav-open {
    overflow: hidden;
}

/* ==================== */
/* Touch Optimization (tablet and below) */
/* ==================== */

@media (max-width: 1199px) {
    /* Sidebar partials inject their own .sidebar display rule after main.css. */
    .main-layout > .sidebar {
        display: none;
    }

    /* Ensure minimum 44px touch targets (iOS HIG recommendation) */
    .sidebar-link,
    button.sidebar-link {
        min-height: 2.75rem; /* 44px */
        padding: 0.625rem 0.75rem;
    }

    /* Larger tap area for hamburger */
    .mobile-nav-toggle {
        min-width: 2.75rem;
        min-height: 2.75rem;
    }

    /* Increase button sizes in mobile view */
    .btn {
        min-height: 2.75rem;
        padding: 0.625rem 1rem;
    }

    .btn-sm {
        min-height: 2.25rem; /* 36px - acceptable for secondary actions */
        padding: 0.375rem 0.75rem;
    }

    /* Table action buttons need adequate spacing */
    .btn-group {
        gap: 0.5rem;
    }

    /* Increase form input height for easier tapping */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="search"],
    input[type="tel"],
    input[type="url"],
    select {
        min-height: 2.75rem;
        padding: 0.625rem 0.75rem;
        font-size: 1rem; /* Prevent iOS zoom on focus */
    }

    /* Prevent double-tap zoom on buttons */
    button,
    .btn,
    a.btn {
        touch-action: manipulation;
    }
}
