/* =====================================================
   SMARTMOP - KOMPONEN BERSAMA
   ===================================================== */

/* ---------- Kartu ---------- */
.card {
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { font-size: 16px; color: var(--navy); }
.card-head p { color: var(--text-secondary); font-size: 13px; }
.link-all { color: var(--primary); font-size: 13px; font-weight: 500; text-decoration: none; }
.link-all:hover { text-decoration: underline; }

/* ---------- Lencana & tombol ---------- */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 500; }
.badge.danger { color: var(--danger); background: var(--danger-bg); }
.badge.success { color: var(--success); background: var(--success-bg); }
.badge.warning { color: var(--warning); background: var(--warning-bg); }
.badge.neutral { color: var(--text-secondary); background: #eef2f7; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 42px; padding: 0 18px;
    border: 1px solid transparent; border-radius: var(--radius-small);
    font-weight: 500;
    transition: background var(--transition), border-color var(--transition), color var(--transition), transform 0.1s ease;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { color: #fff; background: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { color: var(--success); background: var(--success-bg); border-color: #a6e2c1; }
.btn-success:hover { background: #cdf1dd; }
.btn-danger { color: var(--danger); background: var(--danger-bg); border-color: #f7b8b2; }
.btn-danger:hover { background: #fdd0cc; }
.btn-ghost { color: var(--text); background: var(--surface); border-color: var(--border-strong); }
.btn-ghost:hover { background: #f1f4f8; }

/* ---------- Progress ---------- */
.progress { height: 8px; border-radius: 99px; background: #e6ebf3; overflow: hidden; }
.progress i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--primary); transition: width 0.6s ease; }
.progress.green i { background: #16a34a; }
.progress.warn i { background: #f79009; }
.progress.low i { background: var(--danger); }

/* ---------- Form ---------- */
.field { display: grid; gap: 6px; align-content: start; }
.field > label { font-size: 13px; font-weight: 500; color: var(--navy); }
.field small { color: var(--text-secondary); font-size: 12px; }
input[type="text"], input[type="number"], input[type="date"], select {
    width: 100%; min-height: 42px; padding: 9px 12px;
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-small);
    transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(23, 105, 224, 0.16); }
select { appearance: none; padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; }

.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: none; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; z-index: 1; }
.switch-slider { position: absolute; inset: 0; border-radius: 99px; background: #cfd6e2; transition: background var(--transition); }
.switch-slider::after {
    content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
    border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform var(--transition);
}
.switch input:checked + .switch-slider { background: var(--primary); }
.switch input:checked + .switch-slider::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-slider { outline: 3px solid #a8c9ff; outline-offset: 2px; }

.seg { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 10px; background: #eef2f9; }
.seg button { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; border: 0; border-radius: 6px; background: transparent; color: var(--text-secondary); font-weight: 500; transition: background var(--transition), color var(--transition); }
.seg button:hover { color: var(--navy); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--navy); box-shadow: 0 1px 2px rgba(20, 38, 63, 0.12); }

/* ---------- Tabel ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-small); }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th { padding: 12px 14px; background: #f6f8fb; color: var(--text-secondary); font-size: 13px; font-weight: 500; text-align: left; }
td { padding: 10px 14px; border-top: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: var(--surface-light); }
.empty { padding: 36px 16px; text-align: center; color: var(--text-secondary); }

/* ---------- Tampilan kamera (simulasi lantai + bounding box) ---------- */
.feed {
    position: relative; aspect-ratio: 4 / 3; overflow: hidden; /* ESP32-CAM sends VGA 640x480 */
    border-radius: 10px; background: #141b26; isolation: isolate;
}
.feed::before {
    content: ""; position: absolute; inset: 0; z-index: -1;
    background:
        linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px) 0 0 / 100% 25%,
        linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px) 0 0 / 25% 100%;
}
.feed img.stream { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -1; }
.feed.live .spill, .feed.live .bbox { display: none; }
.spill {
    position: absolute; left: 22%; top: 38%; width: 50%; height: 28%;
    border-radius: 58% 42% 55% 45% / 52% 58% 42% 48%;
    background: radial-gradient(circle at 38% 38%, #f0a63a, #c26a1c 70%, #a8530f);
    box-shadow: 0 2px 8px rgba(120, 60, 10, 0.4);
    transform: rotate(-6deg);
}
.bbox { position: absolute; left: 18%; top: 31%; width: 58%; height: 42%; border: 2px solid #e5261b; }
.bbox em {
    position: absolute; left: -2px; bottom: 100%; padding: 2px 10px; white-space: nowrap;
    background: #e5261b; color: #fff; font-style: normal; font-size: 12.5px; font-weight: 600;
}
.feed.sm .bbox { border-width: 1.5px; }
.feed.sm .bbox em { display: none; }
.feed.mop { background: #1e2530; }
.feed.mop::before { background: linear-gradient(180deg, #2c3441, #151a22); }
.feed.mop .pad {
    position: absolute; bottom: 12%; width: 34%; aspect-ratio: 1; border-radius: 50%;
    background: repeating-radial-gradient(circle, #2f5fd0 0 5px, #3d72ec 5px 10px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.5);
}
.feed.mop .pad:nth-child(1) { left: 12%; }
.feed.mop .pad:nth-child(2) { right: 12%; }
.camera-placeholder, .feed > #cameraPlaceholder {
    position: absolute; inset: 0; z-index: 2; display: grid; place-items: center;
    padding: 24px; background: #141b26; color: #9fb0c8; text-align: center; font-size: 13px;
}
/* fill, not contain: YOLO boxes are normalised to the full frame */
.camera-snapshot { position: absolute; inset: 0; z-index: 3; width: 100%; height: 100%; object-fit: fill; }
#cameraBoxOverlay { z-index: 4; }
.feed-time {
    position: absolute; top: 12px; right: 12px; padding: 3px 10px;
    border-radius: 6px; background: rgba(15, 25, 45, 0.72); color: #fff;
    font-size: 13px; font-variant-numeric: tabular-nums;
}
.feed.thumb { width: 84px; aspect-ratio: 4 / 3; border-radius: 6px; }
.feed.thumb .bbox { border-width: 1.5px; }
.feed.thumb .bbox em { display: none; }

.cam-tools {
    position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
    display: flex; gap: 4px; padding: 8px;
    border-radius: 12px; background: rgba(15, 25, 45, 0.8);
}
.cam-tools button {
    min-width: 64px; display: grid; justify-items: center; gap: 2px; padding: 6px 8px;
    border: 0; border-radius: 8px; background: transparent; color: #fff; font-size: 12px;
}
.cam-tools button:hover { background: rgba(255, 255, 255, 0.14); }
.cam-tools button[aria-pressed="true"] { background: var(--danger); }
.cam-tools .ico { width: 22px; height: 22px; }
.cam-tools .hd-tag { font-weight: 800; font-size: 13px; padding: 1px 4px; border: 1.5px solid #fff; border-radius: 4px; line-height: 1.3; }

/* ---------- Toast ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 10px; }
.toast {
    max-width: 360px; padding: 12px 16px; border-radius: 10px;
    background: var(--navy); color: #fff; font-weight: 500;
    box-shadow: 0 8px 24px rgba(20, 38, 63, 0.18);
    animation: toast-in 0.25s ease;
}
.toast.success { background: #0f6d3e; }
.toast.warn { background: #8a4a0a; }
.toast.error { background: #b42318; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } .progress i { transition: none; } .btn:active { transform: none; } }
