/**
 * Mobile-Responsive CSS Utilities
 * Mobile-first approach with progressive enhancement
 */

/* ============================================================
   MOBILE-FIRST BASE STYLES (320px+)
   ============================================================ */

/* Touch-friendly minimum sizes */
:root {
    --touch-target-min: 44px;
    --mobile-padding: 1rem;
    --mobile-font-size: 14px;
    --mobile-line-height: 1.5;
}

/* Ensure all interactive elements are touch-friendly */
button,
a.btn,
input[type="submit"],
input[type="button"],
select,
.nav-item {
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
}

/* Mobile-optimized typography */
body {
    font-size: var(--mobile-font-size);
    line-height: var(--mobile-line-height);
}

/* Mobile spacing */
.mobile-padding {
    padding: var(--mobile-padding);
}

/* ============================================================
   MOBILE MENU & SIDEBAR
   ============================================================ */

/* Mobile menu toggle button */
.mobile-menu-toggle {
    display: block;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1000;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 0.75rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
}

@media (min-width: 768px) {
    .mobile-menu-toggle {
        display: none;
    }
}

/* Sidebar overlay backdrop */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 998;
    transition: opacity 0.3s ease-in-out;
}

.sidebar-overlay.active,
.sidebar-overlay.open {
    display: block;
}

@media (min-width: 1024px) {
    .sidebar-overlay {
        display: none !important;
    }
}

/* Ensure hamburger menu is always visible */
.mobile-menu-toggle,
.topbar-toggle-btn,
#sidebarToggle {
    display: flex !important;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

/* Mobile sidebar styles - tablets and mobile: sidebar toggles and pushes content (does not cover) */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 280px;
        max-width: 85vw;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
        z-index: 999;
        overflow-y: auto;
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 16px rgba(0,0,0,0.15);
    }

    .main-content {
        margin-left: 0 !important;
        padding-top: 4rem;
        transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* When sidebar is open, push main content right so sidebar does not cover the page */
    .sidebar.open ~ .main-content {
        margin-left: 280px !important;
    }

    .sidebar.open ~ .main-content .topbar {
        left: 280px;
    }
    
    .sidebar-overlay.active,
    .sidebar-overlay.open {
        display: block;
        opacity: 1;
    }
}

/* ============================================================
   RESPONSIVE TABLES
   ============================================================ */

/* Table wrapper for horizontal scroll */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.table-responsive table {
    min-width: 100%;
    width: max-content;
}

/* Card-based table layout for mobile */
@media (max-width: 767px) {
    .table-mobile-card {
        display: block;
    }

    .table-mobile-card thead {
        display: none;
    }

    .table-mobile-card tbody,
    .table-mobile-card tr,
    .table-mobile-card td {
        display: block;
        width: 100%;
    }

    .table-mobile-card tr {
        margin-bottom: 1rem;
        border: 1px solid #e5e7eb;
        border-radius: 0.5rem;
        padding: 1rem;
        background: white;
    }

    .table-mobile-card td {
        border: none;
        padding: 0.5rem 0;
        text-align: left;
    }

    .table-mobile-card td:before {
        content: attr(data-label) ": ";
        font-weight: 600;
        display: inline-block;
        min-width: 100px;
    }
}

/* ============================================================
   RESPONSIVE FORMS
   ============================================================ */

@media (max-width: 767px) {
    /* Stack form fields vertically */
    .form-grid {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    /* Full width inputs on mobile */
    .form-input,
    .form-select,
    .form-textarea {
        width: 100% !important;
    }

    /* Full width buttons on mobile */
    .form-submit,
    .btn-submit {
        width: 100%;
        margin-top: 1rem;
    }

    /* Stack form groups */
    .form-group-row {
        flex-direction: column;
    }
}

/* ============================================================
   RESPONSIVE MODALS
   ============================================================ */

@media (max-width: 767px) {
    .modal {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        margin: 0;
        border-radius: 0;
        padding: 1rem;
    }

    .modal-content {
        max-height: 100vh;
        overflow-y: auto;
    }

    .modal-header {
        position: sticky;
        top: 0;
        background: white;
        z-index: 10;
        padding-bottom: 1rem;
        border-bottom: 1px solid #e5e7eb;
    }
}

/* ============================================================
   RESPONSIVE GRIDS
   ============================================================ */

/* Responsive grid utilities */
.responsive-grid-1 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 768px) {
    .responsive-grid-1 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .responsive-grid-1 {
        grid-template-columns: repeat(3, 1fr);
    }
}

.responsive-grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 768px) {
    .responsive-grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================================
   RESPONSIVE NAVIGATION
   ============================================================ */

/* Mobile navigation menu */
.mobile-nav {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: white;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    max-height: 100vh;
    overflow-y: auto;
}

.mobile-nav.active {
    display: block;
}

@media (min-width: 768px) {
    .mobile-nav {
        display: none !important;
    }
}

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

@media (min-width: 768px) {
    .desktop-nav {
        display: flex;
    }
}

/* ============================================================
   RESPONSIVE TYPOGRAPHY
   ============================================================ */

/* Responsive heading sizes */
h1 {
    font-size: 1.5rem;
}

@media (min-width: 768px) {
    h1 {
        font-size: 2rem;
    }
}

@media (min-width: 1024px) {
    h1 {
        font-size: 2.5rem;
    }
}

h2 {
    font-size: 1.25rem;
}

@media (min-width: 768px) {
    h2 {
        font-size: 1.5rem;
    }
}

h3 {
    font-size: 1.125rem;
}

@media (min-width: 768px) {
    h3 {
        font-size: 1.25rem;
    }
}

/* ============================================================
   RESPONSIVE SPACING
   ============================================================ */

/* Mobile-optimized padding */
.mobile-container {
    padding: 1rem;
}

@media (min-width: 768px) {
    .mobile-container {
        padding: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .mobile-container {
        padding: 2rem;
    }
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */

/* Hide on mobile, show on desktop */
.hide-mobile {
    display: none;
}

@media (min-width: 768px) {
    .hide-mobile {
        display: block;
    }
}

/* Show on mobile, hide on desktop */
.show-mobile {
    display: block;
}

@media (min-width: 768px) {
    .show-mobile {
        display: none;
    }
}

/* Full width on mobile */
.full-mobile {
    width: 100%;
}

@media (min-width: 768px) {
    .full-mobile {
        width: auto;
    }
}

/* Stack on mobile */
.stack-mobile {
    flex-direction: column;
}

@media (min-width: 768px) {
    .stack-mobile {
        flex-direction: row;
    }
}

/* ============================================================
   HORIZONTAL SCROLL INDICATOR
   ============================================================ */

.table-responsive::after {
    content: '→';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    color: #6b7280;
    font-size: 1.5rem;
    pointer-events: none;
    opacity: 0.5;
}

@media (min-width: 768px) {
    .table-responsive::after {
        display: none;
    }
}



