/* ============================================================
   ROOT VARIABLES
   ============================================================ */
:root {
    --color-primary: #06b6d4; /* Neon Cyan */
    --color-primary-bg: rgba(6, 182, 212, 0.15);
    --color-accent: #0891b2;
    --bg-body: #0f172a; /* Deep Slate */
    --bg-card: rgba(30, 41, 59, 0.7); /* Semi-transparent Slate */
    --bg-card-hover: rgba(51, 65, 85, 0.8);
    --border: rgba(148, 163, 184, 0.15);
    --border-accent: rgba(6, 182, 212, 0.4);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-sub: #64748b;
    --brand: var(--color-primary);
    --brand-bg: var(--color-primary-bg);
    --green: #10b981; /* Emerald */
    --green-bg: rgba(16, 185, 129, 0.15);
    --red: #e11d48; /* Crimson */
    --red-bg: rgba(225, 29, 72, 0.15);
    --amber: #f59e0b;
    --font: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --mono: 'JetBrains Mono', monospace;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
}

/* Animasi Panic Mode (Global Flash) */
body.panic-mode {
    animation: panicGlobalFlash 0.6s infinite alternate;
}
@keyframes panicGlobalFlash {
    0% { box-shadow: inset 0 0 0px 0px rgba(225, 29, 72, 0); }
    100% { box-shadow: inset 0 0 60px 15px rgba(225, 29, 72, 0.6); }
}

/* ============================================================
   BASE
   ============================================================ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    background-color: var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
    padding: 2rem 1.5rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* ============================================================
   BOOTSTRAP OVERRIDES
   ============================================================ */
.bg-body-custom {
    background-color: var(--bg-body) !important;
}
.bg-card-custom {
    background-color: var(--bg-card) !important;
    border-color: var(--border) !important;
}
.border-custom {
    border-color: var(--border) !important;
}
.text-muted-custom {
    color: var(--text-muted) !important;
}
.text-sub-custom {
    color: var(--text-sub) !important;
}
.text-brand {
    color: var(--brand) !important;
}
.text-green {
    color: var(--green) !important;
}
.text-red {
    color: var(--red) !important;
}

/* ============================================================
   GLASS CARD
   ============================================================ */
.glass-card {
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(12px) saturate(180%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: transform 0.25s ease, box-shadow 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}
.glass-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar-custom {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.75rem 1.5rem;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.brand-icon {
    width: 44px;
    height: 44px;
    background: var(--brand-bg);
    border: 1px solid rgba(59, 130, 246, 0.25);
    color: var(--brand);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0;
    line-height: 1.2;
}

.brand-subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Connection badge */
.connection-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.3);
    padding: 0.4rem 0.85rem;
    border-radius: 100px;
    border: 1px solid var(--border);
    transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.dot.offline {
    background: var(--red);
    box-shadow: 0 0 10px var(--red);
}
.dot.online {
    background: var(--green);
    box-shadow: 0 0 10px var(--green);
}
.dot.loading {
    background: var(--amber);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Dark mode toggle */
.btn-dark-mode {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 0.4rem 0.8rem;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s, border-color 0.2s;
    color: var(--text-main);
    line-height: 1;
}
.btn-dark-mode:hover {
    background: var(--bg-card-hover);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Arm button */
.toggle-arm-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1.3rem;
    border-radius: 100px;
    font-size: 0.82rem;
    font-weight: 700;
    border: 1px solid;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent;
}
.toggle-arm-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.toggle-arm-btn.is-off,
.toggle-arm-btn.disarmed {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border);
    color: var(--text-muted);
}
.toggle-arm-btn.is-off:hover:not(:disabled),
.toggle-arm-btn.disarmed:hover:not(:disabled) {
    background: var(--brand-bg);
    border-color: var(--brand);
    color: var(--brand);
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.25);
}
.toggle-arm-btn.is-on,
.toggle-arm-btn.armed {
    background: linear-gradient(135deg, hsl(150, 75%, 35%), hsl(150, 85%, 25%));
    border-color: hsl(150, 70%, 45%);
    color: #ffffff;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.35);
}
.toggle-arm-btn.is-on:hover:not(:disabled),
.toggle-arm-btn.armed:hover:not(:disabled) {
    background: linear-gradient(135deg, hsl(150, 75%, 42%), hsl(150, 85%, 32%));
    box-shadow: 0 0 25px rgba(16, 185, 129, 0.6);
}

/* ============================================================
   HERO STATUS CARD
   ============================================================ */
.hero-status-card {
    padding: 1.75rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.hero-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-sub);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero-state {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.hero-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
}

.hero-status-card.is-on,
.hero-status-card.armed {
    border-color: rgba(16, 185, 129, 0.4);
    background: linear-gradient(180deg, rgba(16, 185, 129, 0.09) 0%, var(--bg-card) 100%);
}
.hero-status-card.is-on .hero-state,
.hero-status-card.armed .hero-state {
    color: var(--green);
}

.hero-status-card.danger-mode {
    border-color: rgba(239, 68, 68, 0.5);
    background: linear-gradient(180deg, rgba(239, 68, 68, 0.14) 0%, var(--bg-card) 100%);
    animation: alertPulse 1.6s infinite alternate;
}
.hero-status-card.danger-mode .hero-state {
    color: var(--red);
}

@keyframes alertPulse {
    0% { box-shadow: 0 0 0 rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 30px rgba(239, 68, 68, 0.25); }
}

/* ============================================================
   HARDWARE CARDS
   ============================================================ */
.hw-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: background 0.2s, border-color 0.2s, transform 0.2s;
}
.hw-card:hover {
    background: var(--bg-card-hover);
    transform: translateX(4px);
}

.hw-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: background 0.3s ease, color 0.3s ease;
}

.hw-details {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.hw-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.hw-value {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--green);
    transition: color 0.3s ease;
}

.hw-card.danger .hw-icon {
    background: var(--red-bg);
    color: var(--red);
}
.hw-card.danger .hw-value {
    color: var(--red);
}

/* Engine Cut-Off Remote Button */
.btn-engine-cutoff {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(239, 68, 68, 0.4);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.05));
    color: var(--red);
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.15);
}
.btn-engine-cutoff:hover {
    background: var(--red);
    color: #ffffff;
    box-shadow: 0 0 25px rgba(239, 68, 68, 0.5);
    transform: translateY(-2px);
}
.btn-engine-cutoff.is-cut {
    border-color: rgba(16, 185, 129, 0.4);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(16, 185, 129, 0.08));
    color: var(--green);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.2);
}
.btn-engine-cutoff.is-cut:hover {
    background: var(--green);
    color: #ffffff;
    box-shadow: 0 0 25px rgba(16, 185, 129, 0.6);
}

/* ============================================================
   MINI LOG
   ============================================================ */
.mini-log-card {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
}

.log-time {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--text-sub);
}

.mini-log-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-height: 110px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.mini-log-list::-webkit-scrollbar {
    width: 4px;
}
.mini-log-list::-webkit-scrollbar-track {
    background: transparent;
}
.mini-log-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

.log-entry {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
    padding: 0.2rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    transition: border-color 0.3s ease;
}
.log-entry:last-child {
    border-bottom: 0;
}
.log-entry.info .log-msg { color: var(--text-muted); }
.log-entry.success .log-msg { color: var(--green); }
.log-entry.warning .log-msg { color: var(--amber); }
.log-entry.danger .log-msg { color: var(--red); font-weight: 600; }

/* ============================================================
   MAP CARD
   ============================================================ */
.map-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 520px;
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 0.5rem;
    transition: border-color 0.3s ease;
}

.map-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.88rem;
    font-weight: 700;
}
.map-title svg {
    color: var(--brand);
    flex-shrink: 0;
}

.map-badges {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.speed-badge {
    background: var(--brand-bg);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--brand);
    font-family: var(--mono);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.35rem 0.75rem;
    border-radius: 100px;
    transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.coords-badge {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.3);
    padding: 0.35rem 0.75rem;
    border-radius: 100px;
    border: 1px solid var(--border);
    transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.location-address-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border);
    padding: 0.6rem 1.25rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: background 0.3s ease, border-color 0.3s ease;
}
.location-address-bar svg {
    color: var(--brand);
    flex-shrink: 0;
}
.location-address-bar span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#map-container {
    flex: 1;
    width: 100%;
    background: #0d1117;
    min-height: 480px;
}

/* Custom Glowing Pulse Vehicle Marker */
.custom-pulse-marker {
    position: relative;
    width: 36px;
    height: 36px;
}
.pulse-ring {
    position: absolute;
    top: -6px;
    left: -6px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid hsl(200, 90%, 55%);
    box-shadow: 0 0 15px hsl(200, 90%, 55%);
    animation: markerPulse 1.8s ease-out infinite;
}
.marker-core {
    position: absolute;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, hsl(200, 90%, 55%), hsl(220, 90%, 45%));
    border: 2px solid #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}
@keyframes markerPulse {
    0% { transform: scale(0.6); opacity: 1; }
    100% { transform: scale(1.6); opacity: 0; }
}

.btn-map-control {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border);
    color: var(--text-main);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.3rem 0.75rem;
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-map-control:hover {
    background: var(--brand-bg);
    border-color: var(--brand);
    color: var(--brand);
}

/* ============================================================
   ALERT OVERLAY
   ============================================================ */
.alert-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}
.alert-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.alert-modal {
    background: var(--bg-card);
    border: 1px solid rgba(239, 68, 68, 0.4);
    padding: 2.5rem 2rem;
    border-radius: var(--radius-lg);
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 24px 60px rgba(239, 68, 68, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    transition: background 0.3s ease, border-color 0.3s ease;
}
.alert-icon-wrap {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: var(--red-bg);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--red);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 1s infinite alternate;
}
.alert-modal h2 {
    color: var(--red);
    font-size: 1.3rem;
    font-weight: 800;
    margin: 0;
}
.alert-modal p {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
}
.alert-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
    width: 100%;
}
.btn-secondary, .btn-danger {
    flex: 1;
    padding: 0.75rem;
    border-radius: 100px;
    font-size: 0.82rem;
    font-weight: 700;
    border: 1px solid;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border);
    color: var(--text-main);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}
.btn-danger {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
}
.btn-danger:hover {
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 992px) {
    .map-card {
        min-height: 400px;
    }
    #map-container {
        min-height: 350px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 1rem 0.75rem;
    }
    .brand-subtitle {
        display: none;
    }
    .coords-badge {
        display: none;
    }
    .toggle-arm-btn span {
        display: none;
    }
    .toggle-arm-btn {
        padding: 0.5rem 0.9rem;
    }
    .alert-modal {
        padding: 1.75rem 1.25rem;
    }
    .map-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    .map-badges {
        justify-content: flex-start;
    }
}

@media (max-width: 480px) {
    .connection-badge {
        font-size: 0.65rem;
        padding: 0.25rem 0.6rem;
    }
    .hero-state {
        font-size: 1.1rem;
    }
    .hw-card {
        padding: 0.75rem 1rem;
    }
    .speed-badge {
        font-size: 0.65rem;
        padding: 0.2rem 0.5rem;
    }
}

/* ============================================================
   UTILITY
   ============================================================ */
.mono {
    font-family: var(--mono);
}
.transition-all {
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.shadow-glow {
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.06);
}

/* ============================================================
   APP SHELL LAYOUT (HYBRID MOBILE & DESKTOP)
   ============================================================ */
body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden; /* Mencegah scroll di body */
}

.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    background: var(--bg-body);
}

/* TOP APP BAR */
.top-app-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
}
.brand-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--brand-bg);
    color: var(--brand);
    border-radius: 10px;
}
.brand-text {
    display: flex;
    flex-direction: column;
}
.brand-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
    color: var(--text-main);
}
.brand-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.btn-icon {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    color: var(--text-main);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
}
body.light-mode .btn-icon {
    background: rgba(0,0,0,0.05);
}

/* MAIN CONTENT (Tabs) */
.app-content {
    flex: 1;
    position: relative;
    display: flex;
    overflow: hidden;
}

.tab-pane {
    display: none; /* Hide default */
    width: 100%;
    height: 100%;
    overflow-y: auto; /* Allow scroll if content is long */
    animation: fadeIn 0.3s ease-out;
}
.tab-pane.active {
    display: block; /* Show active */
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* TAB 1: MAP WRAPPER */
.map-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}
#map-container {
    flex: 1;
    width: 100%;
}
.map-hud {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: space-between;
    z-index: 400; /* Leaflet uses 400 */
    pointer-events: none; /* Klik tembus ke peta */
}
.hud-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    pointer-events: auto; /* Bisa diklik/hover jika perlu */
}
.map-address-bar {
    position: absolute;
    top: 50px;
    left: 10px;
    right: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 400;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.map-controls {
    position: absolute;
    bottom: 20px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 400;
}
.btn-map-fab {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    cursor: pointer;
}

/* FAB ENGINE CUT-OFF */
.fab-engine-cut {
    position: absolute;
    bottom: 20px;
    left: 10px;
    background: var(--bg-card);
    border: 1px solid var(--red);
    color: var(--red);
    padding: 10px 16px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    z-index: 400;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    transition: all 0.3s;
}
.fab-engine-cut.is-cut {
    background: var(--red);
    color: white;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.6);
}

/* BOTTOM NAVBAR (MOBILE ONLY) */
.bottom-navbar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 8px 0;
    padding-bottom: calc(8px + env(safe-area-inset-bottom)); /* Untuk iPhone Home Indicator */
    z-index: 1000;
}
.bottom-navbar .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 33%;
}
.bottom-navbar .nav-item .nav-icon {
    font-size: 1.4rem;
    margin-bottom: 2px;
    transition: transform 0.2s;
}
.bottom-navbar .nav-item.active {
    color: var(--brand);
}
.bottom-navbar .nav-item.active .nav-icon {
    transform: translateY(-2px);
    filter: drop-shadow(0 0 8px var(--brand-bg));
}

/* SIDEBAR (DESKTOP ONLY) */
.desktop-sidebar {
    display: none; /* Hide default */
    width: 280px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    flex-direction: column;
    justify-content: space-between;
}
.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 12px;
}
.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 16px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}
.sidebar-nav .nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-main);
}
.sidebar-nav .nav-item.active {
    background: var(--brand-bg);
    color: var(--brand);
    border: 1px solid hsla(200, 80%, 55%, 0.2);
}
.sidebar-footer {
    padding: 16px;
}

/* RESPONSIVE LAYOUT */
@media (min-width: 768px) {
    .app-shell {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .top-app-bar {
        width: 100%;
    }
    .bottom-navbar {
        display: none; /* Hide Bottom Nav on Desktop */
    }
    .desktop-sidebar {
        display: flex; /* Show Sidebar on Desktop */
    }
    .app-content {
        height: calc(100vh - 57px); /* Kurangi tinggi header */
    }
    .status-container, .history-container {
        max-width: 600px;
        margin: 0 auto;
    }
}

/* ============================================================
   VIBRATION LEVEL BADGE (3 STATE: normal / small / large)
   ============================================================ */
.hw-card {
    flex-wrap: wrap; /* Allow badge wrap on small screens */
}

.hw-badge-wrap {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-shrink: 0;
}

.vib-level-badge {
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    padding: 4px 10px;
    border-radius: 100px;
    border: 1px solid transparent;
    text-transform: uppercase;
    transition: all 0.3s ease;
    white-space: nowrap;
}

/* State 1: Normal — hijau samar */
.vib-level-badge.vib-none {
    color: var(--green);
    background: hsla(150, 70%, 45%, 0.12);
    border-color: hsla(150, 70%, 45%, 0.25);
}

/* State 2: Getaran Kecil — kuning/amber */
.vib-level-badge.vib-small {
    color: var(--amber);
    background: hsla(40, 90%, 55%, 0.15);
    border-color: hsla(40, 90%, 55%, 0.35);
    animation: vibSmallPulse 1s ease-in-out 3; /* Berkedip 3x lalu berhenti */
}

@keyframes vibSmallPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* State 3: Getaran Besar — merah berkedip terus */
.vib-level-badge.vib-large {
    color: #ffffff;
    background: var(--red);
    border-color: var(--red);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
    animation: vibLargePulse 0.7s ease-in-out infinite;
}

@keyframes vibLargePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.05); box-shadow: 0 0 18px rgba(239, 68, 68, 0.85); }
}

/* Warning border pada hw-card (getaran kecil) */
.hw-card.warning-border {
    border-color: hsla(40, 90%, 55%, 0.55) !important;
    box-shadow: 0 0 12px hsla(40, 90%, 55%, 0.15);
}
.hw-card.warning-border .hw-icon {
    background: hsla(40, 90%, 55%, 0.12);
    color: var(--amber);
}
.hw-card.warning-border .hw-value {
    color: var(--amber);
}

/* Border hijau pada hw-card (GPS terkunci / alat online) */
.hw-card.success-border {
    border-color: rgba(16, 185, 129, 0.5) !important;
}
.hw-card.success-border .hw-value {
    color: var(--green);
}

.btn-engine-cutoff:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ============================================================
   INCIDENT MARKER (Merah — Lokasi Kejadian Getaran Besar)
   ============================================================ */
.incident-marker {
    position: relative;
    width: 42px;
    height: 42px;
}

.incident-ring {
    position: absolute;
    top: -8px;
    left: -8px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: 2px solid hsl(0, 85%, 58%);
    box-shadow: 0 0 18px hsl(0, 85%, 58%);
    animation: incidentPulse 1.2s ease-out infinite;
}

@keyframes incidentPulse {
    0% { transform: scale(0.5); opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; }
}

.incident-core {
    position: absolute;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, hsl(0, 85%, 55%), hsl(0, 90%, 40%));
    border: 2.5px solid #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.55);
}
/* ============================================================
   MAP LAYER SWITCHER (Google Maps Style)
   ============================================================ */
.map-layer-wrapper {
    position: absolute;
    top: 75px; /* Di bawah HUD info koordinat */
    right: 12px;
    z-index: 800;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.btn-layer-toggle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(30, 41, 59, 0.9);
    backdrop-filter: blur(12px) saturate(180%);
    border: 1.5px solid rgba(148, 163, 184, 0.25);
    color: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

.btn-layer-toggle:hover {
    background: var(--color-primary);
    color: #0f172a;
    border-color: var(--color-primary);
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.55);
    transform: scale(1.05);
}

.map-layer-switcher {
    display: flex;
    flex-direction: row;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transform: scale(0.85) translateY(-10px);
    transform-origin: top right;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Munculkan saat Wrapper di-hover (desktop) ATAU saat active (mobile/klik) */
.map-layer-wrapper:hover .map-layer-switcher,
.map-layer-wrapper.active .map-layer-switcher {
    opacity: 1;
    pointer-events: all;
    transform: scale(1) translateY(0);
}

.layer-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: 2px solid transparent;
    border-radius: 10px;
    padding: 4px 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.layer-btn:hover .layer-thumb {
    transform: scale(1.08);
    box-shadow: 0 4px 14px rgba(6, 182, 212, 0.35);
}

.layer-btn.active {
    border-color: var(--color-primary);
}

.layer-btn.active .layer-label {
    color: var(--color-primary);
    font-weight: 700;
}

.layer-thumb {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background-size: cover;
    background-position: center;
    border: 2px solid rgba(255, 255, 255, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.layer-thumb-satellite {
    background: linear-gradient(135deg, #1a3a1a 0%, #2d5a2d 25%, #4a7c59 40%, #2d5a2d 55%, #1a2e1a 70%, #0d1f0d 100%);
}

.layer-thumb-dark {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
}

.layer-thumb-street {
    background: linear-gradient(135deg, #e8e0d8 0%, #f5f0eb 50%, #e8e0d8 100%);
}

.layer-thumb-terrain {
    background: linear-gradient(135deg, #c8e6a0 0%, #8bc34a 35%, #558b2f 50%, #795548 65%, #9e9e9e 80%, #bdbdbd 100%);
}

.layer-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: #94a3b8;
    letter-spacing: 0.02em;
    white-space: nowrap;
    transition: color 0.2s ease;
}

@media (max-width: 768px) {
    .map-layer-wrapper {
        top: auto;
        bottom: 80px; /* di atas bottom-navbar */
        right: 12px;
        align-items: flex-end;
    }
    
    .map-layer-switcher {
        transform-origin: bottom right;
        transform: scale(0.85) translateY(10px);
    }
    
    .map-layer-wrapper:hover .map-layer-switcher,
    .map-layer-wrapper.active .map-layer-switcher {
        transform: scale(1) translateY(0);
    }
    
    .layer-thumb {
        width: 42px;
        height: 42px;
    }
    .layer-label {
        font-size: 0.6rem;
    }
}

/* ============================================================
   TOAST NOTIFICATION (Google Maps / Premium Style)
   ============================================================ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 350px;
    width: 100%;
    pointer-events: none;
}

.toast-card {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(16px) saturate(180%);
    border-left: 4px solid var(--red);
    border-top: 1.5px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1.5px solid rgba(255, 255, 255, 0.1);
    border-right: 1.5px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 14px 16px;
    color: #f8fafc;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    pointer-events: all;
    transform: translateX(120%);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast-card.show {
    transform: translateX(0);
}

.toast-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    animation: alarmBeepGlow 1s infinite alternate;
}

@keyframes alarmBeepGlow {
    0% { transform: scale(1); }
    100% { transform: scale(1.15); filter: drop-shadow(0 0 4px var(--red)); }
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 800;
    font-size: 0.88rem;
    margin-bottom: 2px;
    color: #f8fafc;
    letter-spacing: -0.01em;
}

.toast-body {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.35;
}

.toast-close {
    background: transparent;
    border: none;
    color: var(--text-sub);
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0 4px;
    transition: color 0.2s ease;
}
.toast-close:hover {
    color: var(--red);
}

@media (max-width: 768px) {
    .toast-container {
        top: 70px; /* Di bawah header top-bar */
        right: 12px;
        left: 12px;
        max-width: none;
        width: calc(100% - 24px);
    }
}

/* ============================================================
   HISTORY MODE BUTTON
   ============================================================ */
.btn-back-live {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(6, 182, 212, 0.4);
    color: #06b6d4;
    padding: 10px 20px;
    border-radius: 30px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-back-live:hover {
    background: #06b6d4;
    color: #0f172a;
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.5);
    transform: translateX(-50%) translateY(-2px);
}

.live-indicator {
    animation: alarmBeepGlow 1.5s infinite alternate;
    font-size: 1rem;
}

/* ============================================================
   HISTORY TAB CYBER-DARK UI REDESIGN
   ============================================================ */
.history-cyber-card {
    border: 1px solid rgba(6, 182, 212, 0.2);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 1px 10px rgba(6, 182, 212, 0.05);
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.8) 0%, rgba(30, 41, 59, 0.6) 100%);
    backdrop-filter: blur(16px);
}

.cyber-icon-box {
    background: rgba(6, 182, 212, 0.15);
    color: #06b6d4;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(6, 182, 212, 0.3);
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.2);
}

.cyber-title {
    color: #e2e8f0;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.cyber-desc {
    color: #94a3b8;
    font-size: 0.95rem;
    line-height: 1.5;
}

.cyber-label {
    color: #cbd5e1;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Custom Date Picker */
.cyber-input-wrapper {
    position: relative;
    width: 100%;
}

.cyber-date-picker {
    background: rgba(15, 23, 42, 0.7) !important;
    color: #e2e8f0 !important;
    border: 1px solid rgba(148, 163, 184, 0.2) !important;
    padding: 14px 16px !important;
    border-radius: 12px !important;
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s ease;
    color-scheme: dark; /* Bikin icon kalender browser jadi putih/terang otomatis */
}

.cyber-date-picker:focus,
.cyber-date-picker:hover {
    outline: none;
    border-color: #06b6d4 !important;
    box-shadow: 0 0 0 4px rgba(6, 182, 212, 0.15) !important;
    background: rgba(15, 23, 42, 0.9) !important;
}

/* Cyberpunk Button */
.btn-cyber-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(135deg, #0284c7 0%, #06b6d4 100%);
    border: 1px solid rgba(6, 182, 212, 0.5);
    color: #ffffff;
    font-weight: 700;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.3);
}

.btn-cyber-action::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 60%);
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.4s ease;
}

.btn-cyber-action:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 25px rgba(6, 182, 212, 0.5);
    color: #ffffff;
}

.btn-cyber-action:hover::before {
    opacity: 1;
    transform: scale(1);
}

.btn-cyber-action:active {
    transform: translateY(1px);
    box-shadow: 0 2px 10px rgba(6, 182, 212, 0.3);
}

/* ============================================================
   HISTORY REDESIGN LAYOUT & STATS (V4)
   ============================================================ */

.history-header {
    margin-bottom: 2rem;
}

.history-main-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.5px;
    margin-bottom: 0.25rem;
}

.history-sub-title {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.history-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 992px) {
    .history-grid {
        grid-template-columns: 350px 1fr;
        gap: 2rem;
    }
}

/* Panel Kanan: Statistik */
.panel-stats {
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.panel-stats.show {
    opacity: 1 !important;
    pointer-events: auto !important;
}

.stat-icon-main {
    background: hsla(280, 70%, 55%, 0.15) !important;
    color: hsl(280, 70%, 65%) !important;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.stat-mini-card {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.stat-mini-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.15);
}

.stat-icon {
    font-size: 1.5rem;
}

.stat-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-main);
    font-family: var(--mono);
}

.text-cyan { color: #06b6d4; }
.text-green { color: #10b981; }
.text-amber { color: #f59e0b; }
.text-red { color: #ef4444; }
