/* =========================================================
   FOOD SAVER
   DASHBOARD CSS
   Responsive Layout
   ========================================================= */


/* =========================================================
   DASHBOARD ROOT
   ========================================================= */

.fs-dashboard {
    width: 100%;
    height: 100%;

    min-width: 0;
    min-height: 0;

    box-sizing: border-box;

    display: grid;

    /*
        Desktop:
        kiri  = CCTV / status / alarm / system
        kanan = sensor cards
    */
    grid-template-columns:
        minmax(320px, 38%)
        minmax(0, 1fr);

    gap: 6px;
    padding: 5px;

    background: #000;
    color: #eaf4f7;

    overflow: hidden;

    font-family:
        "DejaVu Sans",
        Arial,
        sans-serif;
}


/* Semua elemen dashboard mengikuti box sizing */

.fs-dashboard *,
.fs-dashboard *::before,
.fs-dashboard *::after {
    box-sizing: border-box;
}


/* =========================================================
   GENERAL PANEL
   ========================================================= */

.fs-panel,
.fs-sensor-card {
    background: #041721;

    border: 1px solid #006a86;
    border-radius: 7px;

    overflow: hidden;
}


/* =========================================================
   LEFT COLUMN
   ========================================================= */

.fs-left-column {

    width: 100%;
    height: 100%;

    min-width: 0;
    min-height: 0;

    display: grid;

    /*
        CCTV
        Door + Smoke
        Alarm
        System
    */
    grid-template-rows:
        minmax(240px, 1.9fr)
        minmax(90px, 0.6fr)
        minmax(110px, 0.75fr)
        minmax(120px, 1fr);

    gap: 6px;

    overflow: hidden;
}


/* =========================================================
   CCTV
   ========================================================= */

.fs-cctv {

    width: 100%;
    height: 100%;

    min-width: 0;
    min-height: 0;

    display: flex;
    flex-direction: column;

    padding:
        clamp(7px, 0.7vw, 11px)
        clamp(8px, 0.8vw, 12px);

    overflow: hidden;
}


.fs-panel-header,
.fs-sensor-head {

    min-width: 0;

    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 8px;
}


.fs-panel-header {
    min-height: 27px;
}


.fs-panel-title {

    min-width: 0;

    color: #e8f2f6;

    font-size: clamp(14px, 1.2vw, 19px);

    font-weight: 700;

    line-height: 1.2;
}


.fs-live {

    flex-shrink: 0;

    display: flex;
    align-items: center;

    color: #00e676;

    font-size: clamp(12px, 1vw, 17px);

    font-weight: 700;

    white-space: nowrap;
}


.fs-live span {

    display: inline-block;

    width: clamp(7px, 0.6vw, 10px);
    height: clamp(7px, 0.6vw, 10px);

    margin-right: 5px;

    border-radius: 50%;

    background: #00e676;
}


/* =========================================================
   CAMERA FRAME
   ========================================================= */

.fs-camera-frame {

    width: 100%;
    height: 100%;

    min-width: 0;
    min-height: 0;

    flex: 1 1 auto;

    margin-top: 7px;

    border: 1px solid #006e91;
    border-radius: 5px;

    background: #020c13;

    overflow: hidden;
}


.fs-camera-frame iframe {

    width: 100%;
    height: 100%;

    min-width: 0;
    min-height: 0;

    display: block;

    border: 0;

    background: #020c13;
}


/* =========================================================
   DOOR + SMOKE STATUS
   ========================================================= */

.fs-status-row {

    width: 100%;
    height: 100%;

    min-width: 0;
    min-height: 0;

    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 6px;

    overflow: hidden;
}


.fs-status-card {

    width: 100%;
    height: 100%;

    min-width: 0;
    min-height: 0;

    padding:
        clamp(6px, 0.6vw, 10px)
        clamp(7px, 0.8vw, 12px);

    display: flex;
    flex-direction: column;

    justify-content: space-between;

    overflow: hidden;
}


.fs-status-title {

    min-width: 0;

    display: flex;

    align-items: center;

    gap: 7px;

    color: #e8f2f6;

    font-size: clamp(11px, 1vw, 18px);

    font-weight: 700;

    line-height: 1.2;

    white-space: nowrap;
}


.fs-status-title img {

    width: clamp(16px, 1.5vw, 21px);
    height: clamp(16px, 1.5vw, 21px);

    flex-shrink: 0;

    object-fit: contain;
}


.fs-status-main {

    min-width: 0;
    min-height: 0;

    flex: 1;

    display: flex;

    justify-content: center;
    align-items: center;

    gap: clamp(5px, 0.7vw, 9px);

    overflow: hidden;
}


.fs-status-icon {

    width: clamp(30px, 3.2vw, 48px);
    height: clamp(30px, 3.2vw, 48px);

    flex-shrink: 0;

    object-fit: contain;
}


.fs-status-main strong {

    min-width: 0;

    color: #f5f9fb;

    font-size: clamp(17px, 2vw, 30px);

    font-weight: 700;

    white-space: nowrap;

    overflow: hidden;
    text-overflow: ellipsis;
}


.fs-status-normal {

    display: flex;

    align-items: center;
    justify-content: center;

    gap: 5px;

    color: #00e676;

    font-size: clamp(10px, 0.9vw, 16px);

    line-height: 1.2;
}


.fs-status-normal span {

    width: 8px;
    height: 8px;

    flex-shrink: 0;

    border-radius: 50%;

    background: #00e676;
}


.fs-status-description {

    text-align: center;

    color: #b9cad1;

    font-size: clamp(9px, 0.75vw, 13px);

    margin-top: 2px;

    line-height: 1.2;
}


/* =========================================================
   ALARM
   ========================================================= */

.fs-alarm {

    width: 100%;
    height: 100%;

    min-width: 0;
    min-height: 0;

    padding:
        clamp(7px, 0.7vw, 10px)
        clamp(8px, 0.8vw, 12px);

    overflow: hidden;
}


.fs-alarm-list {

    width: 100%;
    height: calc(100% - 28px);

    min-width: 0;
    min-height: 0;

    display: flex;

    flex-direction: column;

    justify-content: center;

    gap: 5px;

    padding-left: 5px;

    overflow: hidden;
}


.fs-alarm-list div {

    min-width: 0;

    display: flex;

    align-items: center;

    gap: 9px;

    color: #00e676;

    font-size: clamp(10px, 0.8vw, 13px);

    font-weight: 700;

    line-height: 1.2;
}


.fs-alarm-list i {

    width: 4px;
    height: 20px;

    flex-shrink: 0;

    display: block;

    background: #00e676;
}


/* =========================================================
   SYSTEM INFORMATION
   ========================================================= */

.fs-system {

    width: 100%;
    height: 100%;

    min-width: 0;
    min-height: 0;

    padding:
        clamp(7px, 0.7vw, 10px)
        clamp(8px, 0.8vw, 12px);

    overflow: hidden;
}


.fs-system-title {

    min-width: 0;

    color: #e8f2f6;

    font-size: clamp(13px, 1vw, 17px);

    font-weight: 700;

    margin-bottom: 5px;

    line-height: 1.2;
}


.fs-system-grid {

    width: 100%;

    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        auto;

    row-gap: 3px;

    column-gap: 10px;

    font-size: clamp(10px, 0.75vw, 13px);

    line-height: 1.25;
}


.fs-system-grid span {

    min-width: 0;

    color: #c5d3d8;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;
}


.fs-system-grid b {

    min-width: 0;

    color: #eaf4f7;

    text-align: right;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;
}


.fs-system-grid .sys-good {

    color: #00e676;
}


/* =========================================================
   SENSOR GRID
   ========================================================= */

.fs-sensor-grid {

    width: 100%;
    height: 100%;

    min-width: 0;
    min-height: 0;

    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    grid-template-rows:
        repeat(3, minmax(0, 1fr));

    gap: 6px;

    overflow: hidden;
}


/* =========================================================
   SENSOR CARD
   ========================================================= */

.fs-sensor-card {

    position: relative;

    width: 100%;
    height: 100%;

    min-width: 0;
    min-height: 0;

    padding:
        clamp(7px, 0.7vw, 10px)
        clamp(8px, 0.8vw, 12px);

    display: flex;

    flex-direction: column;

    overflow: hidden;
}


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

.fs-sensor-head {

    flex: 0 0 auto;

    min-height: 25px;
}


.fs-sensor-head strong {

    min-width: 0;

    color: #eaf4f7;

    font-size: clamp(15px, 1.3vw, 20px);

    font-weight: 700;

    line-height: 1.2;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;
}


.fs-sensor-status {

    flex-shrink: 0;

    display: flex;

    align-items: center;

    color: #00e676;

    font-size: clamp(10px, 0.9vw, 14px);

    font-weight: 700;

    white-space: nowrap;
}


.fs-sensor-status i {

    display: inline-block;

    width: 7px;
    height: 7px;

    flex-shrink: 0;

    margin-right: 4px;

    border-radius: 50%;

    background: #00e676;
}


/* =========================================================
   SENSOR MEASUREMENT
   ========================================================= */

.fs-measure-row {

    width: 100%;

    min-width: 0;

    min-height: 58px;

    flex: 0 0 auto;

    display: grid;

    grid-template-columns:
        clamp(38px, 3.2vw, 48px)
        minmax(70px, 0.75fr)
        minmax(100px, 1.25fr);

    gap: 7px;

    align-items: center;
}


.fs-measure-row > img {

    width: clamp(38px, 3.2vw, 48px);
    height: clamp(38px, 3.2vw, 48px);

    flex-shrink: 0;

    object-fit: contain;
}


/* =========================================================
   SENSOR VALUE
   ========================================================= */

.fs-value-wrap {

    min-width: 0;

    display: flex;

    flex-direction: column;

    justify-content: center;

    overflow: hidden;
}


.fs-value-wrap .sensor-value {

    min-width: 0;

    color: #f5f9fb;

    font-size: clamp(24px, 2.8vw, 36px);

    line-height: 1;

    font-weight: 700;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;
}


.fs-value-wrap .unit {

    color: #9aaeb7;

    font-size: clamp(11px, 0.9vw, 15px);

    margin-top: 3px;

    line-height: 1.2;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;
}


/* =========================================================
   SENSOR RANGE
   ========================================================= */

.fs-range-wrap {

    min-width: 0;

    width: 100%;
}


.fs-range-bar {

    position: relative;

    width: 100%;
    height: 9px;

    background: #10232d;

    border-radius: 5px;

    overflow: visible;
}


.fs-range-bar > div {

    width: 50%;
    height: 100%;

    border-radius: 5px;

    background: #22d3ee;
}


.fs-range-bar > b {

    position: absolute;

    left: 50%;
    top: 0;

    width: 8px;
    height: 8px;

    margin-left: -4px;

    border-radius: 50%;

    background: #f5f9fb;
}


.fs-range-label {

    display: flex;

    justify-content: space-between;

    gap: 5px;

    color: #718892;

    font-size: 10px;

    margin-top: 3px;

    line-height: 1.1;
}


.fs-range-label span {

    min-width: 0;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;
}


/* =========================================================
   SENSOR CHART
   ========================================================= */

.fs-chart {

    position: relative;

    width: 100%;

    flex: 1 1 auto;

    min-width: 0;
    min-height: 45px;

    margin-top: 3px;

    border: 1px solid #123746;

    border-radius: 3px;

    background: #020b11;

    overflow: hidden;
}


.fs-chart canvas {

    width: 100%;
    height: 100%;

    display: block;
}


.fs-chart-axis {

    position: absolute;

    right: 3px;
    bottom: 1px;

    color: #718892;

    font-size: 8px;

    pointer-events: none;
}


/* =========================================================
   CHART BUTTONS
   ========================================================= */

.fs-chart-buttons {
    position: static;
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    align-items: center;
    gap: 5px;
    margin-top: 6px;
    z-index: 2;
}


.fs-chart-buttons button {

    width: 42px;
    height: 24px;

    padding: 0;

    border: 1px solid #244652;

    border-radius: 4px;

    background: #061a24;

    color: #8fa8b2;

    font:
        600 8px
        "DejaVu Sans",
        Arial,
        sans-serif;

    cursor: pointer;

    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease;
}


.fs-chart-buttons button:hover {

    color: #e8f2f6;

    background: #0a2b36;

    border-color: #317789;
}


.fs-chart-buttons button.active {

    color: #e8f2f6;

    background: #0a4050;

    border-color: #22d3ee;
}


/* =========================================================
   SENSOR COLORS
   ========================================================= */

.fs-sensor-card[data-sensor-id="ozone"]
.fs-range-bar > div {

    background: #22d3ee;
}


.fs-sensor-card[data-sensor-id="oxygen"]
.fs-range-bar > div {

    background: #3b82f6;
}


.fs-sensor-card[data-sensor-id="co2"]
.fs-range-bar > div {

    background: #8b5cf6;
}


.fs-sensor-card[data-sensor-id="ethylene"]
.fs-range-bar > div {

    background: #d946ef;
}


.fs-sensor-card[data-sensor-id="temperature"]
.fs-range-bar > div {

    background: #0ea5e9;
}


.fs-sensor-card[data-sensor-id="humidity"]
.fs-range-bar > div {

    background: #6366f1;
}


/* =========================================================
   TABLET / SMALL LAPTOP
   <= 1200px
   ========================================================= */

@media (max-width: 1200px) {

    .fs-dashboard {

        grid-template-columns:
            minmax(300px, 40%)
            minmax(0, 1fr);
    }


    .fs-sensor-head strong {

        font-size: clamp(14px, 1.5vw, 18px);
    }


    .fs-sensor-status {

        font-size: 11px;
    }


    .fs-measure-row {

        grid-template-columns:
            42px
            minmax(65px, 0.8fr)
            minmax(90px, 1.2fr);
    }


    .fs-measure-row > img {

        width: 42px;
        height: 42px;
    }


    .fs-value-wrap .sensor-value {

        font-size: clamp(22px, 2.6vw, 32px);
    }
}


/* =========================================================
   TABLET / MOBILE
   <= 900px
   ========================================================= */

@media (max-width: 900px) {

    .fs-dashboard {

        width: 100%;
        height: auto;

        min-height: 100%;

        display: grid;

        grid-template-columns:
            minmax(0, 1fr);

        grid-template-rows: auto;

        gap: 6px;

        padding: 5px;

        overflow-x: hidden;
        overflow-y: auto;
    }


    /* -----------------------------------------------------
       LEFT COLUMN
       ----------------------------------------------------- */

    .fs-left-column {

        width: 100%;
        height: auto;

        min-width: 0;
        min-height: 0;

        display: grid;

        grid-template-rows:
            minmax(280px, 45vh)
            minmax(100px, auto)
            minmax(120px, auto)
            auto;

        gap: 6px;

        overflow: visible;
    }


    /* -----------------------------------------------------
       CCTV
       ----------------------------------------------------- */

    .fs-cctv {

        width: 100%;
        height: 100%;

        min-height: 280px;
    }


    /* -----------------------------------------------------
       STATUS
       ----------------------------------------------------- */

    .fs-status-row {

        width: 100%;
        height: auto;

        min-height: 100px;

        grid-template-columns:
            repeat(2, minmax(0, 1fr));

        overflow: visible;
    }


    .fs-status-card {

        min-height: 100px;
    }


    /* -----------------------------------------------------
       ALARM
       ----------------------------------------------------- */

    .fs-alarm {

        min-height: 120px;

        overflow: visible;
    }


    /* -----------------------------------------------------
       SYSTEM
       ----------------------------------------------------- */

    .fs-system {

        min-height: 150px;

        overflow: visible;
    }


    /* -----------------------------------------------------
       SENSOR GRID
       ----------------------------------------------------- */

    .fs-sensor-grid {

        width: 100%;
        height: auto;

        min-width: 0;

        display: grid;

        grid-template-columns:
            repeat(2, minmax(0, 1fr));

        grid-auto-rows:
            minmax(190px, auto);

        grid-template-rows: none;

        gap: 6px;

        overflow: visible;
    }


    .fs-sensor-card {

        width: 100%;
        height: auto;

        min-height: 190px;
    }


    /* -----------------------------------------------------
       SENSOR MEASUREMENT
       ----------------------------------------------------- */

    .fs-measure-row {

        grid-template-columns:
            42px
            minmax(70px, 0.8fr)
            minmax(90px, 1.2fr);
    }


    .fs-measure-row > img {

        width: 42px;
        height: 42px;
    }


    .fs-value-wrap .sensor-value {

        font-size: clamp(24px, 4vw, 32px);
    }
}


/* =========================================================
   MOBILE
   <= 600px
   ========================================================= */

@media (max-width: 600px) {

    .fs-dashboard {

        width: 100%;
        height: auto;

        min-height: 100%;

        padding: 4px;

        gap: 6px;

        overflow-x: hidden;
        overflow-y: auto;
    }


    /* -----------------------------------------------------
       LEFT COLUMN
       ----------------------------------------------------- */

    .fs-left-column {

        width: 100%;
        height: auto;

        display: grid;

        grid-template-rows:
            minmax(220px, 58vw)
            auto
            auto
            auto;

        gap: 6px;

        overflow: visible;
    }


    /* -----------------------------------------------------
       CCTV
       ----------------------------------------------------- */

    .fs-cctv {

        min-height: 220px;

        padding: 7px;
    }


    .fs-panel-title {

        font-size: 15px;
    }


    .fs-live {

        font-size: 12px;
    }


    .fs-live span {

        width: 7px;
        height: 7px;

        margin-right: 4px;
    }


    /* -----------------------------------------------------
       DOOR + SMOKE
       ----------------------------------------------------- */

    .fs-status-row {

        height: auto;

        min-height: 105px;

        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }


    .fs-status-card {

        min-height: 105px;

        padding: 7px;
    }


    .fs-status-title {

        font-size: 12px;

        gap: 5px;
    }


    .fs-status-title img {

        width: 17px;
        height: 17px;
    }


    .fs-status-icon {

        width: 34px;
        height: 34px;
    }


    .fs-status-main {

        gap: 5px;
    }


    .fs-status-main strong {

        font-size: 20px;
    }


    .fs-status-normal {

        font-size: 11px;
    }


    .fs-status-normal span {

        width: 7px;
        height: 7px;
    }


    .fs-status-description {

        font-size: 9px;
    }


    /* -----------------------------------------------------
       ALARM
       ----------------------------------------------------- */

    .fs-alarm {

        min-height: 145px;

        padding: 7px;
    }


    .fs-alarm-list {

        gap: 4px;

        padding-left: 4px;
    }


    .fs-alarm-list div {

        font-size: 10px;

        gap: 7px;
    }


    .fs-alarm-list i {

        height: 17px;
    }


    /* -----------------------------------------------------
       SYSTEM
       ----------------------------------------------------- */

    .fs-system {

        min-height: 175px;

        padding: 8px;

        overflow: visible;
    }


    .fs-system-title {

        font-size: 14px;
    }


    .fs-system-grid {

        font-size: 11px;

        row-gap: 4px;
    }


    /* -----------------------------------------------------
       SENSOR GRID
       ----------------------------------------------------- */

    .fs-sensor-grid {

        width: 100%;
        height: auto;

        grid-template-columns:
            minmax(0, 1fr);

        grid-auto-rows:
            minmax(210px, auto);

        gap: 6px;

        overflow: visible;
    }


    .fs-sensor-card {

        width: 100%;
        height: auto;

        min-height: 210px;

        padding: 8px;
    }


    .fs-sensor-head strong {

        font-size: 16px;
    }


    .fs-sensor-status {

        font-size: 10px;
    }


    .fs-measure-row {

        grid-template-columns:
            42px
            minmax(70px, 1fr)
            minmax(100px, 1.2fr);

        min-height: 58px;

        gap: 6px;
    }


    .fs-measure-row > img {

        width: 42px;
        height: 42px;
    }


    .fs-value-wrap .sensor-value {

        font-size: 27px;
    }


    .fs-value-wrap .unit {

        font-size: 12px;
    }


    .fs-range-bar {

        height: 8px;
    }


    .fs-range-label {

        font-size: 9px;
    }


    /* -----------------------------------------------------
       CHART
       ----------------------------------------------------- */

    .fs-chart {

        min-height: 65px;
    }


    /* -----------------------------------------------------
       CHART BUTTONS
       ----------------------------------------------------- */

    .fs-chart-buttons {

        flex-direction: row;

        gap: 3px;
    }


    .fs-chart-buttons button {

        width: 34px;
        height: 21px;

        font-size: 8px;
    }
}


/* =========================================================
   VERY SMALL MOBILE
   <= 380px
   ========================================================= */

@media (max-width: 380px) {

    .fs-dashboard {

        padding: 3px;
    }


    /* -----------------------------------------------------
       STATUS
       ----------------------------------------------------- */

    .fs-status-row {

        grid-template-columns:
            minmax(0, 1fr);

        min-height: 0;
    }


    .fs-status-card {

        min-height: 95px;
    }


    /* -----------------------------------------------------
       SENSOR
       ----------------------------------------------------- */

    .fs-sensor-card {

        min-height: 195px;
    }


    .fs-measure-row {

        grid-template-columns:
            38px
            minmax(65px, 1fr)
            minmax(85px, 1.1fr);

        gap: 5px;
    }


    .fs-measure-row > img {

        width: 38px;
        height: 38px;
    }


    .fs-value-wrap .sensor-value {

        font-size: 24px;
    }


    .fs-value-wrap .unit {

        font-size: 11px;
    }


    .fs-range-label {

        font-size: 8px;
    }


    .fs-chart-buttons {

    }


    .fs-chart-buttons button {

        width: 31px;
        height: 20px;

        font-size: 7px;
    }
}


/* =========================================================
   ACCESSIBILITY / REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

    .fs-chart-buttons button {

        transition: none;
    }
}
/* =========================================================
   FOOD SAVER - TREND CHART POLISH
   ========================================================= */

/* Angka pengukuran lebih mudah dibaca */
.fs-sensor-card .sensor-value {
    font-size: clamp(27px, 2.2vw, 36px);
    line-height: 1.15;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Grafik mengambil ruang di atas tombol */
.fs-sensor-card .fs-chart {
    position: relative;
    flex: 1 1 auto;
    min-height: 65px;
    width: 100%;
    margin-top: 5px;
}

/* Canvas mengisi area grafik */
.fs-sensor-card .fs-chart canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Tombol selalu di bawah grafik, bukan overlay */
.fs-sensor-card .fs-chart-buttons {
    position: static;
    inset: auto;
    flex: 0 0 auto;
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    align-items: center;
    gap: 5px;
    width: 100%;
    margin-top: 5px;
    z-index: auto;
}

.fs-sensor-card .fs-chart-buttons button {
    flex: 0 1 42px;
    width: 42px;
    min-width: 0;
    height: 23px;
    font-size: 9px;
}

@media (max-width: 900px) {
    .fs-sensor-card .sensor-value {
        font-size: clamp(25px, 3.5vw, 31px);
    }
}

@media (max-width: 380px) {
    .fs-sensor-card .sensor-value {
        font-size: 24px;
    }

    .fs-sensor-card .fs-chart {
        min-height: 65px;
    }

    .fs-sensor-card .fs-chart-buttons {
        gap: 3px;
    }

    .fs-sensor-card .fs-chart-buttons button {
        flex: 0 1 34px;
        width: 34px;
        height: 21px;
        font-size: 8px;
    }
}

clear