/* Responsive styles for Between The Lines */

/* Medium screens */
@media (max-width: 992px) {
    .controls {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .date-range {
        margin-top: 10px;
        width: 100%;
    }
    
    .modal-container {
        width: 90%;
        margin: 5% auto;
    }
}

/* Small screens */
@media (max-width: 768px) {
    body {
        margin: 0;
        font-size: 14px;
        overflow-x: hidden; /* Prevent horizontal scrolling */
    }
    
    .container {
        padding: 0;
        max-width: 100vw;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    /* Keep some padding for non-card content */
    .container > *:not(.analysis-cards-container):not(.table-container) {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    /* Searchable dropdown adjustments for mobile */
    .entity-filter-ribbon .searchable-dropdown-menu {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        max-height: 70vh;
        border-radius: 16px 16px 0 0;
        border: none;
        box-shadow: 0 -4px 16px rgba(0,0,0,0.2);
        transform: translateY(0);
        transition: transform 0.3s ease-out;
        animation: slideUp 0.3s ease-out;
    }
    
    .entity-filter-ribbon .searchable-dropdown-menu.closing {
        animation: slideDown 0.3s ease-out;
    }
    
    @keyframes slideUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }
    
    @keyframes slideDown {
        from {
            transform: translateY(0);
        }
        to {
            transform: translateY(100%);
        }
    }
    
    /* Drag handle for mobile bottom sheet */
    .entity-filter-ribbon .dropdown-drag-handle {
        display: flex !important; /* Override desktop hide */
        justify-content: center;
        padding: 20px 0 12px 0; /* Larger hit area */
        cursor: grab;
        touch-action: none;
        background: white;
        border-radius: 16px 16px 0 0;
        position: relative;
    }
    
    /* Invisible larger hit area */
    .entity-filter-ribbon .dropdown-drag-handle::before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 40px;
        cursor: grab;
    }
    
    .entity-filter-ribbon .dropdown-drag-handle:active {
        cursor: grabbing;
    }
    
    .entity-filter-ribbon .drag-handle-bar {
        width: 40px;
        height: 4px;
        background-color: #cbd5e0;
        border-radius: 2px;
    }
    
    .entity-filter-ribbon .dropdown-search {
        padding: 12px;
        background: white;
        border-bottom: 1px solid #e0e0e0;
        position: sticky;
        top: 0;
        z-index: 10;
    }
    
    .entity-filter-ribbon .dropdown-search-input {
        width: 100%;
        padding: 12px;
        font-size: 16px; /* Prevent zoom on iOS */
        border-radius: 8px;
    }
    
    .entity-filter-ribbon .dropdown-items {
        max-height: calc(70vh - 100px); /* Account for drag handle + search */
        padding: 8px 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        overscroll-behavior: contain; /* Prevent scroll chaining */
        position: relative;
    }
    
    /* Prevent body scroll when dropdown is open on mobile */
    body.dropdown-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }
    
    .entity-filter-ribbon .dropdown-item {
        padding: 14px 16px;
        font-size: 16px;
    }
    
    /* Add backdrop for mobile */
    .entity-filter-ribbon.open::before {
        content: "";
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9999;
        animation: fadeIn 0.3s ease-out;
    }
    
    @keyframes fadeIn {
        from {
            opacity: 0;
        }
        to {
            opacity: 1;
        }
    }
    
    /* Make trigger more touch-friendly on mobile */
    .entity-filter-ribbon .select-trigger {
        min-height: 36px;
        padding: 8px 10px;
        font-size: 14px;
    }
    
    .entity-filter-ribbon .filter-label {
        font-size: 12px;
    }
    
    .events-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .events-header h2 {
        margin-bottom: 0;
        font-size: 1.5rem;
    }
    
    .event-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .event-item img {
        margin-bottom: 10px;
        margin-right: 0;
        width: 100%;
        max-width: 300px;
        height: auto;
    }
    
    .event-item div {
        width: 100%;
    }
    
    .event-item div span:last-child {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        margin-top: 10px;
    }
    
    .tabs-container {
        margin: 12px 15px !important;
        border-radius: 25px !important;
        background: rgba(118, 118, 128, 0.12) !important;
        padding: 2px !important;
        position: relative;
        overflow: hidden !important;
        box-shadow: none !important;
        border: none !important;
    }

    /* Compact pill-style tabs on mobile - single row only */
    .tabs {
        display: flex;
        gap: 0;
        padding: 0;
        background: transparent !important;
        border-bottom: none !important;
        border-radius: 23px !important;
        overflow: hidden;
        position: relative;
    }
    
    /* Show only first 3 tabs on mobile */
    .tab-button:nth-child(n+4) {
        display: none;
    }
    
    .tab-button {
        flex: 1;
        text-align: center;
        border: none;
        border-radius: 0;
        padding: 12px 8px;
        font-size: 14px;
        font-weight: 500;
        background: transparent;
        color: #495057;
        margin: 0;
        transition: all 0.3s ease;
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-height: 44px;
        border-bottom: 2px solid transparent;
    }
    
    /* Remove the weird rounded pill styling */
    .tab-button:first-child {
        border-radius: 0;
    }
    
    .tab-button:last-child {
        border-radius: 0;
    }
    
    .tab-button:not(:last-child) {
        border-right: 1px solid rgba(0, 0, 0, 0.05);
    }
    
    .tab-button:hover:not(.active) {
        background: rgba(66, 133, 244, 0.08);
        color: #4285f4;
    }
    
    .tab-button.active {
        background: #4285f4 !important;
        color: white !important;
        font-weight: 600;
        border-bottom: 2px solid transparent !important;
        border-radius: 0 !important;
        margin: 0;
        box-shadow: none;
    }
    
    .modal-container {
        width: 95%;
        margin: 2% auto;
        padding: 15px;
        max-height: 95vh;
    }
    
    /* Improve form controls for mobile */
    .form-control, select, input {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 12px;
        min-height: 44px;
    }
    
    /* Improve button touch targets */
    .btn, button {
        min-height: 44px;
        padding: 12px 16px;
        font-size: 16px;
    }
    
    /* Make last refresh text smaller and less prominent */
    .text-muted {
        font-size: 11px !important;
        color: #9ca3af !important;
        line-height: 1.2;
        margin-top: 4px;
    }
    
    #lastRefreshTime {
        font-weight: normal !important;
    }
    
    /* Filters responsive - Fixed overflow issues */
    .filters-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px; /* Reduced from 15px */
        padding: 8px 6px; /* Reduced horizontal padding to prevent overflow */
        margin: 0 -0.75rem 10px -0.75rem; /* Reduced bottom margin */
        width: calc(100vw - 1.5rem); /* Full width minus container padding */
        max-width: calc(100vw - 1.5rem);
        box-sizing: border-box;
        overflow: hidden; /* Hide any overflow */
    }
    
    .filters-row .filter-group {
        display: flex;
        flex-wrap: nowrap; /* Don't wrap, keep on same row */
        gap: 8px; /* Reduced gap to prevent overflow */
        align-items: center;
        min-width: 0; /* Allow shrinking */
        width: 100%;
        justify-content: space-between; /* Distribute space evenly */
    }
    
    .filters-row .filter-item {
        flex: 1 1 0; /* Equal width for both items */
        min-width: 90px; /* Smaller minimum to prevent overflow */
        max-width: calc(50% - 8px); /* Account for padding and gaps */
        display: flex;
        flex-direction: row; /* Row layout for labels beside selectors */
        align-items: center;
        margin-bottom: 6px; /* Reduced from 10px */
        gap: 4px; /* Space between label and selector */
    }
    
    .filters-row .filter-label {
        font-size: 12px; /* Reduced from 13px */
        margin-bottom: 0; /* No bottom margin for row layout */
        display: block;
        width: auto; /* Auto width to fit content */
        min-width: fit-content;
        white-space: nowrap;
        font-weight: 500;
        color: #5f6368;
        flex-shrink: 0; /* Don't shrink */
    }
    
    /* Fix custom select dropdowns on mobile */
    .filters-row .custom-select {
        min-width: 80px;
        max-width: 120px;
        position: relative;
        flex: 1; /* Take remaining space */
    }
    
    .filters-row .custom-select select {
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
        padding-right: 30px; /* Make room for dropdown arrow */
    }
    
    /* Ensure dropdowns stay within viewport */
    .filter-group {
        max-width: 100%;
        overflow: visible;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    body {
        overflow-x: hidden; /* Force prevent horizontal scrolling */
    }
    
    /* Even more compact for small phones */
    .entity-filter-ribbon .select-trigger {
        min-height: 32px;
        padding: 6px 8px;
        font-size: 13px;
        min-width: 120px;
    }
    
    .entity-filter-ribbon .filter-label {
        font-size: 11px;
    }
    
    .entity-filter-ribbon .select-arrow {
        font-size: 18px;
    }
    
    .entity-filter-ribbon .dropdown-item {
        padding: 12px 14px;
        font-size: 15px;
    }
    
    .entity-filter-ribbon .dropdown-search-input {
        padding: 10px;
        font-size: 16px; /* Still 16px to prevent iOS zoom */
    }
    
    .container {
        padding: 0;
        max-width: 100vw;
        box-sizing: border-box;
    }
    
    /* Keep some padding for non-card content on very small screens */
    .container > *:not(.analysis-cards-container):not(.table-container) {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    .event-item div span:last-child {
        width: 100%;
    }
    
    .event-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .modal-title {
        font-size: 18px;
    }
    
    .modal-close {
        top: 10px;
        right: 10px;
    }
    
    /* Compact pills for very small screens */
    .tabs-container {
        margin: 10px 10px !important;
        padding: 2px !important;
        border-radius: 20px !important;
        background-color: #f1f3f5;
    }
    
    .tabs {
        border-radius: 18px !important;
        border-bottom: none !important;
        background-color: transparent !important;
    }
    
    .tab-button {
        padding: 10px 4px;
        font-size: 13px;
        min-height: 36px;
    }
    
    .tab-button:first-child {
        border-radius: 18px 0 0 18px;
    }
    
    .tab-button:last-child {
        border-radius: 0 18px 18px 0;
    }
    
    .tab-button.active {
        border-radius: 18px !important;
        background: #4285f4 !important;
        color: white !important;
    }
    
    /* Improved filters for very small screens */
    .filters-row {
        padding: 6px 4px; /* Reduced horizontal padding to prevent overflow */
        gap: 6px; /* Reduced from 8px */
        margin: 0 -0.5rem 8px -0.5rem; /* Reduced bottom margin */
        width: calc(100vw - 1rem); /* Adjust for smaller container padding */
        max-width: calc(100vw - 1rem);
        overflow: hidden; /* Hide overflow */
    }
    
    .filters-row .filter-item {
        min-width: 0; /* Remove minimum width constraint */
        flex: 1 1 0; /* Equal width for both items */
        max-width: calc(50% - 6px); /* Account for padding and gaps */
        margin-bottom: 4px; /* Reduced from 8px */
        gap: 2px; /* Smaller gap for very small screens */
    }
    
    /* Keep horizontal layout even on very small screens */
    .filters-row .filter-group {
        flex-direction: row; /* Keep horizontal */
        flex-wrap: nowrap; /* Don't wrap */
        align-items: center;
        width: 100%;
        gap: 6px; /* Smaller gap between items */
        justify-content: space-between;
    }
    
    /* Even smaller last refresh text on very small screens */
    .text-muted {
        font-size: 10px !important;
        color: #9ca3af !important;
        line-height: 1.1;
        margin-top: 2px;
    }
} 