/* Mobile-First Responsive Styles for Radio Monitor */

/* ============================================================================
   MOBILE NAVIGATION - Hamburger Menu
   ============================================================================ */

/* Mobile menu button (hidden on desktop) */
#mobile-menu-button {
    display: none;
}

/* Desktop navigation */
#desktop-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Mobile menu container */
#mobile-menu {
    display: none;
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 40;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
}

.dark #mobile-menu {
    background: #1f2937;
}

#mobile-menu.show {
    display: block;
}

#mobile-menu a,
#mobile-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.dark #mobile-menu a,
.dark #mobile-menu button {
    border-bottom-color: #374151;
    color: #e5e7eb;
}

#mobile-menu a:hover,
#mobile-menu button:hover {
    background-color: #f3f4f6;
}

.dark #mobile-menu a:hover,
.dark #mobile-menu button:hover {
    background-color: #374151;
}

/* Hide desktop nav on mobile, show hamburger */
@media (max-width: 768px) {
    #desktop-nav {
        display: none !important;
    }
    
    #mobile-menu-button {
        display: block;
    }
}

/* ============================================================================
   HEADER - Compact Layout
   ============================================================================ */

@media (max-width: 768px) {
    nav.container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    #navbar-logo {
        font-size: 1.125rem !important;
    }
    
    /* Header layout: logo | player | hamburger */
    #navbar-right {
        display: flex;
        align-items: center;
        gap: 0.75rem;
    }
    
    /* Player controls - compact */
    #player-controls {
        display: flex !important;
        gap: 0.25rem;
    }
    
    #player-controls button {
        width: 2rem !important;
        height: 2rem !important;
        font-size: 0.875rem;
    }
    
    #volume-popup {
        right: 0;
    }
}

/* ============================================================================
   DASHBOARD - Stats Blocks (4 in a row on mobile)
   ============================================================================ */

@media (max-width: 768px) {
    /* Force 4 columns even on mobile */
    #stats {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 0.5rem !important;
    }
    
    #stats > div {
        padding: 0.75rem 0.5rem !important;
    }
    
    /* Smaller text for mobile */
    #stats .text-sm {
        font-size: 0.625rem !important;
        line-height: 0.875rem !important;
        font-weight: 500;
    }
    
    #stats .text-3xl {
        font-size: 1.25rem !important;
        line-height: 1.5rem !important;
        margin-top: 0.25rem;
    }
    
    #stats .text-xs {
        font-size: 0.5rem !important;
        margin-top: 0.125rem !important;
    }
}

/* ============================================================================
   DETECTIONS TABLE - 2-Line Mobile Layout
   ============================================================================ */

/* Desktop table - show by default */
#detections table {
    display: table;
}

/* Mobile cards - hidden by default */
#detections-mobile {
    display: none;
}

@media (max-width: 768px) {
    /* Hide desktop table on mobile */
    #detections table {
        display: none !important;
    }
    
    /* Show mobile layout */
    #detections-mobile {
        display: block !important;
    }
    
    /* Detection cards */
    .detection-card {
        padding: 0.875rem 1rem;
        border-bottom: 1px solid #e5e7eb;
    }
    
    .dark .detection-card {
        border-bottom-color: #374151;
    }
    
    .detection-card:hover {
        background-color: #f9fafb;
    }
    
    .dark .detection-card:hover {
        background-color: #374151;
    }
    
    .detection-card:last-child {
        border-bottom: none;
    }
    
    /* Top line: timestamp + ad name */
    .detection-top {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        margin-bottom: 0.5rem;
        gap: 0.75rem;
    }
    
    .detection-time {
        font-size: 0.75rem;
        color: #6b7280;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    .dark .detection-time {
        color: #9ca3af;
    }
    
    .detection-ad {
        font-size: 0.875rem;
        font-weight: 600;
        color: #111827;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .dark .detection-ad {
        color: #f3f4f6;
    }
    
    /* Bottom line: campaign | agency | player */
    .detection-bottom {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        font-size: 0.75rem;
        color: #6b7280;
    }
    
    .dark .detection-bottom {
        color: #9ca3af;
    }
    
    .detection-bottom > span:not(.detection-witness) {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .detection-campaign {
        flex: 1;
        min-width: 0;
    }
    
    .detection-agency {
        flex: 1;
        min-width: 0;
    }
    
    .detection-witness {
        flex-shrink: 0;
    }
    
    /* Separator between campaign and agency */
    .detection-separator {
        color: #d1d5db;
        flex-shrink: 0;
    }
    
    .dark .detection-separator {
        color: #4b5563;
    }
    
    /* Audio player in mobile */
    .detection-witness audio {
        height: 28px !important;
        max-width: 140px !important;
    }
    
    /* Pagination adjustments */
    #detections .flex.items-center.justify-between {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.875rem 1rem !important;
    }
    
    #detections .text-sm {
        font-size: 0.75rem;
        text-align: center;
    }
}

/* ============================================================================
   GENERAL MOBILE ADJUSTMENTS
   ============================================================================ */

@media (max-width: 768px) {
    .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    h2.text-2xl {
        font-size: 1.5rem !important;
    }
    
    h3.text-xl {
        font-size: 1.125rem !important;
    }
}

/* ============================================================================
   DARK MODE
   ============================================================================ */

.dark {
    color-scheme: dark;
}

.dark body {
    background-color: #111827;
}

.dark #page-content {
    background-color: #111827;
}

.dark .min-h-screen {
    background-color: #111827 !important;
}
