/* ==========================================================================
   SMART BIN DASHBOARD — Compact Responsive Design v2
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

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

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #f4f6f9;
    color: #1e293b;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* === Top Bar === */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    background: #047857;
    color: white;
    height: 48px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.topbar-left i { font-size: 18px; }
.topbar-title { font-size: 15px; font-weight: 700; letter-spacing: -0.3px; }

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    opacity: 0.9;
}

.topbar-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.topbar-dot.active  { background: #86efac; box-shadow: 0 0 6px #86efac; }
.topbar-dot.waiting  { background: #fbbf24; }
.topbar-dot.error    { background: #fca5a5; }

.btn-sim {
    padding: 5px 14px;
    font-size: 11px;
    font-weight: 700;
    border: 1.5px solid rgba(255,255,255,0.5);
    border-radius: 6px;
    background: transparent;
    color: white;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    transition: all 0.2s ease;
}
.btn-sim:hover { background: rgba(255,255,255,0.15); border-color: white; }
.btn-sim.sim-active { background: rgba(255,255,255,0.2); border-color: #86efac; color: #86efac; }

/* === Main Grid === */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr 1fr;
    gap: 12px;
    padding: 12px 16px;
    height: calc(100vh - 48px);
    overflow: hidden;
}

/* === Stat Cards === */
.stats-row {
    grid-column: 1 / -1;
    display: flex;
    gap: 12px;
}

.stat-card {
    flex: 1;
    background: white;
    border-radius: 10px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    min-height: 62px;
}

.stat-icon-box {
    width: 38px; height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: white;
    flex-shrink: 0;
}

.stat-info { flex: 1; }
.stat-value { font-size: 22px; font-weight: 800; letter-spacing: -0.8px; line-height: 1.1; display: block; }
.stat-label { font-size: 10px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.8px; font-weight: 600; }

/* === Panel === */
.panel {
    background: white;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
}

.panel-title {
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 8px;
}
.panel-title i { color: #047857; font-size: 14px; }

.panel-body {
    flex: 1;
    overflow: hidden;
    padding: 10px 12px;
}

/* === Gauges === */
.gauges-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    height: 100%;
}

/* === Charts === */
.charts-row {
    display: flex;
    gap: 8px;
    height: 100%;
}
.charts-row > div { flex: 1; min-width: 0; }

/* === History Table === */
.panel-body-table {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.table-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}
.table-scroll::-webkit-scrollbar { width: 4px; }
.table-scroll::-webkit-scrollbar-track { background: #f8fafc; }
.table-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }

.history-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; }

.history-table th {
    background: #f8fafc; color: #475569;
    padding: 8px 10px; text-align: center;
    font-weight: 700; font-size: 10px;
    text-transform: uppercase; letter-spacing: 0.6px;
    position: sticky; top: 0; z-index: 1;
    border-bottom: 2px solid #e2e8f0;
}

.history-table td {
    padding: 7px 10px; text-align: center;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle; font-size: 12px;
}
.history-table tr:hover td { background: #f8fafc; }

.table-icon { width: 18px; height: 18px; object-fit: contain; vertical-align: middle; margin-right: 6px; }

.pagination-bar {
    display: flex; align-items: center; justify-content: center;
    gap: 4px; padding: 6px 0;
    border-top: 1px solid #f1f5f9; flex-shrink: 0;
}

.page-btn {
    padding: 4px 10px; font-size: 11px; font-weight: 600;
    border: 1px solid #e2e8f0; border-radius: 6px;
    background: white; color: #475569; cursor: pointer;
    font-family: 'Inter', sans-serif; transition: all 0.15s ease;
}
.page-btn:hover { background: #f1f5f9; }
.page-btn.active { background: #047857; color: white; border-color: #047857; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.page-info { font-size: 11px; color: #94a3b8; font-weight: 500; margin: 0 8px; }

/* ================================================================
   MODAL — Full height image on left
   ================================================================ */
.modal-overlay {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: m-fade 0.25s ease;
}
@keyframes m-fade { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.18);
    width: 92%;
    max-width: 860px;
    height: 600px;
    overflow: hidden;
    animation: m-slide 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: row;
}
@keyframes m-slide {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Left: image — FULL HEIGHT, no padding, image covers entire side */
.modal-img-side {
    width: 50%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.modal-img-side.bg-paper { background: linear-gradient(145deg, #dbeafe 0%, #eff6ff 100%); }
.modal-img-side.bg-metal { background: linear-gradient(145deg, #e2e8f0 0%, #f1f5f9 100%); }
.modal-img-side.bg-glass { background: linear-gradient(145deg, #d1fae5 0%, #ecfdf5 100%); }
.modal-img-side.bg-waste { background: linear-gradient(145deg, #fee2e2 0%, #fef2f2 100%); }

.modal-img-side img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Right: info */
.modal-info-side {
    width: 50%;
    padding: 40px 36px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.modal-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 12px; border-radius: 16px;
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.8px;
    margin-bottom: 20px; width: fit-content;
}
.modal-badge.badge-paper { background: #dbeafe; color: #1d4ed8; }
.modal-badge.badge-metal { background: #e2e8f0; color: #475569; }
.modal-badge.badge-glass { background: #d1fae5; color: #065f46; }
.modal-badge.badge-waste { background: #fee2e2; color: #991b1b; }

.modal-title { font-size: 26px; font-weight: 800; color: #0f172a; margin-bottom: 10px; letter-spacing: -0.5px; }
.modal-subtitle { font-size: 14px; color: #64748b; margin-bottom: 28px; line-height: 1.6; }

.modal-confidence { display: flex; align-items: center; gap: 10px; margin-bottom: 32px; }
.modal-conf-label { font-size: 12px; color: #64748b; font-weight: 600; white-space: nowrap; }
.modal-conf-bar-bg { flex: 1; height: 10px; background: #f1f5f9; border-radius: 5px; overflow: hidden; }
.modal-conf-bar { height: 100%; border-radius: 5px; transition: width 0.5s ease; }
.modal-conf-pct { font-size: 15px; font-weight: 800; color: #0f172a; min-width: 42px; text-align: right; }

.modal-question { font-size: 18px; font-weight: 700; color: #0f172a; margin-bottom: 18px; text-align: center; }

/* Auto-close countdown bar */
.modal-countdown-bar {
    width: 100%;
    height: 4px;
    background: #f1f5f9;
    border-radius: 2px;
    margin-top: 20px;
    overflow: hidden;
}
.modal-countdown-fill {
    height: 100%;
    background: linear-gradient(90deg, #047857, #10b981);
    border-radius: 2px;
    animation: countdown-shrink 5s linear forwards;
}
@keyframes countdown-shrink {
    from { width: 100%; }
    to   { width: 0%; }
}

.modal-countdown-text {
    font-size: 11px;
    color: #94a3b8;
    text-align: center;
    margin-top: 6px;
}

.modal-buttons { display: flex; gap: 14px; justify-content: center; }

.modal-btn {
    padding: 14px 40px; font-size: 15px; font-weight: 700;
    border: none; border-radius: 12px; cursor: pointer;
    font-family: 'Inter', sans-serif; transition: all 0.2s ease;
    display: flex; align-items: center; gap: 8px; color: white;
}
.modal-btn-yes {
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 4px 14px rgba(16,185,129,0.3);
}
.modal-btn-yes:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(16,185,129,0.4); }

.modal-btn-no {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 4px 14px rgba(239,68,68,0.3);
}
.modal-btn-no:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(239,68,68,0.4); }

.modal-ts { font-size: 12px; color: #94a3b8; text-align: center; margin-top: 12px; }

/* === Responsive === */
@media (max-width: 1024px) {
    .main-grid { grid-template-columns: 1fr; grid-template-rows: auto auto auto auto; overflow-y: auto; }
    .stats-row { flex-wrap: wrap; }
    .modal-card { flex-direction: column; height: auto; max-height: 90vh; }
    .modal-img-side { width: 100%; height: 280px; }
    .modal-info-side { width: 100%; }
    html, body { overflow: auto; }
}
@media (max-width: 640px) {
    .topbar { padding: 8px 12px; }
    .main-grid { padding: 8px; gap: 8px; }
    .stat-card { padding: 8px 10px; }
    .stat-value { font-size: 18px; }
}