/* ============================================================
   WATER MONITORING SYSTEM — SHARED STYLESHEET
   Digunakan oleh: index.html, tren-sensor.html & log-alert.html
   ============================================================ */

/* ── Base ── */
body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: #F0F4F8;
    color: #0F172A;
    min-height: 100vh;
}

/* ── Card Utilities ── */
.card-shadow {
    box-shadow: 0 4px 20px -5px rgba(0, 0, 0, 0.05);
}

/* ── Activity List Scrollbar ── */
#activity-list::-webkit-scrollbar {
    width: 4px;
}

#activity-list::-webkit-scrollbar-thumb {
    background: #e2e8f1;
    border-radius: 10px;
}

/* ============================================================
   TOAST NOTIFICATION SYSTEM
   (konsisten antara index.html, tren-sensor.html & log-alert.html)
   ============================================================ */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: 14px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 11px;
    font-weight: 700;
    color: white;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    animation: slideInToast 0.35s ease forwards;
    pointer-events: auto;
    min-width: 220px;
}

.toast.success {
    background: #10B981;
}

.toast.error {
    background: #EF4444;
}

.toast.info {
    background: #488cf9;
}

@keyframes slideInToast {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes fadeOutToast {
    to {
        opacity: 0;
        transform: translateY(8px) scale(0.95);
    }
}

/* ============================================================
   OFFLINE BANNER  (index.html)
   ============================================================ */
#offline-banner {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9998;
    background: #F59E0B;
    color: white;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 10px;
    font-weight: 800;
    text-align: center;
    padding: 6px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

#offline-banner.show {
    display: block;
}

/* ============================================================
   CUSTOM CONFIRM DIALOG  (log_alert.html)
   ============================================================ */
#confirm-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

#confirm-overlay.show {
    display: flex;
}

#confirm-box {
    background: white;
    border-radius: 24px;
    padding: 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.15);
    animation: slideInToast 0.3s ease forwards;
}

/* ============================================================
   ORBITAL MONITORING LAYOUT (index.html)
   ============================================================ */

/* Layout 3 kolom: Kiri (2 sensor) | Tengah (gauge) | Kanan (2 sensor) */
.orbital-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    gap: 16px;
}

/* Kolom kiri & kanan: 2 sensor di-stack vertikal */
.orbital-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-evenly;
    height: 80%;
    min-width: 90px;
    flex-shrink: 0;
}

/* Tiap cell sensor */
.orbital-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 3px;
    transition: transform 0.3s ease;
}

.orbital-cell:hover {
    transform: scale(1.05);
}

/* Cell tengah (WQI gauge) */
.orbital-center {
    position: relative;
    flex: 1;
    max-width: 280px;
    aspect-ratio: 1;
}

/* SVG Gauge */
.orbital-gauge {
    width: 100%;
    height: 100%;
    transform: rotate(135deg);
}

.gauge-track {
    fill: none;
    stroke: #E8EDF2;
    stroke-width: 16;
    stroke-linecap: round;
    stroke-dasharray: 508.94 678.58;
}

.gauge-fill {
    fill: none;
    stroke: #10B981;
    stroke-width: 16;
    stroke-linecap: round;
    stroke-dasharray: 508.94 678.58;
    stroke-dashoffset: 508.94;
    transition: stroke-dashoffset 1.2s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.5s ease;
    filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.3));
}

/* Teks di tengah gauge */
.orbital-center-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 2px;
}

/* Ikon bulat di node */
.orbital-node-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.3s ease;
}

.orbital-node-value {
    font-size: 24px;
    font-weight: 800;
    color: #1E293B;
    line-height: 1;
}

.orbital-node-unit {
    font-size: 11px;
    font-weight: 700;
    color: #94A3B8;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.orbital-node-label {
    font-size: 11px;
    font-weight: 700;
    color: #64748B;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Pulse glow pada gauge */
@keyframes gaugeGlow {

    0%,
    100% {
        filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.3));
    }

    50% {
        filter: drop-shadow(0 0 14px rgba(16, 185, 129, 0.5));
    }
}

.gauge-fill.animate-glow {
    animation: gaugeGlow 2.5s ease-in-out infinite;
}

/* Slide-in animasi untuk activity items */
@keyframes slide-in {
    from {
        opacity: 0;
        transform: translateX(10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-slide-in {
    animation: slide-in 0.35s ease forwards;
}

/* Activity panel scrollbar */
.activity-panel-list::-webkit-scrollbar {
    width: 3px;
}

.activity-panel-list::-webkit-scrollbar-thumb {
    background: #e2e8f1;
    border-radius: 10px;
}

/* ============================================================
   COLLAPSIBLE SIDEBAR
   ============================================================ */
/* Atur transisi halus untuk lebar sidebar */
#sidebar {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Lebar saat collapsed */
html.sidebar-collapsed #sidebar {
    width: 76px !important;
}

/* Sembunyikan elemen teks (dan judul) saat collapsed */
html.sidebar-collapsed #sidebar .sidebar-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
    display: none;
}

/* Pusatkan isi link menu saat collapsed */
html.sidebar-collapsed #sidebar nav a,
html.sidebar-collapsed #sidebar button {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

/* Hilangkan gap pada item nav dan tombol saat collapsed */
html.sidebar-collapsed #sidebar nav a {
    gap: 0;
}
html.sidebar-collapsed #sidebar button {
    gap: 0;
}

/* Pastikan ikon tetap berukuran konsisten */
#sidebar i {
    flex-shrink: 0;
}

/* ============================================================
   RESPONSIVE DESIGN - MOBILE & TABLET
   ============================================================ */

/* TABLET (768px - 1024px) */
@media (max-width: 1024px) {
    /* Sidebar lebih sempit */
    #sidebar {
        width: 160px !important;
    }
    
    html.sidebar-collapsed #sidebar {
        width: 70px !important;
    }
    
    /* Activity panel lebih kecil */
    .activity-panel {
        width: 240px !important;
    }
    
    /* Orbital layout: reduce gap dan padding */
    .orbital-side {
        min-width: 75px;
    }
    
    .orbital-cell {
        gap: 2px;
    }
    
    .orbital-cell.mr-32 {
        margin-right: 24px;
    }
    
    .orbital-cell.ml-32 {
        margin-left: 24px;
    }
    
    .orbital-node-value {
        font-size: 20px;
    }
    
    .orbital-center {
        max-width: 240px;
    }
    
    /* Toast container */
    #toast-container {
        bottom: 16px;
        right: 16px;
    }
    
    .toast {
        min-width: 200px;
        font-size: 10px;
    }
}

/* MOBILE LANDSCAPE (576px - 1024px) */
@media (max-width: 768px) {
    /* Body padding */
    body {
        padding: 12px !important;
        gap: 12px !important;
    }
    
    /* Header adjustments */
    header {
        padding: 12px 16px !important;
        border-radius: 14px !important;
    }
    
    header .flex.items-center:first-child {
        gap: 12px !important;
    }
    
    header h1 {
        font-size: 14px;
    }
    
    header h2 {
        font-size: 12px;
    }
    
    header p {
        font-size: 13px;
    }
    
    /* Sidebar hidden by default on mobile, can be toggled */
    #sidebar {
        position: absolute;
        left: 0;
        top: 60px;
        height: calc(100vh - 120px);
        width: 160px;
        z-index: 35;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
    }
    
    #sidebar.mobile-open {
        transform: translateX(0);
    }
    
    /* Main bottom wrapper responsive */
    .flex.flex-1.gap-4.overflow-hidden {
        gap: 0 !important;
        flex-direction: column;
    }
    
    /* Orbital layout: change to single column */
    .orbital-layout {
        flex-direction: column;
        gap: 12px;
        height: auto !important;
    }
    
    .orbital-side {
        flex-direction: row;
        justify-content: center;
        gap: 16px;
        height: auto;
        min-width: auto;
        width: 100%;
        flex-shrink: 1;
    }
    
    .orbital-cell {
        gap: 4px;
        flex: 1;
        min-width: 70px;
    }
    
    .orbital-cell.mr-32,
    .orbital-cell.ml-32 {
        margin: 0 !important;
    }
    
    .orbital-node-icon {
        width: 48px;
        height: 48px;
        font-size: 18px;
    }
    
    .orbital-node-value {
        font-size: 18px;
    }
    
    .orbital-node-unit {
        font-size: 9px;
    }
    
    .orbital-node-label {
        font-size: 9px;
    }
    
    .orbital-center {
        max-width: 200px;
        width: 100%;
    }
    
    .orbital-center-content {
        gap: 1px;
    }
    
    .orbital-center-content #wqi-label {
        font-size: 8px !important;
    }
    
    .orbital-center-content #wqi-status {
        font-size: 13px !important;
    }
    
    .orbital-center-content #wqi-desc {
        font-size: 8px !important;
    }
    
    /* Activity panel: full width on mobile */
    .activity-panel,
    .w-\\[280px\\] {
        width: 100% !important;
        shrink: 0 !important;
    }
    
    .activity-panel-list {
        min-height: 120px;
    }
    
    /* Charts section */
    div[style*="height:220px"] {
        height: 280px !important;
    }
    
    /* Toast container mobile positioning */
    #toast-container {
        bottom: 12px;
        right: 12px;
        left: 12px;
    }
    
    .toast {
        min-width: auto;
        width: 100%;
        max-width: 350px;
        margin-left: auto;
        margin-right: auto;
    }
}

/* MOBILE SMALL (360px - 576px) */
@media (max-width: 576px) {
    /* Ultra-compact body */
    body {
        padding: 8px !important;
        gap: 8px !important;
    }
    
    /* Header ultra-compact */
    header {
        padding: 10px 12px !important;
        flex-wrap: wrap;
        border-radius: 12px !important;
    }
    
    header .flex.items-center:first-child {
        gap: 8px !important;
    }
    
    header h1 {
        font-size: 12px;
    }
    
    header h2 {
        font-size: 10px;
    }
    
    header p {
        font-size: 11px;
    }
    
    header .hidden.lg\\:flex {
        display: none !important;
    }
    
    /* Hide user info on small phones */
    .hidden.sm\\:block {
        display: none !important;
    }
    
    /* Sidebar responsive */
    #sidebar {
        width: 200px;
        top: 55px;
        height: calc(100vh - 115px);
    }
    
    html.sidebar-collapsed #sidebar {
        width: 65px !important;
    }
    
    /* Main content area */
    .flex-1.overflow-y-auto.flex.flex-col.relative {
        min-h: 0;
    }
    
    /* Reduce orbit layout padding */
    .orbital-layout {
        padding: 0 !important;
    }
    
    .orbital-side {
        gap: 12px;
    }
    
    .orbital-cell {
        gap: 3px;
        flex: 1;
    }
    
    .orbital-node-icon {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }
    
    .orbital-node-value {
        font-size: 16px;
    }
    
    .orbital-node-unit {
        font-size: 8px;
    }
    
    .orbital-node-label {
        font-size: 8px;
    }
    
    .orbital-center {
        max-width: 160px;
    }
    
    /* Activity panel */
    .activity-panel,
    .w-\\[280px\\] {
        width: 100% !important;
    }
    
    /* Chart height */
    div[style*="height:220px"] {
        height: 250px !important;
    }
    
    /* Toast mobile small */
    #toast-container {
        bottom: 8px;
        right: 8px;
        left: 8px;
    }
    
    .toast {
        padding: 10px 14px;
        font-size: 9px;
    }
    
    /* Confirm dialog */
    #confirm-box {
        padding: 20px;
        margin: 12px;
        border-radius: 18px;
    }
}

/* EXTRA SMALL (< 360px) */
@media (max-width: 360px) {
    body {
        padding: 6px !important;
        gap: 6px !important;
    }
    
    header {
        padding: 8px 10px !important;
    }
    
    header h1 {
        font-size: 11px;
    }
    
    .orbital-node-icon {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }
    
    .orbital-node-value {
        font-size: 14px;
    }
    
    .orbital-center {
        max-width: 140px;
    }
    
    .toast {
        padding: 8px 12px;
        font-size: 8px;
    }
}

/* ============================================================
   DESKTOP ADJUSTMENTS (untuk memastikan tidak ada regresi)
   ============================================================ */
@media (min-width: 1025px) {
    .orbital-cell.mr-32 {
        margin-right: 128px;
    }
    
    .orbital-cell.ml-32 {
        margin-left: 128px;
    }
}