
/* =====================================================
   WSSDATALA - HOMEPAGE
   Mengikuti desain terbaru Detail Stasiun
   Desktop: 4 kolom | Tablet: 2 kolom | HP: 1 kolom
===================================================== */

* {
    box-sizing: border-box;
}

:root {
    --primary: #233f6b;
    --primary-dark: #152c4d;
    --primary-light: #365a8f;
    --background: #d2e3fc;
    --card: #ffffff;
    --text: #26364d;
    --muted: #718096;
    --border: #e2e8f0;
}

html {
    width: 100%;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

body {
    font-family: "Inter", Arial, sans-serif;
    background: var(--background);
    color: var(--text);
    margin: 0;
    padding: 20px;
    min-width: 320px;
    overflow-x: hidden;
    line-height: 1.5;
}

h1 {
    text-align: center;
    margin: 0 0 10px;
    color: var(--primary-dark);
}

.leaflet-marker-icon {
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
}

/* =====================================================
   HEADER UTAMA
===================================================== */

.main-header {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto 24px;
    padding: 22px 26px 16px;
    color: white;
    background: linear-gradient(
        135deg,
        #365a8f,
        #152c4d
    );
    border-radius: 16px;
    box-shadow: 0 5px 16px rgba(0,0,0,0.16);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.brand-icon {
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 30px;
    background: rgba(255,255,255,0.13);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 14px;
}

.brand-text {
    min-width: 0;
}

.brand-text h1 {
    margin: 0;
    color: white;
    text-align: left;
    font-size: clamp(20px, 2.5vw, 29px);
    line-height: 1.3;
}

.brand-text p {
    margin: 5px 0 0;
    color: #d0e6ff;
    font-size: 12px;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 9px;
    color: #d0e6ff;
    font-size: 12px;
    white-space: nowrap;
}

.live-indicator {
    width: 9px;
    height: 9px;
    background: #39df91;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(57,223,145,0.8);
}

/* =====================================================
   UPDATE TIME
===================================================== */

.toolbar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin: 18px 0 0;
    padding-top: 13px;
    border-top: 1px solid rgba(255,255,255,0.15);
    flex-wrap: wrap;
}

#lastUpdate {
    color: #d0e6ff;
    font-size: 12px;
}

#updateTime {
    color: white;
    font-weight: 700;
}

/* =====================================================
   DASHBOARD HEADING
===================================================== */

.dashboard-main {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
}

.dashboard-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.dashboard-heading h2 {
    margin: 0;
    color: #203b66;
    font-size: 21px;
}

.dashboard-heading p {
    margin: 5px 0 0;
    color: #64748b;
    font-size: 13px;
}

/* =====================================================
   GRID STASIUN
===================================================== */

.grid-container {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    align-items: stretch;
}

/* =====================================================
   KARTU STASIUN
===================================================== */

.station-card {
    position: relative;
    min-width: 0;
    min-height: 300px;
    padding: 16px;
    background: linear-gradient(
        135deg,
        #365a8f,
        #203d68
    );
    color: white;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.22);
    overflow: hidden;
    opacity: 0;
    transform: translateY(10px);
    animation: fadeInUp 0.5s ease forwards;
    transition: box-shadow 0.2s ease, background 0.2s ease;
}

.station-card:nth-child(odd) {
    animation-delay: 0.08s;
}

.station-card:nth-child(even) {
    animation-delay: 0.16s;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.station-card:hover {
    background: #10284a;
    box-shadow: 0 8px 20px rgba(0,0,0,0.22);
}

.station-card small {
    color: #d0e6ff;
}

/* =====================================================
   HEADER KARTU
===================================================== */

.station-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.station-header h2 {
    margin: 0;
    font-size: 17px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

/* =====================================================
   STATUS STASIUN
===================================================== */

.status {
    display: inline-block;
    padding: 6px 11px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.4;
    white-space: nowrap;
}

.status.online {
    color: #166534;
    background: #dcfce7;
}

.status.offline {
    color: #991b1b;
    background: #fee2e2;
}

.status.stale {
    color: #92400e;
    background: #fef3c7;
}

.status.api-error {
    color: white;
    background: #b91c1c;
}

/* =====================================================
   RINGKASAN PARAMETER CUACA
===================================================== */

.station-summary {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: stretch;
    gap: 10px;
    width: 100%;
}

.summary-item {
    min-width: 0;
    flex: 1 1 45%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 7px;
    text-align: center;
    border-radius: 10px;
    background: rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.13);
    overflow-wrap: anywhere;
}

.summary-item .icon {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    object-fit: contain;
    background: transparent;
    mix-blend-mode: normal;
    opacity: 1;
    user-select: none;
    pointer-events: none;
}

.summary-item h3 {
    margin: 0 0 5px;
    color: #e1edff;
    font-size: 12px;
    font-weight: 600;
    opacity: 0.9;
}

.summary-item p {
    margin: 0;
    font-size: clamp(16px, 1.5vw, 21px);
    font-weight: 800;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

/* Warna parameter */

.summary-item:nth-child(1) p {
    color: #f1c40f;
}

.summary-item:nth-child(2) p {
    color: #aadafa;
}

.summary-item:nth-child(3) p {
    color: #b8fff1;
}

.summary-item:nth-child(4) p {
    color: #d3b1e0;
}

.summary-item:nth-child(5) p {
    color: #a3ced1;
}

/* =====================================================
   KARTU PETA
   Posisi desktop: kolom 4 baris 2
===================================================== */

.grid-container > .map-card {
    grid-column: 4;
    grid-row: 2;
    min-width: 0;
    min-height: auto;
    padding: 13px;
    background: white;
    color: var(--text);
    border-radius: 15px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    overflow: hidden;
}

.grid-container > .map-card:hover {
    background: white;
}

.map-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.map-card-header h2 {
    margin: 0;
    color: var(--primary);
    font-size: 16px;
}

.map-card-header p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 11px;
}

.map-label {
    display: inline-block;
    padding: 5px 9px;
    color: #166534;
    background: #dcfce7;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.5px;
}

/* Mendukung ID map homepage dan miniMap lama */

#map,
#miniMap,
.map-container {
    display: block;
    width: 100%;
    height: 300px;
    min-height: 250px;
    border-radius: 10px;
    overflow: hidden;
    background: #1e2a38;
    z-index: 1;
}

/* =====================================================
   PERINGATAN HUJAN
===================================================== */

.alert-hujan {
    border: 5px solid red !important;
    box-shadow: 0 0 15px rgba(255,0,0,0.7) !important;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.65;
    }
}

/* =====================================================
   PESAN OFFLINE
===================================================== */

.offline-msg {
    padding: 12px;
    margin-top: 10px;
    border-radius: 8px;
    background: #fef2f2;
    color: #991b1b;
    text-align: center;
}

.stale-msg {
    padding: 10px;
    margin-top: 10px;
    border-radius: 8px;
    background: #fffbeb;
    color: #92400e;
    font-size: 12px;
}

/* =====================================================
   FOOTER
===================================================== */

footer {
    width: 100%;
    max-width: 1600px;
    margin: 28px auto 0;
    padding: 16px 18px;
    background: #182840;
    color: white;
    border-radius: 12px;
    text-align: center;
    opacity: 0.95;
}

.footer-content {
    text-align: center;
}

.footer-brand {
    color: white;
    font-size: 17px;
    font-weight: 800;
}

.footer-content p {
    margin: 5px 0 10px;
    color: #d0e6ff;
    font-size: 12px;
}

.footer-content h5 {
    margin: 0;
    color: #aebed2;
    font-size: 11px;
    font-weight: 500;
}

/* =====================================================
   TOMBOL KEMBALI
===================================================== */

.btn-back {
    display: block;
    width: fit-content;
    max-width: 100%;
    margin: 15px auto;
    padding: 13px 22px;
    background: #233c61;
    color: white;
    font-weight: 700;
    text-decoration: none;
    text-align: center;
    border-radius: 10px;
    box-shadow: 0 3px 6px rgba(0,0,0,0.2);
    transition: background 0.2s, transform 0.2s;
}

.btn-back:hover {
    background: #51688a;
    transform: translateY(-2px);
}

/* =====================================================
   TABLET / LAPTOP KECIL
===================================================== */

@media (max-width: 1100px) {
    .grid-container {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .grid-container > .map-card {
        grid-column: 1 / -1;
        grid-row: auto;
        order: 999;
    }

    .summary-item {
        flex: 1 1 45%;
    }
}

/* =====================================================
   MOBILE
===================================================== */

@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    .main-header {
        padding: 16px;
        margin-bottom: 17px;
        border-radius: 12px;
    }

    .header-content {
        align-items: flex-start;
    }

    .brand-section {
        gap: 10px;
    }

    .brand-icon {
        width: 44px;
        height: 44px;
        font-size: 25px;
        border-radius: 11px;
    }

    .brand-text h1 {
        font-size: 19px;
    }

    .brand-text p {
        font-size: 10px;
    }

    .header-status {
        margin-left: 54px;
        font-size: 10px;
    }

    .toolbar {
        justify-content: flex-start;
        margin-top: 14px;
    }

    #lastUpdate {
        font-size: 11px;
    }

    .dashboard-heading {
        margin-bottom: 14px;
    }

    .dashboard-heading h2 {
        font-size: 18px;
    }

    .dashboard-heading p {
        font-size: 11px;
    }

    .grid-container {
        grid-template-columns: minmax(0, 1fr);
        gap: 13px;
    }

    .station-card {
        min-height: auto;
        padding: 14px;
        border-radius: 12px;
    }

    .station-header h2 {
        font-size: 16px;
    }

    .station-summary {
        gap: 8px;
    }

    .summary-item {
        flex: 1 1 45%;
        padding: 10px 6px;
    }

    .summary-item .icon {
        width: 26px;
        height: 26px;
    }

    .summary-item h3 {
        font-size: 11px;
    }

    .summary-item p {
        font-size: 17px;
    }

    .grid-container > .map-card {
        grid-column: 1;
        grid-row: auto;
        order: 999;
        padding: 10px;
    }

    #map,
    #miniMap,
    .map-container {
        height: 270px;
        min-height: 270px;
    }

    footer {
        margin-top: 20px;
        padding: 14px;
        font-size: 11px;
    }

    .btn-back {
        width: 100%;
    }
}

/* =====================================================
   HP SANGAT KECIL
===================================================== */

@media (max-width: 360px) {
    body {
        padding: 7px;
    }

    .main-header {
        padding: 12px;
    }

    .brand-text h1 {
        font-size: 17px;
    }

    .station-card {
        padding: 11px;
    }

    .summary-item {
        gap: 5px;
        padding: 8px 4px;
    }

    .summary-item .icon {
        width: 22px;
        height: 22px;
    }

    .summary-item p {
        font-size: 15px;
    }

    #map,
    #miniMap,
    .map-container {
        height: 250px;
        min-height: 250px;
    }
}

/* =====================================================
   AKSESIBILITAS
===================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
/* POSISI PETA DESKTOP */
@media (min-width: 1101px) {
    #stationsContainer {
        display: grid !important;
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        grid-auto-flow: row;
    }

    #stationsContainer > .map-card {
        grid-column: 4 !important;
        grid-row: 2 !important;
        order: 0 !important;
        width: 100%;
    }
}

/* TABLET */
@media (min-width: 601px) and (max-width: 1100px) {
    #stationsContainer {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    #stationsContainer > .map-card {
        grid-column: 1 / -1 !important;
        grid-row: auto !important;
    }
}

/* HP */
@media (max-width: 600px) {
    #stationsContainer {
        display: flex !important;
        flex-direction: column !important;
    }

    #stationsContainer > .map-card {
        order: 999 !important;
        width: 100% !important;
    }
}

.dashboard-heading {
    width: 100%;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 24px;
}

.dashboard-heading h2 {
    width: 100%;
    text-align: center;
    margin: 0;
}

/* =====================================
   MODE TV / LAYAR BESAR 50 INCH
   ===================================== */

@media (min-width: 1600px) {

    .dashboard-main {
        max-width: 1900px;
        margin: auto;
        padding: 25px 35px;
    }

    .dashboard-heading h2 {
        font-size: 30px;
    }

    #stationsContainer {
        gap: 22px;
    }

    .station-card {
        min-height: 320px;
        padding: 24px;
        border-radius: 18px;
    }

    .station-header h2 {
        font-size: 23px;
    }

    .station-summary {
        gap: 18px;
    }

    .summary-item {
        padding: 18px;
    }

    .summary-item strong {
        font-size: 28px;
    }

    .summary-item span {
        font-size: 15px;
    }

    #map {
        height: 380px;
        min-height: 380px;
    }

    .status {
        font-size: 14px;
        padding: 7px 12px;
    }

    .alert-hujan,
    .alert-suhu {
        font-size: 15px;
        padding: 14px;
    }
}



.story-download-btn {
    border: none;
    background: #1769aa;
    color: #fff;
    padding: 10px 16px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background .2s ease;
}

.story-download-btn:hover {
    background: #0d4f85;
}

.story-download-btn:disabled {
    opacity: .6;
    cursor: wait;
}

@media (max-width: 600px) {
    .toolbar {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .story-download-btn {
        width: 100%;
    }
}


/* =========================================
   PERBAIKAN TAMPILAN DATA PARAMETER STASIUN
   Judul di atas, nilai di bawah
========================================= */

.station-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
}

.summary-item {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: center;
    justify-content: initial;
    gap: 2px 9px;
    min-width: 0;
    min-height: 76px;
    padding: 12px 10px;
    text-align: left;
    border-radius: 10px;
}

.summary-item .icon {
    grid-column: 1;
    grid-row: 1 / 3;
    width: 28px;
    height: 28px;
    align-self: center;
}

.summary-item h3 {
    grid-column: 2;
    grid-row: 1;
    margin: 0;
    font-size: 11px;
    line-height: 1.3;
    text-align: left;
}

.summary-item p {
    grid-column: 2;
    grid-row: 2;
    margin: 0;
    font-size: clamp(16px, 1.5vw, 21px);
    line-height: 1.3;
    text-align: left;
    overflow-wrap: anywhere;
}

/* Tablet */
@media (max-width: 1100px) {
    .station-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* HP */
@media (max-width: 600px) {
    .station-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .summary-item {
        min-height: 70px;
        padding: 10px 7px;
        gap: 2px 7px;
    }

    .summary-item .icon {
        width: 24px;
        height: 24px;
    }

    .summary-item h3 {
        font-size: 10px;
    }

    .summary-item p {
        font-size: 16px;
    }
}
/* =========================================
   POSISI JUDUL, IKON DAN NILAI PARAMETER
========================================= */

/* Empat parameter pertama */
.station-summary > .summary-item:not(:nth-child(5)) {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 22px !important;
    grid-template-rows: auto auto !important;
    align-items: center !important;
    justify-content: initial !important;
    gap: 5px 4px !important;
    text-align: left !important;
}

/* Judul di kiri atas */
.station-summary > .summary-item:not(:nth-child(5)) h3 {
    grid-column: 1 !important;
    grid-row: 1 !important;
    width: 100% !important;
    margin: 0 !important;
    text-align: left !important;
    align-self: center !important;
}

/* Ikon kecil di kanan judul */
.station-summary > .summary-item:not(:nth-child(5)) .icon {
    display: inline-flex !important;
    grid-column: 2 !important;
    grid-row: 1 !important;
    width: 18px !important;
    height: 18px !important;
    font-size: 14px !important;
    align-self: center !important;
    justify-self: end !important;
    margin: 0 !important;
}

/* Nilai di bawah judul */
.station-summary > .summary-item:not(:nth-child(5)) p {
    grid-column: 1 / -1 !important;
    grid-row: 2 !important;
    width: 100% !important;
    margin: 0 !important;
    text-align: left !important;
}

/* Total hujan tetap memanjang dan di tengah */
.station-summary > .summary-item:nth-child(5) {
    grid-column: 1 / -1 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
}

.station-summary > .summary-item:nth-child(5) h3,
.station-summary > .summary-item:nth-child(5) p {
    width: 100% !important;
    text-align: center !important;
}