/* ==========================================================
   GLOBAL
   ========================================================== */

:root {
    --page-background: #f4f7fa;
    --card-background: #ffffff;
    --primary-text: #1d2939;
    --secondary-text: #667085;
    --border: #e4e7ec;
    --dark-button: #344054;
    --dark-button-hover: #1d2939;
    --pause-button: #b42318;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    background-color: var(--page-background);
}

body {
    color: var(--primary-text);
    font-family: Arial, Helvetica, sans-serif;
}

button {
    font-family: inherit;
}


/* ==========================================================
   PAGE
   ========================================================== */

.dashboard-page {
    width: 100%;
    max-width: 1700px;
    min-height: 100vh;
    margin: 0 auto;
    padding: 28px 32px 34px;
}

.dashboard-body {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.dashboard-grid {
    order: 1;
}

.timeline-card {
    order: 2;
}


/* ==========================================================
   HEADER
   ========================================================== */

.dashboard-header {
    display: flex;
    align-items: center;
    gap: 18px;
    padding-bottom: 22px;
}

.dashboard-logo {
    width: auto;
    height: 54px;
    max-width: 190px;
    object-fit: contain;
    flex-shrink: 0;
}

.dashboard-heading-copy {
    min-width: 0;
}

.dashboard-title {
    margin: 0;
    color: var(--primary-text);
    font-size: 27px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.4px;
}

.dashboard-subtitle {
    margin: 8px 0 0;
    color: var(--secondary-text);
    font-size: 14px;
    line-height: 1.45;
}


/* ==========================================================
   MAIN GRID
   ========================================================== */

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(340px, 1fr);
    gap: 22px;
    align-items: start;
    width: 100%;
}

.dashboard-card {
    min-width: 0;
    overflow: hidden;
    background-color: var(--card-background);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow:
        0 1px 2px rgba(16, 24, 40, 0.04),
        0 2px 8px rgba(16, 24, 40, 0.04);
}

.panel-header {
    padding: 18px 20px;
}

.map-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 12px;
}

.panel-title {
    margin: 0;
    color: #344054;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.3;
}

.panel-timestamp {
    margin-top: 4px;
    color: var(--secondary-text);
    font-size: 13px;
    line-height: 1.4;
}

.panel-description {
    margin: 12px 0 0;
    color: var(--secondary-text);
    font-size: 12px;
    line-height: 1.45;
}

.map-marker-note {
    flex-shrink: 0;
    margin-top: 1px;
    padding: 5px 8px;
    color: #475467;
    background-color: #f2f4f7;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
}


/* ==========================================================
   MAPS
   ========================================================== */

.dashboard-map {
    width: 100%;
    min-width: 0;
}

.dashboard-map > div {
    width: 100% !important;
}

.dashboard-map .js-plotly-plot {
    width: 100% !important;
}


/*
   Desktop map is visible by default.
   Mobile map is hidden by default.
*/

.desktop-map {
    display: block;
    height: 650px;
}

.mobile-map {
    display: none;
    height: 390px;
}


/* ==========================================================
   DESKTOP PM2.5 TABLE
   ========================================================== */

.pm25-table-container {
    width: 100%;
    max-height: 570px;
    padding: 0 16px 18px;
    overflow-x: auto;
    overflow-y: auto;
}

.pm25-table {
    width: 100%;
    min-width: 310px;
    border-collapse: collapse;
    background-color: #ffffff;
    font-size: 12px;
}

.pm25-table-header {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 12px 10px;
    color: #ffffff;
    background-color: #263238;
}

.metro-column {
    padding-left: 12px;
    text-align: left;
}

.number-column {
    text-align: center;
}

.pm25-unit {
    font-size: 10px;
    font-weight: 400;
}

.pm25-table-metro {
    padding: 11px 12px;
    color: #344054;
    font-weight: 500;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.pm25-table-value {
    padding: 11px 10px;
    font-weight: 700;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.pm25-table-monitors {
    padding: 11px 10px;
    color: #475467;
    text-align: center;
    border-bottom: 1px solid var(--border);
}


/* ==========================================================
   MOBILE PM2.5 CARDS
   ========================================================== */

.mobile-pm25 {
    display: none;
}

.pm25-mobile-container {
    padding: 0 12px 12px;
}

.mobile-metro-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 62px;
    margin-bottom: 8px;
    padding: 10px 10px 10px 12px;
    background-color: #ffffff;
    border: 1px solid var(--border);
    border-radius: 9px;
}

.mobile-metro-card:last-child {
    margin-bottom: 0;
}

.mobile-metro-copy {
    min-width: 0;
}

.mobile-metro-name {
    overflow: hidden;
    color: #344054;
    font-size: 13px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-monitor-count {
    margin-top: 3px;
    color: var(--secondary-text);
    font-size: 10px;
}

.mobile-pm25-badge {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 3px;
    flex-shrink: 0;
    min-width: 78px;
    padding: 8px 9px;
    border-radius: 7px;
}

.mobile-pm25-number {
    font-size: 16px;
    line-height: 1;
}

.mobile-pm25-unit {
    font-size: 8px;
    font-weight: 600;
}


/* ==========================================================
   TIMELINE
   ========================================================== */

.timeline-card {
    margin-top: 22px;
    padding: 18px 20px 28px;
    overflow: visible;
}

.timeline-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.timeline-heading {
    color: #475467;
    font-size: 12px;
    font-weight: 600;
}

.timeline-current-time {
    color: var(--secondary-text);
    font-size: 12px;
}

.timeline-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}

.timeline-button {
    min-height: 42px;
    padding: 10px 16px;
    border: none;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
}

.secondary-button {
    color: #344054;
    background-color: #f2f4f7;
    border: 1px solid #d0d5dd;
}

.secondary-button:hover {
    background-color: #e4e7ec;
}

.play-button {
    min-width: 94px;
    color: #ffffff;
    background-color: var(--dark-button);
}

.play-button:hover {
    background-color: var(--dark-button-hover);
}

.play-button.is-playing {
    background-color: var(--pause-button);
}

.timeline-slider-wrapper {
    min-width: 0;
    padding: 0 8px;
}


/* ==========================================================
   SLIDER
   ========================================================== */

#frame-slider {
    width: 100%;
}

#frame-slider .rc-slider-rail {
    height: 5px;
    background-color: #d0d5dd;
}

#frame-slider .rc-slider-track {
    background-color: transparent;
}

#frame-slider .rc-slider-handle {
    width: 18px;
    height: 18px;
    margin-top: -7px;
    border: 3px solid #344054;
    background-color: #ffffff;
    opacity: 1;
}

#frame-slider .rc-slider-handle:hover,
#frame-slider .rc-slider-handle:focus,
#frame-slider .rc-slider-handle:active {
    border-color: #1d2939;
    box-shadow: 0 0 0 4px rgba(52, 64, 84, 0.14);
}


/* ==========================================================
   SOURCE
   ========================================================== */

.dashboard-source-note {
    margin-top: 16px;
    color: var(--secondary-text);
    font-size: 11px;
    line-height: 1.5;
}


/* ==========================================================
   TABLET
   ========================================================== */

@media (max-width: 1100px) {
    .dashboard-page {
        padding: 22px;
    }

    .dashboard-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 18px;
    }

    .pm25-table-container {
        max-height: 450px;
    }
}


/* ==========================================================
   MOBILE
   ========================================================== */

@media (max-width: 700px) {
    .dashboard-page {
        width: 100%;
        padding:
            calc(12px + env(safe-area-inset-top))
            10px
            calc(22px + env(safe-area-inset-bottom));
    }


    /* Move timeline above the map */

    .timeline-card {
        order: 0;
    }

    .dashboard-grid {
        order: 1;
    }


    /* Header */

    .dashboard-header {
        align-items: flex-start;
        gap: 10px;
        padding: 2px 2px 12px;
    }

    .dashboard-logo {
        width: 40px;
        height: 40px;
        max-width: 40px;
    }

    .dashboard-title {
        font-size: 18px;
        line-height: 1.23;
        letter-spacing: -0.2px;
    }

    .dashboard-subtitle {
        margin-top: 4px;
        font-size: 11px;
        line-height: 1.35;
    }


    /* Cards */

    .dashboard-grid {
        gap: 12px;
    }

    .dashboard-card {
        border-radius: 10px;
        box-shadow:
            0 1px 3px rgba(16, 24, 40, 0.05);
    }

    .panel-header {
        padding: 13px 13px 10px;
    }

    .map-panel-header {
        align-items: flex-start;
        gap: 8px;
    }

    .panel-title {
        font-size: 15px;
    }

    .panel-timestamp {
        margin-top: 3px;
        font-size: 10px;
    }

    .panel-description {
        margin-top: 7px;
        font-size: 10px;
        line-height: 1.4;
    }

    .map-marker-note {
        display: none;
    }


    /* Use mobile map only */

    .desktop-map {
        display: none !important;
    }

    .mobile-map {
        display: block !important;
        width: 100% !important;
        height: 390px !important;
        min-height: 390px !important;
        visibility: visible !important;
    }

    .mobile-map .modebar {
        display: none !important;
    }


    /* Replace desktop table with cards */

    .desktop-pm25 {
        display: none;
    }

    .mobile-pm25 {
        display: block;
    }

    .pm25-card {
        max-height: none;
    }

    .pm25-mobile-container {
        max-height: 430px;
        padding: 0 9px 10px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }


    /* Timeline at top */

    .timeline-card {
        margin-top: 0;
        margin-bottom: 12px;
        padding: 12px 12px 18px;
    }

    .timeline-title-row {
        display: block;
        margin-bottom: 11px;
        text-align: center;
    }

    .timeline-heading {
        font-size: 9px;
        text-transform: uppercase;
        letter-spacing: 0.45px;
    }

    .timeline-current-time {
        margin-top: 4px;
        color: #344054;
        font-size: 13px;
        font-weight: 600;
    }

    .timeline-buttons {
        display: grid;
        grid-template-columns: 1fr 1.1fr 1fr;
        gap: 7px;
        margin-bottom: 15px;
    }

    .timeline-button {
        width: 100%;
        min-width: 0;
        min-height: 43px;
        padding: 8px 5px;
        font-size: 11px;
    }

    .timeline-slider-wrapper {
        padding: 0 7px;
    }

    #frame-slider {
        padding-bottom: 4px;
    }

    #frame-slider .rc-slider-mark {
        display: none;
    }

    #frame-slider .rc-slider-handle {
        width: 24px;
        height: 24px;
        margin-top: -10px;
    }


    /* Source */

    .dashboard-source-note {
        margin: 11px 3px 0;
        font-size: 9px;
        line-height: 1.4;
    }
}


/* ==========================================================
   VERY NARROW PHONES
   ========================================================== */

@media (max-width: 390px) {
    .dashboard-page {
        padding-right: 7px;
        padding-left: 7px;
    }

    .dashboard-logo {
        width: 36px;
        height: 36px;
        max-width: 36px;
    }

    .dashboard-title {
        font-size: 16px;
    }

    .dashboard-subtitle {
        font-size: 10px;
    }

    .mobile-map {
        height: 390px !important;
        min-height: 390px !important;
    }

    .mobile-metro-name {
        max-width: 175px;
        font-size: 12px;
    }

    .timeline-button {
        font-size: 10px;
    }
}