body {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
}

#map {
    height: 100vh;
    width: 100vw;
    transition: width 0.3s ease;
}

/* Split screen layout when chart is visible */
body.chart-visible #map {
    width: 50vw;
}

#forecast-controls {
    position: absolute;
    top: 10px;
    left: 10px;
    background: transparent;
    padding: 8px 12px;
    z-index: 1001;
    font-family: Arial, sans-serif;
    min-width: 400px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    column-gap: 10px;
    row-gap: 2px;
}

/* Show forecast controls only when chart is visible */
body.chart-visible #forecast-controls {
    opacity: 1;
    pointer-events: auto;
}

#forecast-controls label {
    grid-column: 1;
    grid-row: 1;
    white-space: nowrap;
    font-weight: bold;
    color: #333;
    font-size: 13px;
}

#forecast-time {
    color: #0066cc;
    display: inline-block;
    min-width: 135px;
}

#forecast-slider {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    margin: 0;
    cursor: pointer;
}

#forecast-labels {
    grid-column: 2;
    grid-row: 2;
    position: relative;
    height: 16px;
    font-size: 9px;
    color: #666;
}

#forecast-labels span {
    position: absolute;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background-color 0.2s;
    transform: translateX(-50%);
    text-align: center;
}

/* Position each label based on its value (0-48 hours) */
#forecast-labels span:nth-child(1) { left: 0%; }      /* 0h */
#forecast-labels span:nth-child(2) { left: 6.25%; }   /* 3h */
#forecast-labels span:nth-child(3) { left: 12.5%; }   /* 6h */
#forecast-labels span:nth-child(4) { left: 18.75%; }  /* 9h */
#forecast-labels span:nth-child(5) { left: 25%; }     /* 12h */
#forecast-labels span:nth-child(6) { left: 37.5%; }   /* 18h */
#forecast-labels span:nth-child(7) { left: 50%; }     /* 24h */
#forecast-labels span:nth-child(8) { left: 75%; }     /* 36h */
#forecast-labels span:nth-child(9) { left: 100%; }    /* 48h */

#forecast-labels span:hover {
    background-color: rgba(0, 102, 204, 0.1);
    color: #0066cc;
}

#layer-control {
    position: fixed;
    top: 10px;
    left: 70px;
    background: rgba(255, 255, 255, 0.9);
    padding: 6px;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    z-index: 1000;
    font-family: Arial, sans-serif;
}

#layer-select {
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 13px;
    background: white;
    cursor: pointer;
}

#airport-search {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 1000;
    font-family: Arial, sans-serif;
    min-width: 280px;
    transition: right 0.3s ease;
}

/* Position airport search better in split screen mode */
body.chart-visible #airport-search {
    right: calc(50vw + 20px);
}

#airport-search label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #333;
}

#airport-input {
    width: 200px;
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    text-transform: uppercase;
    margin-right: 8px;
}

#search-button {
    padding: 6px 15px;
    background: #0066cc;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

#search-button:hover {
    background: #0052a3;
}

#search-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

#search-status {
    margin-top: 8px;
    font-size: 12px;
    min-height: 16px;
}

#search-status.success {
    color: #008000;
}

#search-status.error {
    color: #cc0000;
}

#search-status.searching {
    color: #0066cc;
}

#skewt-container {
    position: fixed;
    top: 0;
    right: 0;
    width: 50vw;
    height: 100vh;
    background: white;
    border-left: 2px solid #333;
    box-shadow: -4px 0 8px rgba(0,0,0,0.3);
    display: none;
    z-index: 1000;
    overflow: auto;
    transition: width 0.3s ease;
}

#skewt-chart {
    width: 100%;
    height: 100%;
    padding: 0;
    box-sizing: border-box;
}

/* Hide cursor only over the plot area */
#skewt-chart .xy {
    cursor: none !important;
}

#close-chart {
    position: absolute;
    top: 10px;
    right: 15px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ccc;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 16px;
    cursor: pointer;
    color: #666;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
}

#close-chart:hover {
    color: #000;
}

#airport-navigation {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 8px 15px;
    border-radius: 20px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 14px;
    z-index: 1002;
}

#prev-airport, #next-airport {
    background: #0066cc;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

#prev-airport:hover, #next-airport:hover {
    background: #0052a3;
}

#prev-airport:disabled, #next-airport:disabled {
    background: #ccc;
    cursor: not-allowed;
}

#airport-indicator {
    color: #333;
    font-weight: bold;
    min-width: 50px;
    text-align: center;
}

/* ========================================
   MOBILE RESPONSIVE STYLES
   ======================================== */

/* Mobile Layout - Stack chart below map instead of side-by-side */
@media (max-width: 768px) {
    /* Mobile split-screen: map on top, chart on bottom */
    body.chart-visible #map {
        width: 100vw;
        height: 50vh;
        transition: height 0.3s ease;
    }
    
    #skewt-container {
        position: fixed;
        top: 50vh;
        left: 0;
        width: 100vw;
        height: 50vh;
        border-left: none;
        border-top: 2px solid #333;
        box-shadow: 0 -4px 8px rgba(0,0,0,0.3);
        transition: height 0.3s ease, top 0.3s ease;
    }
    
    /* Collapsed chart state - minimal height, more map visibility */
    body.chart-collapsed #map {
        width: 100vw;
        height: 85vh;
    }
    
    body.chart-collapsed #skewt-container {
        top: 85vh;
        height: 15vh;
    }
    
    /* Hide map controls on mobile to save space and reduce clutter */
    #layer-control {
        display: none;
    }
    
    /* Hide Leaflet zoom controls on mobile */
    .leaflet-control-zoom {
        display: none !important;
    }
    
    /* Reposition airport search to not overlap on mobile */
    #airport-search {
        top: 60px; /* Move down to avoid dynamic island */
        right: 10px;
        left: 10px; /* Full width */
        min-width: auto;
        padding: 10px 15px;
        display: flex;
        align-items: center;
        gap: 8px;
    }
    
    /* Keep airport search positioned properly in chart mode */
    body.chart-visible #airport-search {
        right: 10px;
        left: 10px; /* Maintain full width in chart mode */
    }
    
    /* Forecast controls positioning for mobile */
    #forecast-controls {
        top: 5px;
        left: 5px;
        min-width: 240px;
        padding: 6px 10px;
    }
    
    /* Hide label on mobile to save vertical space */
    #airport-search label {
        display: none;
    }
    
    /* Airport input should flex to take available space on mobile */
    #airport-input {
        flex: 1;
        width: auto;
        margin-right: 0; /* Remove default margin since we're using gap */
    }
    
    /* Search button should maintain its size */
    #search-button {
        flex-shrink: 0;
    }
    
    /* Close button positioning for mobile */
    #close-chart {
        top: 5px;
        right: 5px;
    }
    
    /* Hide airport navigation controls on mobile - use swipe instead */
    #airport-navigation {
        display: none;
    }
    
    /* Add swipe indicator for mobile when multiple airports are available */
    .mobile-swipe-hint {
        position: fixed;
        bottom: 10px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0, 0, 0, 0.7);
        color: white;
        padding: 6px 12px;
        border-radius: 16px;
        font-size: 12px;
        z-index: 1002;
        opacity: 0;
        transition: opacity 0.3s ease;
        pointer-events: none;
    }
    
    .mobile-swipe-hint.visible {
        opacity: 1;
    }
}

/* Larger touch targets for mobile devices */
@media (max-width: 768px) {
    /* Increase button sizes for better touch interaction */
    button {
        min-height: 44px;
        padding: 8px 16px;
        font-size: 14px;
    }
    
    /* Larger input fields */
    input[type="text"], select {
        min-height: 44px;
        padding: 8px 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Larger close button */
    #close-chart {
        width: 44px;
        height: 44px;
        font-size: 20px;
        line-height: 44px;
    }
    
    /* Forecast slider improvements */
    #forecast-slider {
        height: 6px;
    }
    
    #forecast-slider::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }
    
    #forecast-slider::-moz-range-thumb {
        width: 24px;
        height: 24px;
    }
    
    /* Better spacing for forecast labels */
    #forecast-labels {
        margin-top: 8px;
    }
    
    #forecast-labels span {
        font-size: 11px;
        padding: 2px;
    }
}

/* Small mobile devices (phones in portrait) */
@media (max-width: 480px) {
    #airport-search {
        padding: 8px 12px;
    }
    
    #airport-input {
        width: calc(100% - 80px); /* Account for button width */
        font-size: 14px;
    }
    
    #forecast-controls {
        min-width: 200px;
    }
    
    /* Smaller layer control select */
    #layer-select {
        font-size: 12px;
        padding: 4px 8px;
    }
    
    /* Adjust airport search placeholder */
    #airport-input::placeholder {
        font-size: 12px;
    }
}

/* Tablet landscape - maintain desktop-like experience */
@media (min-width: 769px) and (max-width: 1024px) {
    /* Keep side-by-side layout but adjust proportions */
    body.chart-visible #map {
        width: 55vw;
    }
    
    #skewt-container {
        width: 45vw;
    }
    
    body.chart-visible #airport-search {
        right: calc(45vw + 15px);
    }
}

/* Touch-specific improvements for all mobile devices */
@media (hover: none) and (pointer: coarse) {
    /* Better touch scrolling */
    * {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Remove hover effects on touch devices */
    button:hover {
        background-color: initial;
    }
    
    /* Better tap highlighting */
    button, input, select {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
    
    /* Ensure map is touch-friendly */
    #map {
        touch-action: manipulation;
    }
}

/* ========================================
   CONVECTIVE POTENTIAL BADGE & PANEL
   ======================================== */

#convective-potential-badge {
    position: absolute;
    top: 50px;
    right: 15px;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    color: white;
    min-width: 110px;
    text-align: center;
    transition: filter 0.15s ease;
}

#convective-potential-badge:hover {
    filter: brightness(0.9);
}

#convective-potential-badge .cp-label {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    opacity: 0.9;
}

#convective-potential-badge .cp-level {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

#convective-potential-panel {
    position: absolute;
    top: 108px;
    right: 15px;
    z-index: 1002;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    padding: 14px 16px;
    width: 260px;
    font-size: 12px;
    border: 1px solid #e0e0e0;
}

.cp-panel-title {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 10px;
}

.cp-reason {
    margin-bottom: 0;
    border-bottom: 1px solid #f0f0f0;
}

.cp-reason:last-of-type {
    border-bottom: none;
}

/* <details> reset */
.cp-reason summary {
    list-style: none;
}
.cp-reason summary::-webkit-details-marker {
    display: none;
}

.cp-reason-summary {
    cursor: pointer;
    padding: 7px 0;
    position: relative;
    padding-right: 18px;
}

/* Expand chevron */
.cp-reason-summary::after {
    content: '▸';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: #aaa;
    transition: transform 0.15s ease;
}

.cp-reason[open] > .cp-reason-summary::after {
    transform: translateY(-50%) rotate(90deg);
}

.cp-reason-summary:hover .cp-reason-factor {
    color: #0066cc;
}

.cp-reason-header {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    margin-bottom: 2px;
}

.cp-reason-factor {
    color: #333;
    transition: color 0.15s;
}

.cp-reason-value {
    color: #555;
}

.cp-reason-note {
    color: #666;
    font-size: 11px;
    line-height: 1.4;
}

.cp-reason-detail {
    padding: 6px 0 10px 0;
    border-top: 1px dashed #eee;
    margin-top: 2px;
}

.cp-reason-detail p {
    margin: 0 0 6px 0;
    font-size: 11px;
    color: #444;
    line-height: 1.5;
}

.cp-reason-detail p:last-child {
    margin-bottom: 0;
}

.cp-thresholds {
    color: #666 !important;
    font-style: italic;
}

.cp-disclaimer {
    margin-top: 10px;
    font-size: 10px;
    color: #999;
    line-height: 1.4;
    font-style: italic;
}

@media (max-width: 768px) {
    #convective-potential-badge {
        top: 44px;
        right: 10px;
        min-width: 90px;
        padding: 5px 10px;
    }

    #convective-potential-badge .cp-level {
        font-size: 14px;
    }

    #convective-potential-panel {
        top: 98px;
        right: 10px;
        width: calc(100vw - 20px);
        max-width: 320px;
    }
}

/* Safari UI auto-hide encouragement */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari specific styles */
    body {
        /* Fill viewport to encourage Safari UI auto-hide */
        min-height: 100vh;
        min-height: -webkit-fill-available;
    }
    
    /* Adjust for dynamic viewport on iOS */
    #map {
        height: 100vh;
        height: -webkit-fill-available;
    }
    
    /* Ensure full screen usage */
    body.chart-visible #map {
        height: 50vh;
        height: calc(-webkit-fill-available * 0.5);
    }
    
    #skewt-container {
        height: 50vh;
        height: calc(-webkit-fill-available * 0.5);
    }
    
    /* iOS Safari collapsed chart state */
    body.chart-collapsed #map {
        height: 85vh;
        height: calc(-webkit-fill-available * 0.85);
    }
    
    body.chart-collapsed #skewt-container {
        height: 15vh;
        height: calc(-webkit-fill-available * 0.15);
    }
}


