/* ==========================================
   Responsive Design Styles
   Mobile-first approach with breakpoints
   ========================================== */

/* ==========================================
   Global Responsive Foundations
   ========================================== */

html, body {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

img, video, iframe {
    max-width: 100%;
    height: auto;
}

/* ==========================================
   Mobile Menu Toggle
   ========================================== */

.mobile-menu-btn {
    display: none;
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    color: white;
}

.mobile-nav {
    display: none;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem 0;
}

.mobile-nav.active {
    display: flex;
}

@media (max-width: 767px) {
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ==========================================
   Extra Small Devices (xs) - < 640px
   ========================================== */

@media (max-width: 639px) {
    .hidden-xs {
        display: none !important;
    }

    main,
    header {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    #bar-chart-container,
    #line-chart-container {
        min-height: 220px !important;
    }

    .tabs-container {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.375rem;
    }

    .flex-wrap {
        flex-wrap: wrap;
    }

    /* Removed global .gap-6/.gap-8, button, h1-h3 overrides —
       these were breaking Tailwind responsive classes on
       navigation tabs, header buttons, grids, and headings. */

    /* Only force 1-col on non-Tailwind grids (Tailwind handles its own breakpoints) */
    .tabs-container.grid-cols-2 {
        grid-template-columns: 1fr;
    }

    .chart-bar {
        gap: 3px !important;
    }

    .bar-label, .bar-value {
        font-size: 9px;
    }

    .notification {
        top: 0.5rem;
        right: 0.5rem;
        left: 0.5rem;
        padding: 0.625rem 0.75rem;
        font-size: 0.8125rem;
    }

    p {
        hyphens: auto;
        word-break: break-word;
    }

    table {
        font-size: 0.8125rem;
    }

    table th, table td {
        padding: 0.5rem 0.375rem;
    }

    /* Admin filter bar mobile */
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .filter-bar .flex-1 {
        display: none;
    }

    .filter-bar select {
        width: 100% !important;
    }

    /* Admin stat boxes mobile */
    .stat-box {
        padding: 1rem 0.75rem;
    }

    /* Admin card compact */
    .admin-card-body {
        padding: 0.875rem 1rem;
    }

    .admin-card-header {
        padding: 0.875rem 1rem;
    }

    /* Section dividers */
    .section-divider {
        margin: 1.25rem 0 0.75rem;
    }

    .section-divider span {
        font-size: 11px;
        letter-spacing: 1px;
    }
}

/* ==========================================
   Small Devices (sm) - 640px to 767px
   ========================================== */

@media (min-width: 640px) and (max-width: 767px) {
    .hidden-sm {
        display: none !important;
    }

    main {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }
}

/* ==========================================
   Medium Devices (md) - 768px to 1023px
   ========================================== */

@media (min-width: 768px) {
    .hidden-md {
        display: none !important;
    }

    #bar-chart-container,
    #line-chart-container {
        min-height: 300px !important;
    }

    .grid-cols-1.md\:grid-cols-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .grid-cols-1.md\:grid-cols-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .lg\:flex-row {
        flex-direction: row;
    }

    .tabs-container {
        display: flex;
        grid-template-columns: unset;
    }
}

/* ==========================================
   Large Devices (lg) - 1024px to 1279px
   ========================================== */

@media (min-width: 1024px) {
    .hidden-lg {
        display: none !important;
    }

    .grid-cols-1.lg\:grid-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    main {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* ==========================================
   Extra Large Devices (xl) - 1280px and up
   ========================================== */

@media (min-width: 1280px) {
    .hidden-xl {
        display: none !important;
    }

    main {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* ==========================================
   Portrait Orientation
   ========================================== */

@media (orientation: portrait) {
    .landscape-only {
        display: none !important;
    }
}

/* ==========================================
   Landscape Orientation
   ========================================== */

@media (orientation: landscape) and (max-height: 500px) {
    header {
        padding: 0.5rem;
    }

    main {
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }

    .chart-container {
        height: 200px;
    }
}

/* ==========================================
   High Resolution Displays
   ========================================== */

@media (min-resolution: 2dppx) {
    * {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* ==========================================
   Dark Mode Support
   ========================================== */

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
    }

    body {
        background-color: #111827;
        color: #f3f4f6;
    }

    .bg-white {
        background-color: #1f2937;
        color: #f3f4f6;
    }

    .text-gray-900 {
        color: #f3f4f6;
    }

    .text-gray-600 {
        color: #d1d5db;
    }

    .bg-gray-50,
    .bg-gray-100 {
        background-color: #374151;
    }

    .border {
        border-color: #4b5563;
    }
}

/* ==========================================
   Reduced Motion
   ========================================== */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ==========================================
   High Contrast Mode
   ========================================== */

@media (prefers-contrast: more) {
    body {
        font-weight: 600;
    }

    button {
        border: 2px solid currentColor;
    }

    a {
        text-decoration: underline;
    }
}

/* ==========================================
   Touch Device Optimizations
   ========================================== */

@media (hover: none) and (pointer: coarse) {
    button,
    .btn,
    [role="tab"] {
        min-height: 44px;
    }

    .card-hover:active {
        transform: translateY(-2px);
    }

    .tab-inactive:active {
        background: #d1d5db !important;
    }
}

/* ==========================================
   High DPI Displays
   ========================================== */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* ==========================================
   Responsive Text Sizing
   ========================================== */

@media (max-width: 640px) {
    .text-xs {
        font-size: 0.7rem;
    }

    .text-sm {
        font-size: 0.875rem;
    }

    .text-base {
        font-size: 1rem;
    }

    .text-lg {
        font-size: 1.125rem;
    }
}

/* ==========================================
   Responsive Padding & Margins
   ========================================== */

@media (max-width: 640px) {
    .p-6, .p-8 {
        padding: 1rem !important;
    }

    .px-6, .px-8 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .py-6, .py-8 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }

    .gap-6, .gap-8 {
        gap: 1rem !important;
    }

    .space-y-6 > * + *,
    .space-y-8 > * + * {
        margin-top: 1rem !important;
    }
}

/* ==========================================
   Responsive Grid
   ========================================== */

@media (max-width: 640px) {
    .grid-cols-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .grid-cols-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (min-width: 641px) and (max-width: 1023px) {
    .grid-cols-4 {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
}

/* ==========================================
   Responsive Images
   ========================================== */

img {
    max-width: 100%;
    height: auto;
    display: block;
}

@media (max-width: 640px) {
    .w-28 {
        width: 5rem !important;
    }

    .h-25 {
        height: 5rem !important;
    }
}
