/* ==========================================================================
   SISTEM CARTA ORGANISASI PERKIM - GLOBAL STYLESHEET
   ========================================================================== */

/* 1. Pemalar Reka Bentuk (CSS Variables) */
:root {
    --primary-color: #0d9488;      /* Teal Premium */
    --primary-hover: #0f766e;
    --secondary-color: #4f46e5;    /* Indigo */
    --secondary-hover: #4338ca;
    --bg-dark: #0f172a;            /* Slate gelap untuk latar admin */
    --bg-light: #f8fafc;           /* Abu-abu terang untuk latar awam */
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --text-main: #1e293b;          /* Kelabu Gelap */
    --text-muted: #64748b;         /* Kelabu Sederhana */
    --success: #10b981;            /* Hijau */
    --danger: #ef4444;             /* Merah */
    --border-radius: 12px;
    --transition-speed: 0.3s;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

/* 2. Asas & Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-main);
    line-height: 1.5;
    background-color: var(--bg-light);
}

/* 3. Komponen Borang & Butang Umum */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 15px;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    outline: none;
    transition: all var(--transition-speed);
    font-family: inherit;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.form-control-file {
    display: block;
    width: 100%;
    padding: 8px 0;
}

.form-text {
    display: block;
    margin-top: 5px;
}

.muted {
    color: var(--text-muted);
}

.text-muted {
    color: var(--text-muted);
}

.text-sm {
    font-size: 13px;
}

.required {
    color: var(--danger);
}

hr {
    border: 0;
    border-top: 1px solid var(--card-border);
    margin: 20px 0;
}

/* Butang */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    padding: 10px 20px;
    font-size: 14px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all var(--transition-speed);
    text-decoration: none;
    font-family: inherit;
}

.btn-primary {
    background-color: var(--primary-color);
    color: #ffffff;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.25);
}

.btn-secondary {
    background-color: #e2e8f0;
    color: #334155;
}

.btn-secondary:hover {
    background-color: #cbd5e1;
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* Amaran / Alert */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    border-left: 4px solid transparent;
}

.alert-danger {
    background-color: #fef2f2;
    color: #991b1b;
    border-color: #ef4444;
}

.alert-success {
    background-color: #ecfdf5;
    color: #065f46;
    border-color: #10b981;
}

.alert-info {
    background-color: #eff6ff;
    color: #1e40af;
    border-color: #3b82f6;
}

/* ==========================================================================
   4. Portal Log Masuk Admin
   ========================================================================== */
.admin-login-body {
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-wrapper {
    width: 100%;
    max-width: 440px;
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    padding: 40px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.brand-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    font-size: 28px;
    font-weight: 700;
    border-radius: 50%;
    margin-bottom: 15px;
    box-shadow: 0 4px 10px rgba(13, 148, 136, 0.3);
}

.login-header h2 {
    font-size: 22px;
    color: #0f172a;
    font-weight: 600;
}

.login-header p {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 5px;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
}

.back-link {
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition-speed);
}

.back-link:hover {
    color: var(--primary-color);
}

/* ==========================================================================
   5. Dashboard Pentadbiran
   ========================================================================== */
.admin-dashboard-body {
    background-color: #0b0f19;
    color: #f8fafc;
    min-height: 100vh;
    margin: 0;
}

/* Susun Atur Wrapper Gelap (Sidebar + Content) */
.dashboard-wrapper-dark {
    display: flex;
    min-height: 100vh;
}

@media (max-width: 1024px) {
    .dashboard-wrapper-dark {
        flex-direction: column;
    }
}

/* ==========================================================================
   Bar Sisi Khas Pentadbir (Left Sidebar)
   ========================================================================== */
.sidebar-dark {
    width: 260px;
    background-color: #111827;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    padding: 25px 20px;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 99;
}

@media (max-width: 1024px) {
    .sidebar-dark {
        width: 100%;
        height: auto;
        position: relative;
        padding: 15px 20px;
    }
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 30px;
}

.logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(139, 92, 246, 0.3);
}

.logo-info {
    display: flex;
    flex-direction: column;
}

.logo-title {
    font-weight: 700;
    font-size: 16px;
    color: #ffffff;
    letter-spacing: -0.5px;
}

.logo-subtitle {
    font-size: 11px;
    color: #94a3b8;
}

/* Profil Admin di Bar Sisi */
.sidebar-profile {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 12px 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 25px;
}

.profile-avatar {
    width: 35px;
    height: 35px;
    background-color: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.profile-info {
    display: flex;
    flex-direction: column;
}

.profile-name {
    font-weight: 600;
    font-size: 13px;
    color: #ffffff;
}

.profile-role {
    font-size: 11px;
    color: #94a3b8;
}

/* Navigasi Bar Sisi */
.sidebar-nav {
    flex: 1;
}

.sidebar-nav ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover {
    background-color: rgba(255, 255, 255, 0.03);
    color: #ffffff;
}

.sidebar-nav li.active a {
    background-color: rgba(139, 92, 246, 0.08);
    color: #a78bfa;
    font-weight: 600;
    border-left: 3px solid #8b5cf6;
}

.sidebar-nav li.nav-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 8px 12px;
    padding: 0;
    pointer-events: none;
}

/* Footer Bar Sisi */
.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 15px;
}

.nav-logout-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #ef4444;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.nav-logout-btn:hover {
    background-color: rgba(239, 68, 68, 0.05);
}

/* ==========================================================================
   Kawasan Kandungan Utama Gelap (Main Content)
   ========================================================================== */
.main-content-dark {
    flex: 1;
    padding: 40px;
    background-color: #0b0f19;
    overflow-y: auto;
}

@media (max-width: 768px) {
    .main-content-dark {
        padding: 20px;
    }
}

/* Header Kandungan Utama */
.main-header-dark {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 35px;
    gap: 20px;
}

@media (max-width: 768px) {
    .main-header-dark {
        flex-direction: column;
        align-items: flex-start;
    }
}

.header-titles h1 {
    font-size: 24px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.5px;
    margin-bottom: 5px;
}

.header-titles p {
    color: #94a3b8;
    font-size: 14px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Kad Bekas & Tetapan Gelap */
.card-dark {
    background-color: #111827;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    margin-bottom: 25px;
}

.card-dark h2 {
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 20px;
}

/* Grid Grid Kandungan Utama */
.columns-grid-dark {
    display: grid;
    grid-template-columns: 2.2fr 1fr;
    gap: 25px;
    align-items: start;
}

@media (max-width: 1200px) {
    .columns-grid-dark {
        grid-template-columns: 1fr;
    }
}

.side-column-dark {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

/* ==========================================================================
   Ubah Suai Kad Metrik/Statistik Grid 4 Lajur
   ========================================================================== */
.stats-grid-dark {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

@media (max-width: 1024px) {
    .stats-grid-dark {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 580px) {
    .stats-grid-dark {
        grid-template-columns: 1fr;
    }
}

.stat-card-dark {
    background-color: #111827;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: transform 0.25s ease;
}

.stat-card-dark:hover {
    transform: translateY(-3px);
}

.stat-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.stat-card-icon {
    font-size: 18px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Pengekodan Warna Ikon Stat */
.cawangan-color {
    background-color: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.wanita-color {
    background-color: rgba(139, 92, 246, 0.1);
    color: #a78bfa;
}

.total-color {
    background-color: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.status-color {
    background-color: rgba(249, 115, 22, 0.1);
    color: #f97316;
}

.stat-card-value {
    font-size: 26px;
    font-weight: 700;
    color: #ffffff;
}

.stat-card-desc {
    font-size: 12px;
    color: #64748b;
}

/* Kad Notifikasi Jingga (Pangkalan Data Kosong) */
.notice-banner-dark {
    background: rgba(249, 115, 22, 0.04);
    border: 1px dashed rgba(249, 115, 22, 0.3);
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 20px;
}

@media (max-width: 580px) {
    .notice-banner-dark {
        flex-direction: column;
        text-align: center;
    }
}

.notice-icon {
    font-size: 32px;
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background-color: rgba(249, 115, 22, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #f97316;
    flex-shrink: 0;
}

.notice-info h3 {
    font-size: 16px;
    font-weight: 600;
    color: #f97316;
    margin-bottom: 4px;
}

.notice-info p {
    font-size: 13px;
    color: #94a3b8;
    margin-bottom: 12px;
}

/* ==========================================================================
   Elemen Borang Input & Butang Tema Gelap
   ========================================================================== */
.form-control-dark {
    width: 100%;
    background-color: #1f2937;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 10px 14px;
    color: #ffffff;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
    font-family: inherit;
}

.form-control-dark:focus {
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.form-control-dark::placeholder {
    color: #64748b;
}

/* Butang Khusus */
.btn-primary-dark {
    background-color: #8b5cf6;
    color: #ffffff;
}

.btn-primary-dark:hover {
    background-color: #7c3aed;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.25);
}

.btn-secondary-dark {
    background-color: rgba(255, 255, 255, 0.06);
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-secondary-dark:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.btn-orange-dark {
    background-color: #f97316;
    color: #ffffff;
    text-decoration: none;
}

.btn-orange-dark:hover {
    background-color: #ea580c;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.25);
}

.btn-icon-only {
    width: 38px;
    height: 38px;
    background-color: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
}

.btn-icon-only:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

/* ==========================================================================
   Jadual Data Tema Gelap
   ========================================================================== */
.table-responsive-dark {
    width: 100%;
    overflow-x: auto;
}

.data-table-dark {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table-dark th, .data-table-dark td {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: middle;
}

.data-table-dark th {
    background-color: rgba(255, 255, 255, 0.02);
    font-weight: 600;
    font-size: 11px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table-dark tr:hover td {
    background-color: rgba(255, 255, 255, 0.01);
}

.table-avatar-container-dark {
    width: 42px;
    height: 42px;
    position: relative;
}

.table-avatar-dark {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 30%;
    border-radius: 50%;
    border: 2px solid #1f2937;
    box-shadow: 0 2px 4px rgba(0,0,0,0.25);
}

.table-avatar-fallback-dark {
    width: 100%;
    height: 100%;
    background-color: #8b5cf6;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    border: 2px solid #1f2937;
}

.contact-info-dark {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    color: #94a3b8;
}

.contact-info-dark span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.table-actions-dark {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.btn-action-dark {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-edit-dark {
    background-color: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
}

.btn-edit-dark:hover {
    background-color: rgba(59, 130, 246, 0.2);
}

.btn-delete-dark {
    background-color: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
}

.btn-delete-dark:hover {
    background-color: rgba(239, 68, 68, 0.2);
}

/* ==========================================================================
   Previu Gambar Halaman Sunting/Tambah Gelap
   ========================================================================== */
.current-avatar-preview-dark {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 10px;
}

.edit-preview-img-dark {
    width: 65px;
    height: 65px;
    object-fit: cover;
    object-position: center 30%;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.08);
}

.avatar-preview-fallback-dark {
    width: 65px;
    height: 65px;
    background-color: #1f2937;
    color: #94a3b8;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    border: 1px dashed rgba(255, 255, 255, 0.1);
}

.checkbox-option-dark {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #94a3b8;
}

.checkbox-option-dark label {
    margin-bottom: 0;
    cursor: pointer;
}


.edit-preview-img {
    width: 70px;
    height: 70px;
    object-fit: cover;
    object-position: center 30%;
    border-radius: 50%;
    border: 2px solid var(--card-border);
}

.avatar-preview-fallback {
    width: 70px;
    height: 70px;
    background-color: #f1f5f9;
    color: var(--text-muted);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    border: 1px dashed var(--card-border);
}

.checkbox-option {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.checkbox-option label {
    margin-bottom: 0;
    cursor: pointer;
}

/* ==========================================================================
   6. Halaman Awam Carta Organisasi (index.php)
   ========================================================================== */
.public-body {
    background-color: #f8fafc;
    color: #1e293b;
}

.public-header {
    background-color: #ffffff;
    border-bottom: 2px solid #e2e8f0;
    padding: 25px 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    position: relative;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
}

.header-logo-box {
    flex-shrink: 0;
}

.header-logo {
    height: 90px;
    width: auto;
    object-fit: contain;
}

.header-text-box {
    text-align: center;
}

.header-title-main {
    font-size: 24px;
    font-weight: 800;
    color: #15803d; /* Warna Hijau PERKIM */
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.header-title-sub {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 2px;
}

.header-title-branch {
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 2px;
}

.header-title-year {
    font-size: 14px;
    font-weight: 600;
    color: #4b5563;
}

@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    .header-title-main {
        font-size: 20px;
    }
    .header-title-sub {
        font-size: 15px;
    }
    .header-title-branch {
        font-size: 14px;
    }
    .header-title-year {
        font-size: 12px;
    }
    .header-logo {
        height: 70px;
    }
}

.public-footer {
    text-align: center;
    padding: 30px;
    font-size: 13px;
    color: var(--text-muted);
    border-top: 1px solid var(--card-border);
    margin-top: 40px;
}

.public-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.public-footer a:hover {
    text-decoration: underline;
}

/* Petunjuk Skrol — hanya pada mobile */
.scroll-hint {
    display: none;
    text-align: center;
    color: #94a3b8;
    font-size: 12px;
    padding: 8px 0 0 0;
}

@media (max-width: 768px) {
    .scroll-hint { display: block; }
    .desktop-only { display: none; }
}
@media (min-width: 769px) {
    .mobile-only { display: none; }
}

/* Pembungkus Carta Scroll */
.chart-scroll-wrapper {
    overflow-x: auto;
    padding: 40px 20px;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
}

@media (min-width: 1280px) {
    .chart-scroll-wrapper {
        justify-content: center;
    }
}

/* ==========================================================================
   7. Logik Pepohon Carta Organisasi (Pure CSS Tree)
   ========================================================================== */
.org-tree-wrapper-custom {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.org-tree {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.org-tree ul {
    padding-top: 20px;
    position: relative;
    transition: all 0.5s;
    display: flex;
    justify-content: center;
}

.org-tree li {
    text-align: center;
    list-style-type: none;
    position: relative;
    padding: 20px 15px 0 15px;
    transition: all 0.5s;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Garisan mendatar antara kad AJK */
.org-tree li::before {
    content: '';
    position: absolute;
    top: 0;
    right: 50%;
    border-top: 2px solid #cbd5e1;
    width: 50%;
    height: 20px;
}
.org-tree li:before {
    content: '';
    position: absolute;
    top: 0;
    right: 50%;
    border-top: 2px solid #cbd5e1;
    width: 50%;
    height: 20px;
}

.org-tree li::after {
    content: '';
    position: absolute;
    top: 0;
    right: 50%;
    border-top: 2px solid #cbd5e1;
    width: 50%;
    height: 20px;
}
.org-tree li:after {
    content: '';
    position: absolute;
    top: 0;
    right: 50%;
    border-top: 2px solid #cbd5e1;
    width: 50%;
    height: 20px;
}

.org-tree li::after {
    right: auto;
    left: 50%;
    border-left: 2px solid #cbd5e1;
}
.org-tree li:after {
    right: auto;
    left: 50%;
    border-left: 2px solid #cbd5e1;
}

/* Keluarkan garisan sambungan jika hanya ada satu anak */
.org-tree li:only-child::before {
    display: none;
}
.org-tree li:only-child:before {
    display: none;
}
.org-tree li:only-child::after {
    display: none;
}
.org-tree li:only-child:after {
    display: none;
}
.org-tree li.is-only-child::before {
    display: none;
}
.org-tree li.is-only-child:before {
    display: none;
}
.org-tree li.is-only-child::after {
    display: none;
}
.org-tree li.is-only-child:after {
    display: none;
}

.org-tree li:only-child {
    padding-top: 0;
}
.org-tree li.is-only-child {
    padding-top: 0;
}

/* - Keluarkan garisan kiri/kanan pada penghujung cabang */
.org-tree li:first-child::before {
    border: 0 none;
}
.org-tree li:first-child:before {
    border: 0 none;
}
.org-tree li:last-child::after {
    border: 0 none;
}
.org-tree li:last-child:after {
    border: 0 none;
}
.org-tree li.is-first-child::before {
    border: 0 none;
}
.org-tree li.is-first-child:before {
    border: 0 none;
}
.org-tree li.is-last-child::after {
    border: 0 none;
}
.org-tree li.is-last-child:after {
    border: 0 none;
}

/* Tambah border condong pada bucu hujung kiri/kanan */
.org-tree li:last-child::before {
    border-right: 2px solid #cbd5e1;
    border-radius: 0 8px 0 0;
}
.org-tree li:last-child:before {
    border-right: 2px solid #cbd5e1;
    border-radius: 0 8px 0 0;
}
.org-tree li.is-last-child::before {
    border-right: 2px solid #cbd5e1;
    border-radius: 0 8px 0 0;
}
.org-tree li.is-last-child:before {
    border-right: 2px solid #cbd5e1;
    border-radius: 0 8px 0 0;
}

.org-tree li:first-child::after {
    border-radius: 8px 0 0 0;
}
.org-tree li:first-child:after {
    border-radius: 8px 0 0 0;
}
.org-tree li.is-first-child::after {
    border-radius: 8px 0 0 0;
}
.org-tree li.is-first-child:after {
    border-radius: 8px 0 0 0;
}

/* Garisan menegak dari bapa ke barisan anak-anak */
.org-tree ul ul::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    border-left: 2px solid #cbd5e1;
    width: 0;
    height: 20px;
}

/* Garisan tegak keluar dari bawah kad jika ahli tersebut mempunyai anak (subordinate) */
.org-tree li:has(ul) > .member-card::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 50%;
    border-left: 2px solid #cbd5e1;
    width: 0;
    height: 20px;
    z-index: 1;
}

/* Kad Ahli (Member Card) */
.member-card {
    background: #ffffff;
    border: 1px solid var(--card-border);
    padding: 16px 20px;
    border-radius: 12px;
    width: 200px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.3s ease;
}

.member-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    border-color: var(--primary-color);
}

.member-card:hover::after {
    border-color: var(--primary-color) !important;
}

.card-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 30%;
    margin-bottom: 12px;
    border: 3px solid #fff;
    box-shadow: var(--shadow-sm);
    background-color: #f1f5f9;
}

.card-avatar-fallback {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 20px;
    margin-bottom: 12px;
    border: 3px solid #fff;
    box-shadow: var(--shadow-sm);
}

.member-card h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 4px;
    word-break: break-word;
    max-height: 40px;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

.member-card p {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    color: var(--primary-color);
    letter-spacing: 0.5px;
    background-color: rgba(13, 148, 136, 0.06);
    padding: 3px 8px;
    border-radius: 20px;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Modifikasi Garisan Apabila Melakukan Hover */
.org-tree li:hover::before, 
.org-tree li:hover::after,
.org-tree li:hover > ul::before,
.org-tree li:hover > ul > li::before,
.org-tree li:hover > ul > li::after {
    border-color: var(--primary-color);
}

/* ==========================================================================
   8. Gaya Tab Switcher Dwi-Carta (Premium)
   ========================================================================== */
.tabs-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 35px;
    margin-bottom: 5px;
    width: 100%;
    padding: 0 20px;
}

.tabs-container {
    background-color: #e2e8f0;
    padding: 5px;
    border-radius: 50px;
    display: inline-flex;
    gap: 4px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.06);
}

.tab-btn {
    border: none;
    background: transparent;
    padding: 12px 28px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.25s ease;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    outline: none;
}

.tab-btn:hover {
    color: var(--text-main);
}

.tab-btn.active {
    background-color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Serlahkan warna aktif mengikut sayap */
.tab-btn.active:first-child {
    color: var(--primary-color);
}

.tab-btn.active:last-child {
    color: var(--secondary-color);
}

/* Logik Sembunyi/Papar Carta */
.chart-content {
    width: 100%;
}

.hidden-chart {
    display: none !important;
}

.empty-chart-card {
    max-width: 450px;
    margin: 50px auto;
    text-align: center;
    padding: 40px;
}

/* ==========================================================================
   9. Reka Bentuk Khas Pengerusi Tetap & Naib Pengerusi Tetap (Gambar 2)
   ========================================================================== */
.top-special-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    position: relative;
    margin-bottom: 20px;
}

.top-special-row {
    display: flex;
    justify-content: center;
    gap: 100px;
    position: relative;
}

.top-special-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 200px;
    position: relative;
}

.line-down {
    width: 2px;
    height: 20px;
    background-color: #cbd5e1;
    transition: background-color 0.3s ease;
}

.line-horizontal {
    width: 300px; /* Jarak pusat-ke-pusat antara dua kad (200px kad + 100px gap) */
    height: 2px;
    background-color: #cbd5e1;
    margin-top: -2px; /* Bertindih dengan hujung line-down */
    transition: background-color 0.3s ease;
}

.line-down-center {
    width: 2px;
    height: 20px;
    background-color: #cbd5e1;
    transition: background-color 0.3s ease;
}

/* Hover Micro-interaction bagi garisan teratas */
.top-special-wrapper:hover .line-down,
.top-special-wrapper:hover .line-horizontal,
.top-special-wrapper:hover .line-down-center {
    background-color: var(--primary-color);
}

/* ==========================================================================
   10. Reka Bentuk Khas Pemeriksa Kira-Kira (Gambar 3)
   ========================================================================== */
.bottom-special-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    position: relative;
    margin-top: 20px;
}

.bottom-special-row {
    display: flex;
    justify-content: center;
    gap: 100px;
    position: relative;
}

.bottom-special-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 200px;
    position: relative;
}

/* Hover Micro-interaction bagi garisan terbawah */
.bottom-special-wrapper:hover .line-down,
.bottom-special-wrapper:hover .line-horizontal,
.bottom-special-wrapper:hover .line-down-center {
    background-color: var(--primary-color);
}

/* ==========================================================================
   11. Penyelarasan Tema Warna Sayap Wanita (Hover Pink/Purple)
   ========================================================================== */
#chart-wanita .org-tree li:hover::before, 
#chart-wanita .org-tree li:hover::after,
#chart-wanita .org-tree li:hover > ul::before,
#chart-wanita .org-tree li:hover > ul > li::before,
#chart-wanita .org-tree li:hover > ul > li::after {
    border-color: var(--secondary-color);
}

#chart-wanita .member-card:hover {
    border-color: var(--secondary-color);
}

#chart-wanita .member-card p {
    color: var(--secondary-color);
    background-color: rgba(219, 39, 119, 0.06);
}

#chart-wanita .top-special-wrapper:hover .line-down,
#chart-wanita .top-special-wrapper:hover .line-horizontal,
#chart-wanita .top-special-wrapper:hover .line-down-center {
    background-color: var(--secondary-color);
}

#chart-wanita .bottom-special-wrapper:hover .line-down,
#chart-wanita .bottom-special-wrapper:hover .line-horizontal,
#chart-wanita .bottom-special-wrapper:hover .line-down-center {
    background-color: var(--secondary-color);
}

/* ==========================================================================
   12. Gaya Butang Muat Turun PDF (Premium)
   ========================================================================== */
.download-pdf-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
    font-family: inherit;
    outline: none;
}

.download-pdf-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.3);
    background: linear-gradient(135deg, #34d399 0%, #059669 100%);
}

.download-pdf-btn:active {
    transform: translateY(0);
}

/* ==========================================================================
   15. Modal Pengesahan & Carian Dashboard
   ========================================================================== */

/* Overlay Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-dialog {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 30px;
    max-width: 440px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.modal-dialog h3 {
    color: #f1f5f9;
    margin: 0 0 12px 0;
    font-size: 18px;
}

.modal-dialog p {
    color: #94a3b8;
    margin: 0 0 25px 0;
    font-size: 14px;
    line-height: 1.6;
}

.modal-dialog .member-name {
    color: #f472b6;
    font-weight: 600;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-actions .btn {
    min-width: 100px;
}

.btn-cancel {
    background: rgba(255, 255, 255, 0.06);
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}

.btn-danger {
    background: #dc2626;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-danger:hover {
    background: #b91c1c;
}

/* Carian Dashboard */
.search-bar {
    margin-bottom: 20px;
    position: relative;
}

.search-bar input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 14px;
    font-family: 'Outfit', sans-serif;
    transition: border-color 0.2s;
}

.search-bar input:focus {
    outline: none;
    border-color: #8b5cf6;
}

.search-bar::before {
    content: '🔍';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    pointer-events: none;
    opacity: 0.5;
}

.search-no-results {
    text-align: center;
    padding: 30px;
    color: #64748b;
    font-size: 14px;
}

/* Jadual Audit */
.audit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.audit-table th {
    text-align: left;
    padding: 10px 12px;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.audit-table td {
    padding: 10px 12px;
    color: #cbd5e1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: top;
}

.audit-action-create { color: #34d399; font-weight: 600; }
.audit-action-update { color: #60a5fa; font-weight: 600; }
.audit-action-delete { color: #f87171; font-weight: 600; }

.admin-mini-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.admin-mini-table th {
    text-align: left;
    padding: 8px 10px;
    color: #64748b;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.admin-mini-table td {
    padding: 8px 10px;
    color: #cbd5e1;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.admin-mini-table .badge-self {
    display: inline-block;
    background: rgba(139, 92, 246, 0.12);
    color: #a78bfa;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.admin-mini-table .btn-sm-danger {
    background: transparent;
    color: #f87171;
    border: 1px solid rgba(248, 113, 113, 0.3);
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s;
}

.admin-mini-table .btn-sm-danger:hover {
    background: rgba(248, 113, 113, 0.1);
    border-color: #f87171;
}

.admin-mini-table .btn-sm-danger:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.form-inline {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.form-inline input {
    flex: 1;
    min-width: 120px;
    padding: 8px 12px;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 13px;
    font-family: 'Outfit', sans-serif;
}

.form-inline input:focus {
    outline: none;
    border-color: #8b5cf6;
}

.btn-sm-primary {
    background: #8b5cf6;
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.2s;
}

.btn-sm-primary:hover {
    background: #7c3aed;
}

/* Tab Filter Dashboard */
.btn-tab {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.04);
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition: all 0.2s;
}

.btn-tab:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
}

.btn-tab.active {
    background: rgba(139, 92, 246, 0.12);
    color: #a78bfa;
    border-color: rgba(139, 92, 246, 0.3);
}

/* Page Link Pagination */
.page-link {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    text-decoration: none;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition: all 0.2s;
}

.page-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
}

.page-link.active {
    background: #8b5cf6;
    color: #fff;
    border-color: #8b5cf6;
    pointer-events: none;
}

/* ==========================================================================
   16. Responsif — Paparan Awam (Mobile-Friendly)
   ========================================================================== */

/* --- Tablet (max 768px) --- */
@media (max-width: 768px) {
    .header-logo { height: 60px; }
    .header-title-main { font-size: 18px; }
    .header-title-sub { font-size: 14px; }
    .header-title-branch { font-size: 13px; }
    .header-title-year { font-size: 11px; }

    .tabs-wrapper {
        flex-direction: column;
        gap: 12px;
        margin-top: 20px;
    }
    .tab-btn {
        padding: 10px 18px;
        font-size: 12px;
    }
    .download-pdf-btn {
        padding: 8px 18px;
        font-size: 12px;
    }

    /* Carta — skrol mendatar */
    .chart-scroll-wrapper {
        padding: 20px 10px;
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        display: block;
        overflow-x: auto;
    }
    .chart-content {
        min-width: max-content;
        display: inline-block;
    }
    .org-tree-wrapper-custom {
        min-width: max-content;
    }

    /* Kad lebih kecil */
    .member-card {
        width: 150px;
        padding: 12px 14px;
        border-radius: 10px;
    }
    .card-avatar, .card-avatar-fallback {
        width: 44px;
        height: 44px;
        margin-bottom: 8px;
    }
    .card-avatar-fallback { font-size: 16px; }
    .member-card h3 { font-size: 12px; }
    .member-card p { font-size: 10px; padding: 2px 6px; }

    /* Pepohon — kurangkan jarak */
    .org-tree li { padding: 16px 10px 0 10px; }
    .org-tree ul { padding-top: 16px; }
    .org-tree li::before, .org-tree li:before,
    .org-tree li::after, .org-tree li:after,
    .org-tree ul ul::before { height: 16px; }
    .org-tree li:has(ul) > .member-card::after { height: 16px; bottom: -16px; }

    /* Baris khas — kecilkan */
    .top-special-row, .bottom-special-row { gap: 50px; }
    .top-special-col, .bottom-special-col { width: 150px; }
    .line-horizontal { width: 200px; }
    .line-down, .line-down-center { height: 15px; }

    .public-footer { padding: 20px; font-size: 11px; }
}

/* --- Telefon Bimbit (max 480px) --- */
@media (max-width: 480px) {
    .header-container { gap: 10px; }
    .header-logo { height: 50px; }
    .header-title-main { font-size: 16px; }
    .header-title-sub { font-size: 12px; }
    .header-title-branch { font-size: 11px; }
    .header-title-year { font-size: 10px; }
    .public-header { padding: 15px 10px; }

    .tabs-wrapper { margin-top: 12px; gap: 8px; }
    .tabs-container {
        flex-direction: column;
        width: 100%;
        border-radius: 12px;
        padding: 4px;
    }
    .tab-btn {
        padding: 8px 14px;
        font-size: 11px;
        border-radius: 8px;
        width: 100%;
        justify-content: center;
    }
    .download-pdf-btn {
        width: 100%;
        justify-content: center;
        padding: 10px 16px;
        font-size: 13px;
    }

    /* Carta — padding minima */
    .chart-scroll-wrapper {
        padding: 15px 5px;
        display: block;
        overflow-x: auto;
    }
    .chart-content {
        min-width: max-content;
        display: inline-block;
    }
    .org-tree-wrapper-custom {
        min-width: max-content;
    }

    /* Kad paling kecil */
    .member-card {
        width: 125px;
        padding: 10px 10px;
        border-radius: 8px;
    }
    .card-avatar, .card-avatar-fallback {
        width: 38px;
        height: 38px;
        margin-bottom: 6px;
    }
    .card-avatar-fallback { font-size: 14px; }
    .member-card h3 { font-size: 11px; margin-bottom: 2px; }
    .member-card p { font-size: 9px; padding: 2px 5px; letter-spacing: 0.3px; }

    /* Pepohon — paling padat */
    .org-tree li { padding: 12px 6px 0 6px; }
    .org-tree ul { padding-top: 12px; }
    .org-tree li::before, .org-tree li:before,
    .org-tree li::after, .org-tree li:after,
    .org-tree ul ul::before { height: 12px; border-width: 1.5px; }
    .org-tree li:has(ul) > .member-card::after {
        height: 12px;
        bottom: -12px;
        border-width: 1.5px;
    }
    .org-tree li:last-child::before { border-width: 1.5px; }
    .org-tree li:first-child::after { border-width: 1.5px; }

    /* Baris khas — paling kecil */
    .top-special-row, .bottom-special-row { gap: 30px; }
    .top-special-col, .bottom-special-col { width: 125px; }
    .line-horizontal { width: 150px; height: 1.5px; }
    .line-down, .line-down-center { height: 12px; width: 1.5px; }

    .public-footer { padding: 15px 10px; font-size: 10px; margin-top: 20px; }
    .empty-chart-card { padding: 30px 15px !important; }

    /* Petunjuk skrol */
    .scroll-hint {
        display: block;
        text-align: center;
        color: #94a3b8;
        font-size: 12px;
        padding: 8px 0 0 0;
    }
}

/* --- Skrin besar (>1400px) — pusatkan carta --- */

/* --- Skrin besar (>1400px) — pusatkan carta --- */
@media (min-width: 1401px) {
    .chart-scroll-wrapper { justify-content: center; }
}


