/* =====================================================================
   SISTEM ABSENSI IOT - DESIGN SYSTEM
   Palet: Navy (#101828) + Indigo (#4F46E5) + Neutral (#F7F8FA)
   Tipografi: Sora (heading) / Inter (body) / JetBrains Mono (data teknis)
   ===================================================================== */

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

:root {
    --navy-900: #101828;
    --navy-800: #1D2939;
    --navy-700: #344054;
    --indigo-600: #4F46E5;
    --indigo-500: #6366F1;
    --indigo-50: #EEF2FF;
    --bg: #F7F8FA;
    --surface: #FFFFFF;
    --border: #E4E7EC;
    --text-primary: #1E2330;
    --text-secondary: #667085;
    --success: #16A34A;
    --success-bg: #ECFDF3;
    --danger: #DC2626;
    --danger-bg: #FEF3F2;
    --warning: #D97706;
    --warning-bg: #FFFAEB;
    --radius: 10px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
}

h1, h2, h3, h4, .font-display {
    font-family: 'Sora', sans-serif;
    font-weight: 700;
    color: var(--navy-900);
    letter-spacing: -0.01em;
}

.mono, .uid-tag, .code-tag {
    font-family: 'JetBrains Mono', monospace;
}

a { color: var(--indigo-600); text-decoration: none; }

/* =========================== LAYOUT SHELL =========================== */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--navy-900);
    color: #E4E7EC;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand img { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; }
.sidebar-brand-logo-placeholder {
    width: 36px; height: 36px; border-radius: 8px;
    background: var(--indigo-600); display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-family: 'Sora', sans-serif;
}
.sidebar-brand-text { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 14px; color: #fff; line-height: 1.3; }
.sidebar-brand-text small { display: block; font-weight: 400; color: #94A3B8; font-size: 11px; }

.sidebar-nav { flex: 1; padding: 16px 12px; }
.sidebar-section-title {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
    color: #64748B; padding: 16px 12px 6px;
}
.sidebar-link {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 8px; color: #CBD5E1;
    font-size: 13.5px; font-weight: 500; margin-bottom: 2px;
    transition: background 0.15s, color 0.15s;
}
.sidebar-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-link.active { background: var(--indigo-600); color: #fff; }
.sidebar-link .icon { width: 18px; text-align: center; flex-shrink: 0; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-user { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sidebar-user-avatar {
    width: 34px; height: 34px; border-radius: 50%; background: var(--indigo-500);
    display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; font-size: 13px;
}
.sidebar-user-name { font-size: 13px; font-weight: 600; color: #fff; }
.sidebar-user-role { font-size: 11px; color: #94A3B8; text-transform: capitalize; }
.sidebar-logout {
    display: block; text-align: center; font-size: 12.5px; padding: 8px;
    border-radius: 8px; border: 1px solid rgba(255,255,255,0.12); color: #CBD5E1;
}
.sidebar-logout:hover { background: rgba(255,255,255,0.06); color: #fff; }

.main-content { flex: 1; margin-left: 260px; display: flex; flex-direction: column; min-height: 100vh; }

/* =========================== TOPBAR =========================== */
.topbar {
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 16px 28px; display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 18px; color: var(--navy-900); }
.topbar-right { display: flex; align-items: center; gap: 18px; }

/* Signature element: device status "LED" indicator */
.device-status-pill {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 14px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
    background: var(--bg); border: 1px solid var(--border);
}
.led-dot { width: 9px; height: 9px; border-radius: 50%; position: relative; flex-shrink: 0; }
.led-dot.online { background: var(--success); box-shadow: 0 0 0 rgba(22,163,74,0.5); animation: pulse-green 1.8s infinite; }
.led-dot.offline { background: var(--danger); }
@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(22,163,74,0.5); }
    70% { box-shadow: 0 0 0 7px rgba(22,163,74,0); }
    100% { box-shadow: 0 0 0 0 rgba(22,163,74,0); }
}

.theme-toggle {
    width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface); cursor: pointer; display: flex; align-items: center; justify-content: center;
}

.page-body { padding: 28px; flex: 1; }

/* =========================== CARDS / WIDGETS =========================== */
.grid { display: grid; gap: 20px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; box-shadow: var(--shadow-sm);
}
.card-title { font-size: 13px; color: var(--text-secondary); font-weight: 600; margin-bottom: 6px; }
.card-value { font-family: 'Sora', sans-serif; font-size: 28px; font-weight: 700; color: var(--navy-900); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-header h3 { font-size: 15px; }

.stat-icon {
    width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
    background: var(--indigo-50); color: var(--indigo-600); font-size: 18px; margin-bottom: 12px;
}

/* =========================== BUTTONS =========================== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px; border-radius: 8px; font-size: 13.5px; font-weight: 600;
    border: 1px solid transparent; cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.btn-primary { background: var(--indigo-600); color: #fff; }
.btn-primary:hover { background: #4338CA; }
.btn-outline { background: var(--surface); border-color: var(--border); color: var(--text-primary); }
.btn-outline:hover { background: var(--bg); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-outline { background: var(--danger-bg); color: var(--danger); border-color: #FDA29B; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-mode {
    padding: 14px 20px; border-radius: 12px; border: 2px solid var(--border);
    background: var(--surface); font-weight: 600; font-size: 14px; cursor: pointer;
    display: flex; align-items: center; gap: 10px; transition: all 0.15s;
}
.btn-mode.active { border-color: var(--indigo-600); background: var(--indigo-50); color: var(--indigo-600); }

/* =========================== TABLES =========================== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
    text-align: left; padding: 10px 14px; background: var(--bg); color: var(--text-secondary);
    font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em;
    border-bottom: 1px solid var(--border);
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
tbody tr:hover { background: #FAFBFC; }
tbody tr:last-child td { border-bottom: none; }

.uid-tag {
    display: inline-block; background: var(--navy-900); color: #A5B4FC;
    padding: 3px 8px; border-radius: 5px; font-size: 11.5px; font-weight: 500;
}

/* =========================== BADGES =========================== */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-neutral { background: var(--bg); color: var(--text-secondary); border: 1px solid var(--border); }

/* =========================== FORMS =========================== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--navy-800); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
    font-family: inherit; font-size: 13.5px; background: var(--surface); color: var(--text-primary);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--indigo-500); box-shadow: 0 0 0 3px var(--indigo-50);
}
.form-group input:disabled { background: var(--bg); color: var(--text-secondary); cursor: not-allowed; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* =========================== ALERTS =========================== */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; font-weight: 500; }
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #FDA29B; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #A6F4C5; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #FEC84B; }

/* =========================== MODAL =========================== */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(16,24,40,0.5); display: none;
    align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal-box {
    background: var(--surface); border-radius: var(--radius); padding: 24px;
    width: 100%; max-width: 460px; box-shadow: var(--shadow-md); max-height: 90vh; overflow-y: auto;
}
.modal-box.modal-wide { max-width: 640px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-close { cursor: pointer; font-size: 20px; color: var(--text-secondary); background: none; border: none; }

/* =========================== TABS =========================== */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-item {
    padding: 10px 16px; font-size: 13.5px; font-weight: 600; color: var(--text-secondary);
    cursor: pointer; border-bottom: 2px solid transparent;
}
.tab-item.active { color: var(--indigo-600); border-color: var(--indigo-600); }

/* =========================== MISC =========================== */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-secondary); }
.flex { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-16 { margin-top: 16px; } .mb-16 { margin-bottom: 16px; }
.text-secondary { color: var(--text-secondary); }
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; align-items: end; }
.filter-bar .form-group { margin-bottom: 0; min-width: 160px; }

/* =========================== DARK MODE =========================== */
body.dark {
    --bg: #0B1120;
    --surface: #151D2E;
    --border: #263143;
    --text-primary: #E4E7EC;
    --text-secondary: #94A3B8;
    --navy-900: #F1F5F9;
    --indigo-50: rgba(79,70,229,0.15);
}
body.dark .sidebar { background: #0B1120; border-right: 1px solid var(--border); }
body.dark .uid-tag { background: #263143; color: #A5B4FC; }
body.dark thead th { background: #1A2332; }
