/**
 * FIFO Mobile Responsive Optimizations
 * ====================================
 * This file contains all mobile-first responsive enhancements
 * for optimal display on smartphones and tablets
 */

/* ================================
   MOBILE FIRST APPROACH
   ================================ */

/* Extra Small Devices (phones, < 576px) */
@media (max-width: 575.98px) {
    :root {
        --font-size-base: 14px;
        --card-padding: 0.75rem;
        --spacing-xs: 0.5rem;
    }

    body {
        font-size: 14px;
    }

    /* Typography optimizations */
    h1 {
        font-size: 1.3rem;
        margin-bottom: 0.75rem;
    }

    h2 {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }

    h3 {
        font-size: 1rem;
    }

    h5 {
        font-size: 0.95rem;
    }

    h6 {
        font-size: 0.85rem;
    }

    p {
        margin-bottom: 0.75rem;
    }

    /* Button optimizations */
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
        border-radius: 0.25rem;
        min-height: 44px; /* Touch-friendly */
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .btn-sm {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
        min-height: 36px;
        min-width: 36px;
    }

    /* Form controls */
    .form-control,
    .form-select,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 0.75rem;
        min-height: 44px;
    }

    /* Cards */
    .card {
        margin-bottom: 1rem;
        border-radius: 0.25rem;
    }

    .card-body {
        padding: 0.75rem;
    }

    .card-header {
        padding: 0.75rem;
    }

    /* Tables */
    .table {
        font-size: 0.85rem;
        margin-bottom: 0;
    }

    .table thead th {
        padding: 0.5rem;
        font-size: 0.8rem;
        font-weight: 600;
        background-color: #f8f9fa;
        border-bottom: 2px solid #dee2e6;
        color: #000;
    }

    .table tbody td {
        padding: 0.5rem;
        vertical-align: middle;
        border-bottom: 1px solid #dee2e6;
    }

    .table tbody tr:hover {
        background-color: rgba(0, 0, 0, 0.02);
    }

    /* Hide less important columns on mobile */
    .d-none.d-md-table-cell,
    .d-none.d-lg-table-cell {
        display: none !important;
    }

    /* Badges */
    .badge {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
        border-radius: 0.25rem;
    }

    .badge-status {
        display: inline-block;
        white-space: nowrap;
    }

    /* Spacing */
    .mb-4 {
        margin-bottom: 1rem;
    }

    .mt-2 {
        margin-top: 0.5rem;
    }

    .p-3 {
        padding: 0.75rem;
    }

    /* Alerts */
    .alert {
        padding: 0.75rem;
        margin: 0 -0.5rem 1rem;
        border-radius: 0.25rem;
        font-size: 0.9rem;
    }

    /* Navigation */
    .navbar {
        padding: 0.5rem 0.5rem;
        flex-direction: column;
        gap: 10px;
    }

    .navbar-brand {
        font-size: 1rem;
        margin-bottom: 0;
    }

    /* Sidebar on mobile */
    .sidebar {
        width: 250px;
        padding-top: 1rem;
    }

    .sidebar .nav-link {
        font-size: 0.9rem;
        padding: 8px 12px;
        margin: 2px 6px;
    }

    .sidebar .nav-link i {
        margin-right: 8px;
        width: 16px;
    }

    /* Responsive grid */
    .row {
        --bs-gutter-x: 0.75rem;
        --bs-gutter-y: 0;
    }
}

/* Small Devices (landscape phones, 576px and up) */
@media (min-width: 576px) {
    .btn {
        min-height: 40px;
        min-width: 40px;
    }

    .table {
        font-size: 0.9rem;
    }

    .table thead th {
        font-size: 0.85rem;
        color: #000;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.2rem;
    }
}

/* Medium Devices (tablets, 768px and up) */
@media (min-width: 768px) {
    :root {
        --font-size-base: 15px;
    }

    body {
        font-size: 15px;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.4rem;
    }

    .table {
        font-size: 0.95rem;
    }

    .table thead th {
        font-size: 0.9rem;
        color: #000;
    }

    /* Show columns on tablet */
    .d-none.d-md-table-cell {
        display: table-cell !important;
    }

    .sidebar .nav-link {
        font-size: 0.95rem;
        padding: 10px 15px;
        margin: 3px 8px;
    }
}

/* Large Devices (desktops, 992px and up) */
@media (min-width: 992px) {
    body {
        font-size: 16px;
    }

    .btn {
        min-height: auto;
        min-width: auto;
    }

    /* Show all columns on desktop */
    .d-none.d-lg-table-cell {
        display: table-cell !important;
    }

    .table thead th {
        font-size: 0.95rem;
        padding: 0.75rem;
        color: #000;
    }

    .table tbody td {
        padding: 0.75rem;
    }
}

/* ================================
   TOUCH-FRIENDLY INTERACTIONS
   ================================ */

/* Larger tap targets on mobile */
@media (max-width: 767.98px) {
    a,
    button,
    input[type="button"],
    input[type="submit"],
    .nav-link,
    .list-group-item {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* Improve form usability */
    input:focus,
    textarea:focus,
    select:focus {
        outline: 2px solid #89f283;
        outline-offset: 2px;
    }
}

/* ================================
   CHART RESPONSIVENESS
   ================================ */

.chart-container {
    position: relative;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 10px;
}

.chart-container canvas {
    min-width: 100%;
    height: auto;
}

@media (max-width: 767.98px) {
    .chart-container {
        height: 250px;
        padding-bottom: 15px;
    }

    .chart-container canvas {
        min-width: 500px;
    }
}

/* ================================
   STAT CARDS MOBILE
   ================================ */

@media (max-width: 575.98px) {
    .stat-card {
        padding: 0.75rem;
    }

    .stat-card .card-body {
        padding: 0.75rem;
    }

    .stat-card h6 {
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .stat-card h2 {
        font-size: 1.5rem;
        font-weight: 700;
    }

    .stat-card i {
        font-size: 2rem !important;
    }
}

/* ================================
   SIDEBAR NAVIGATION
   ================================ */

@media (max-width: 767.98px) {
    .sidebar .submenu {
        padding-left: 0;
        margin-top: 5px;
    }

    .sidebar .submenu .nav-link {
        padding: 8px 15px;
        padding-left: 35px;
        font-size: 0.85rem;
        margin: 2px 8px;
    }

    .sidebar .nav-link.has-submenu {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-right: 10px;
    }
}

/* ================================
   ACCESSIBILITY & CONTRAST
   ================================ */

@media (prefers-contrast: more) {
    .stat-card {
        border-left-width: 6px;
    }

    .btn {
        border-width: 2px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ================================
   DARK MODE (optional)
   ================================ */

@media (prefers-color-scheme: dark) {
    .table thead {
        background-color: #2d3748;
        color: #e2e8f0;
    }

    .table tbody tr:hover {
        background-color: rgba(255, 255, 255, 0.05);
    }

    .alert {
        background-color: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
}

/* ================================
   LANDSCAPE MODE (iPhone)
   ================================ */

@media (max-height: 500px) {
    .sidebar {
        height: 100vh;
        overflow-y: auto;
    }

    .navbar {
        padding: 0.25rem 0.5rem;
    }

    .navbar-brand {
        font-size: 0.9rem;
    }

    .card {
        margin-bottom: 0.5rem;
    }

    .chart-container {
        height: 200px;
    }
}
