/* =============================================
   Sistem Maklumat JR/Penghubung - Main CSS
   ============================================= */

:root {
    --primary: #1a3c6e;
    --primary-light: #2557a7;
    --primary-dark: #0f2447;
    --accent: #e8a020;
    --accent-light: #ffc94d;
    --success: #198754;
    --danger: #dc3545;
    --sidebar-w: 260px;
    --topbar-h: 64px;
    --bg: #f0f4f9;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: 0 2px 16px rgba(26,60,110,0.08);
    --shadow-md: 0 4px 24px rgba(26,60,110,0.12);
}

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

body {
    font-family: 'Plus Jakarta Sans', 'Noto Sans Malay', sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
}

/* ---- SIDEBAR ---- */
.sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-w);
    background: linear-gradient(165deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease, width 0.3s ease;
    overflow: hidden;
}
.sidebar.collapsed { transform: translateX(calc(-1 * var(--sidebar-w))); }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}
.brand-icon {
    width: 42px; height: 42px;
    background: var(--accent);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; color: white;
    flex-shrink: 0;
}
.brand-title { display: block; color: white; font-weight: 700; font-size: 0.95rem; line-height: 1.2; }
.brand-sub { display: block; color: rgba(255,255,255,0.6); font-size: 0.72rem; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-section-label {
    font-size: 0.65rem; font-weight: 700; letter-spacing: 1.5px;
    text-transform: uppercase; color: rgba(255,255,255,0.4);
    padding: 0 8px; margin-bottom: 6px;
}
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; border-radius: 8px;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 0.875rem; font-weight: 500;
    transition: all 0.2s;
    margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,0.12); color: white; }
.nav-item.active { background: rgba(255,255,255,0.18); color: white; font-weight: 600; }
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    width: 3px; height: 36px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}
.nav-item { position: relative; }
.nav-item i { font-size: 1.05rem; width: 20px; text-align: center; }

.sidebar-user {
    display: flex; align-items: center; gap: 10px;
    padding: 16px; border-top: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}
.user-avatar {
    width: 36px; height: 36px;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 1rem; flex-shrink: 0;
}
.user-info { flex: 1; overflow: hidden; }
.user-name { display: block; color: white; font-size: 0.8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; color: rgba(255,255,255,0.5); font-size: 0.68rem; }
.btn-logout {
    background: rgba(255,255,255,0.1); border: none;
    color: rgba(255,255,255,0.7); width: 32px; height: 32px;
    border-radius: 8px; cursor: pointer; transition: all 0.2s;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.btn-logout:hover { background: rgba(220,53,69,0.7); color: white; }

/* ---- MAIN CONTENT ---- */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
    display: flex; flex-direction: column;
}
.main-content.expanded { margin-left: 0; }

.top-navbar {
    height: var(--topbar-h);
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 24px; gap: 16px;
    position: sticky; top: 0; z-index: 100;
    box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}
.sidebar-toggle {
    background: none; border: 1px solid var(--border);
    width: 36px; height: 36px; border-radius: 8px;
    cursor: pointer; font-size: 1.1rem; color: var(--text-muted);
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.sidebar-toggle:hover { background: var(--bg); color: var(--primary); }
.navbar-breadcrumb { flex: 1; font-size: 0.82rem; color: var(--text-muted); }
.breadcrumb-current { color: var(--primary); font-weight: 600; }
.datetime-display { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }

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

/* ---- PAGE HEADER ---- */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px;
}
.page-title { font-size: 1.4rem; font-weight: 700; color: var(--primary); }
.page-subtitle { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; }

/* ---- CARDS ---- */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-header-custom {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--radius) var(--radius) 0 0;
}
.card-header-custom .card-title { color: white; font-weight: 600; font-size: 0.95rem; margin: 0; }
.card-header-custom .card-icon { color: rgba(255,255,255,0.7); font-size: 1.1rem; }

/* ---- STAT CARDS ---- */
.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 22px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex; align-items: center; gap: 18px;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; flex-shrink: 0;
}
.stat-icon.blue { background: #dbeafe; color: #1d4ed8; }
.stat-icon.green { background: #dcfce7; color: #16a34a; }
.stat-icon.amber { background: #fef3c7; color: #d97706; }
.stat-icon.red { background: #fee2e2; color: #dc2626; }
.stat-value { font-size: 1.8rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }

/* ---- FORM ---- */
.form-label { font-size: 0.82rem; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.form-control, .form-select {
    border: 1.5px solid var(--border);
    border-radius: 8px; font-size: 0.875rem;
    padding: 9px 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,60,110,0.1);
}
.form-control[readonly] { background: #f8fafc; color: var(--text-muted); }
.input-group .btn { border-radius: 0 8px 8px 0 !important; }

/* ---- BUTTONS ---- */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border: none; border-radius: 8px; font-weight: 600;
    padding: 9px 20px; transition: all 0.2s;
}
.btn-primary:hover { background: linear-gradient(135deg, var(--primary-dark), var(--primary)); box-shadow: 0 4px 12px rgba(26,60,110,0.25); }
.btn-warning { border-radius: 8px; font-weight: 600; }
.btn-danger { border-radius: 8px; font-weight: 600; }
.btn-secondary { border-radius: 8px; font-weight: 600; }

/* ---- TABLE ---- */
.table { font-size: 0.85rem; }
.table thead th {
    background: #f1f5f9; font-weight: 700; font-size: 0.78rem;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-muted); border-bottom: 1px solid var(--border);
    padding: 12px 14px;
}
.table tbody td { padding: 11px 14px; vertical-align: middle; border-bottom: 1px solid #f1f5f9; }
.table tbody tr:hover { background: #f8fafc; }
.table-responsive { border-radius: 0 0 var(--radius) var(--radius); }

/* ---- BADGES ---- */
.badge-status-aktif { background: #dcfce7; color: #16a34a; border: 1px solid #86efac; border-radius: 20px; padding: 3px 10px; font-size: 0.72rem; font-weight: 600; }
.badge-status-tidak { background: #fee2e2; color: #dc2626; border: 1px solid #fca5a5; border-radius: 20px; padding: 3px 10px; font-size: 0.72rem; font-weight: 600; }

/* Status Undi Badges */
.badge-putih  { background:#ffffff; color:#374151; border:1.5px solid #d1d5db; border-radius:20px; padding:3px 12px; font-size:0.72rem; font-weight:700; }
.badge-kelabu { background:#e5e7eb; color:#374151; border:1.5px solid #9ca3af; border-radius:20px; padding:3px 12px; font-size:0.72rem; font-weight:700; }
.badge-hitam  { background:#1f2937; color:#f9fafb; border:1.5px solid #111827; border-radius:20px; padding:3px 12px; font-size:0.72rem; font-weight:700; }
.badge-tdk    { background:#fef3c7; color:#92400e; border:1.5px solid #fbbf24; border-radius:20px; padding:3px 12px; font-size:0.72rem; font-weight:700; }

/* Special category badges */
.badge-kronik  { background:#fee2e2; color:#991b1b; border:1px solid #fca5a5; border-radius:6px; padding:2px 8px; font-size:0.68rem; font-weight:600; }
.badge-oku     { background:#dbeafe; color:#1e40af; border:1px solid #93c5fd; border-radius:6px; padding:2px 8px; font-size:0.68rem; font-weight:600; }
.badge-jkm     { background:#fef3c7; color:#92400e; border:1px solid #fcd34d; border-radius:6px; padding:2px 8px; font-size:0.68rem; font-weight:600; }

/* Status radio buttons */
.status-radio-group { display:flex; gap:8px; flex-wrap:wrap; }
.status-radio-group .form-check { margin:0; padding:0; }
.status-radio-group .form-check-input { display:none; }
.status-radio-group .form-check-label {
    display:inline-flex; align-items:center; gap:6px;
    padding:7px 14px; border-radius:8px; cursor:pointer;
    border:2px solid #e2e8f0; font-size:0.82rem; font-weight:600;
    transition:all 0.15s;
}
.status-radio-group .form-check-input:checked + .form-check-label { transform:scale(1.04); box-shadow:0 0 0 3px rgba(26,60,110,0.15); }
.status-putih-label  { background:#f9fafb; color:#374151; border-color:#d1d5db; }
.status-putih-label:hover, .form-check-input:checked + .status-putih-label   { background:#fff; border-color:#374151; }
.status-kelabu-label { background:#f3f4f6; color:#374151; border-color:#9ca3af; }
.status-kelabu-label:hover, .form-check-input:checked + .status-kelabu-label { background:#e5e7eb; border-color:#4b5563; }
.status-hitam-label  { background:#f9fafb; color:#374151; border-color:#d1d5db; }
.status-hitam-label:hover, .form-check-input:checked + .status-hitam-label   { background:#1f2937; color:#fff; border-color:#111827; }
.status-tdk-label    { background:#fffbeb; color:#92400e; border-color:#fbbf24; }
.status-tdk-label:hover, .form-check-input:checked + .status-tdk-label       { background:#fef3c7; border-color:#f59e0b; }

/* Special checkbox group */
.special-checkbox-group { display:flex; gap:10px; flex-wrap:wrap; margin-top:6px; }
.special-checkbox-group .form-check { padding:0; margin:0; }
.special-checkbox-group .form-check-input { display:none; }
.special-checkbox-group .form-check-label {
    display:inline-flex; align-items:center; gap:7px;
    padding:8px 14px; border-radius:8px; cursor:pointer;
    border:2px solid #e2e8f0; font-size:0.82rem; font-weight:600;
    transition:all 0.15s; background:#f8fafc; color:#475569;
}
.special-checkbox-group .form-check-input:checked + .lbl-kronik { background:#fee2e2; color:#991b1b; border-color:#f87171; }
.special-checkbox-group .form-check-input:checked + .lbl-oku    { background:#dbeafe; color:#1e40af; border-color:#60a5fa; }
.special-checkbox-group .form-check-input:checked + .lbl-jkm    { background:#fef3c7; color:#92400e; border-color:#fbbf24; }
.special-checkbox-group .form-check-label:hover { border-color:#cbd5e1; background:#f1f5f9; }

/* ---- SEARCH BOX ---- */
.search-ic-box {
    background: linear-gradient(135deg, #f0f4f9 0%, #e8f0fe 100%);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 24px;
    border: 1px solid #c7d7f5;
}
.search-ic-box .search-title { font-size: 0.85rem; font-weight: 700; color: var(--primary); margin-bottom: 12px; }

/* ---- LOGIN PAGE ---- */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    display: flex; align-items: center; justify-content: center;
    padding: 20px; position: relative; overflow: hidden;
}
.login-page::before {
    content: '';
    position: absolute; inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.login-card {
    background: white;
    border-radius: 20px;
    padding: 48px 40px;
    width: 100%; max-width: 420px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.3);
    position: relative;
}
.login-logo {
    width: 64px; height: 64px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem; color: white;
    margin: 0 auto 20px;
}
.login-title { text-align: center; color: var(--primary); font-weight: 800; font-size: 1.3rem; }
.login-subtitle { text-align: center; color: var(--text-muted); font-size: 0.82rem; margin-bottom: 32px; }
.password-toggle { cursor: pointer; background: none; border: 0; color: var(--text-muted); padding: 0 12px; }
.btn-login {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border: none; width: 100%; padding: 12px;
    border-radius: 10px; font-weight: 700;
    font-size: 0.95rem; color: white;
    transition: all 0.2s;
}
.btn-login:hover { background: linear-gradient(135deg, var(--primary-dark), var(--primary)); box-shadow: 0 8px 20px rgba(26,60,110,0.3); transform: translateY(-1px); }

/* ---- LOGOUT MODAL ---- */
.logout-icon {
    width: 60px; height: 60px; border-radius: 50%;
    background: #fee2e2; color: #dc2626;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem; margin: 0 auto;
}

/* ---- CHART PLACEHOLDER ---- */
.chart-container { position: relative; height: 240px; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(calc(-1 * var(--sidebar-w))); }
    .sidebar.mobile-open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .page-content { padding: 16px; }
    .stat-value { font-size: 1.4rem; }
}

/* ---- LOADING SPINNER ---- */
.spinner-overlay {
    position: fixed; inset: 0;
    background: rgba(255,255,255,0.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999; display: none;
}

/* ---- ALERT ---- */
.alert { border-radius: 10px; font-size: 0.875rem; }
.section-divider {
    border: 0; border-top: 2px solid var(--border);
    margin: 20px 0;
}
.form-section-title {
    font-size: 0.78rem; font-weight: 700; letter-spacing: 1px;
    text-transform: uppercase; color: var(--primary);
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 16px;
}
.form-section-title::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
}
