/* ============================================
   AMAL PEKANAN — Design System
   Theme: Islamic Green + White, Refined & Clean
   ============================================ */

:root {
    --green-950: #052e16;
    --green-900: #14532d;
    --green-800: #166534;
    --green-700: #15803d;
    --green-600: #16a34a;
    --green-500: #22c55e;
    --green-400: #4ade80;
    --green-300: #86efac;
    --green-200: #bbf7d0;
    --green-100: #dcfce7;
    --green-50:  #f0fdf4;

    --gold: #b8973e;
    --gold-light: #f0d98c;
    --silver: #9ca3af;
    --bronze: #c2783e;

    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    --sidebar-width: 260px;
    --topbar-height: 64px;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
    --shadow: 0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.05);
    --shadow-lg: 0 12px 32px rgba(0,0,0,.1), 0 4px 8px rgba(0,0,0,.06);
    --shadow-green: 0 8px 24px rgba(22, 163, 74, .25);

    --font-arabic: 'Amiri', serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

/* ─── LAYOUT ─────────────────────────────── */

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ─── SIDEBAR ─────────────────────────────── */

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(175deg, var(--green-900) 0%, var(--green-950) 100%);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform .3s cubic-bezier(.4,0,.2,1);
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 200px;
    background: radial-gradient(ellipse at top left, rgba(74, 222, 128, .12), transparent 70%);
    pointer-events: none;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-icon svg {
    width: 36px; height: 36px;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-name {
    color: var(--white);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -.01em;
}

.brand-sub {
    color: var(--green-300);
    font-size: 11px;
    font-weight: 400;
    letter-spacing: .03em;
}

.sidebar-nav {
    padding: 20px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-section-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--green-400);
    padding: 4px 8px 8px;
    opacity: .7;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: rgba(255,255,255,.7);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: all .2s;
    position: relative;
}

.nav-item:hover {
    background: rgba(255,255,255,.07);
    color: var(--white);
}

.nav-item.active {
    background: rgba(74, 222, 128, .15);
    color: var(--green-300);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--green-400);
    border-radius: 0 3px 3px 0;
}

.nav-icon {
    width: 18px; height: 18px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.nav-icon svg {
    width: 16px; height: 16px;
}

.sidebar-footer {
    padding: 16px 20px 24px;
    border-top: 1px solid rgba(255,255,255,.06);
}

.ayah-quote {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.ayah-text {
    font-family: var(--font-arabic);
    font-size: 18px;
    color: var(--green-300);
    opacity: .8;
    text-align: center;
    direction: rtl;
}

.ayah-trans {
    font-size: 10px;
    color: rgba(255,255,255,.35);
    letter-spacing: .04em;
}

/* ─── MAIN AREA ─────────────────────────────── */

.main-area {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: var(--topbar-height);
    background: var(--white);
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 16px;
}

.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--gray-600);
    border-radius: 2px;
    transition: .3s;
}

.topbar-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-800);
    flex: 1;
}

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

.topbar-date {
    font-size: 12.5px;
    color: var(--gray-500);
    font-weight: 400;
}

.content-area {
    padding: 28px;
    flex: 1;
    min-width: 0; 
    overflow-x: hidden; 
}

/* ─── CARDS ─────────────────────────────── */

.card {
    width: 100%;
    min-width: 0;
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-100);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-800);
}

.card-body {
    padding: 24px;
}

/* ─── FORM ELEMENTS ─────────────────────────────── */

.panduan-box {
    background: linear-gradient(135deg, var(--green-50), #f0fdf4);
    border: 1px solid var(--green-200);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 28px;
}

.panduan-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--green-800);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panduan-title svg {
    width: 16px; height: 16px;
    color: var(--green-600);
}

.panduan-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.panduan-list li {
    font-size: 12.5px;
    color: var(--green-900);
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.panduan-list li::before {
    content: '•';
    color: var(--green-500);
    font-size: 14px;
    line-height: 1.4;
    flex-shrink: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.form-grid.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    display: flex;
    align-items: center;
    gap: 3px;
}

.required-star {
    color: #ef4444;
    font-size: 14px;
    line-height: 1;
}

input[type="text"],
input[type="number"],
input[type="date"],
select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 13.5px;
    color: var(--gray-800);
    background: var(--white);
    transition: border-color .2s, box-shadow .2s;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 36px;
}

input:focus, select:focus {
    border-color: var(--green-500);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, .12);
}

input:disabled, select:disabled {
    background: var(--gray-50);
    color: var(--gray-400);
    cursor: not-allowed;
    border-color: var(--gray-200);
}

.form-divider {
    grid-column: 1 / -1;
    border: none;
    border-top: 1px dashed var(--gray-200);
    margin: 4px 0;
}

.section-label {
    grid-column: 1 / -1;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--green-700);
    padding: 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--green-100);
}

/* ─── BUTTONS ─────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all .2s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--green-600);
    color: var(--white);
}

.btn-primary:hover:not(:disabled) {
    background: var(--green-700);
    box-shadow: var(--shadow-green);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    background: var(--gray-300);
    color: var(--gray-500);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-outline {
    background: transparent;
    color: var(--green-700);
    border: 1.5px solid var(--green-300);
}

.btn-outline:hover {
    background: var(--green-50);
}

.btn-sm {
    padding: 7px 14px;
    font-size: 12.5px;
}

.btn-icon {
    width: 16px; height: 16px;
}

/* ─── FILTER BAR ─────────────────────────────── */

.filter-bar {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
    padding: 16px 20px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-100);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 160px;
}

.filter-group label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--gray-500);
    letter-spacing: .03em;
}

.filter-group input,
.filter-group select {
    padding: 8px 12px;
    font-size: 13px;
}

.filter-actions {
    display: flex;
    gap: 8px;
    align-self: flex-end;
}

/* ─── TABLE ─────────────────────────────── */

.table-wrapper {
    overflow-x: auto;
    width: 100%;
}

table {
    width: 100%;
    min-width: 600px; /* sesuaikan dengan jumlah kolom */
    border-collapse: collapse;
    font-size: 13px;
}

.table-wide {
    min-width: 1000px;
}

thead {
    background: var(--green-50);
    border-bottom: 2px solid var(--green-100);
}

thead th {
    padding: 11px 16px;
    text-align: left;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--green-800);
    letter-spacing: .04em;
    text-transform: uppercase;
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--gray-100);
    transition: background .15s;
}

tbody tr:hover {
    background: var(--green-50);
}

tbody td {
    padding: 12px 16px;
    color: var(--gray-700);
    vertical-align: middle;
}

.td-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

.td-link {
    color: var(--green-700);
    font-weight: 600;
    text-decoration: none;
    transition: color .15s;
}

.td-link:hover {
    color: var(--green-500);
    text-decoration: underline;
}

/* ─── PAGINATION ─────────────────────────────── */

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-top: 1px solid var(--gray-100);
    font-size: 12.5px;
    color: var(--gray-500);
}

.pagination-controls {
    display: flex;
    gap: 4px;
    align-items: center;
}

.page-btn {
    min-width: 32px;
    height: 32px;
    border: 1.5px solid var(--gray-200);
    background: var(--white);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-family: var(--font-body);
    cursor: pointer;
    color: var(--gray-600);
    font-weight: 500;
    transition: all .15s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
}

.page-btn:hover:not(:disabled) {
    border-color: var(--green-400);
    color: var(--green-700);
    background: var(--green-50);
}

.page-btn.active {
    background: var(--green-600);
    border-color: var(--green-600);
    color: var(--white);
}

.page-btn:disabled {
    opacity: .4;
    cursor: not-allowed;
}

.limit-select {
    padding: 6px 10px;
    font-size: 12px;
    min-width: 80px;
    width: auto;
}

/* ─── RANK BADGES ─────────────────────────────── */

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
}

.rank-1 { background: linear-gradient(135deg, #ffd700, #f0b800); color: #7a5500; box-shadow: 0 2px 8px rgba(240,184,0,.4); }
.rank-2 { background: linear-gradient(135deg, #e8e8e8, #c0c0c0); color: #4a4a4a; }
.rank-3 { background: linear-gradient(135deg, #e8a87c, #c2783e); color: #fff; }
.rank-other { background: var(--gray-100); color: var(--gray-500); }

.trophy-icon {
    font-size: 20px;
    text-align: center;
}

/* ─── MODAL ─────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn .2s ease;
}

.modal-box {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 36px 40px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: slideUp .25s ease;
}

.modal-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 28px;
}

.modal-icon.success { background: var(--green-100); }
.modal-icon.error { background: #fee2e2; }
.modal-icon.warning { background: #fef9c3; }

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 8px;
}

.modal-msg {
    font-size: 13.5px;
    color: var(--gray-500);
    line-height: 1.6;
    margin-bottom: 24px;
}

/* ─── EMPTY STATE ─────────────────────────────── */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--gray-400);
    gap: 12px;
}

.empty-state svg {
    width: 48px;
    height: 48px;
    opacity: .4;
}

.empty-state p {
    font-size: 13.5px;
}

/* ─── LOADING ─────────────────────────────── */

.loading-row td {
    text-align: center;
    padding: 40px;
    color: var(--gray-400);
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--green-200);
    border-top-color: var(--green-500);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

/* ─── BADGE ─────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.badge-green {
    background: var(--green-100);
    color: var(--green-800);
}

/* ─── STAT AVG PILL ─────────────────────────────── */

.avg-pill {
    display: inline-block;
    min-width: 36px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    background: var(--green-50);
    color: var(--green-800);
}

/* ─── SEARCHABLE SELECT ───────────────────────────────── */

.searchable-select {
    position: relative;
}

.searchable-select input[type="text"] {
    width: 100%;
    cursor: pointer;
}

.searchable-select input[type="text"].has-value {
    font-weight: 600;
    color: var(--green-800);
    border-color: var(--green-400);
}

.searchable-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--white);
    border: 1.5px solid var(--green-300);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    max-height: 220px;
    overflow-y: auto;
}

.searchable-dropdown-item {
    padding: 10px 14px;
    font-size: 13.5px;
    cursor: pointer;
    color: var(--gray-700);
    transition: background .12s;
    border-bottom: 1px solid var(--gray-100);
}

.searchable-dropdown-item:last-child {
    border-bottom: none;
}

.searchable-dropdown-item:hover,
.searchable-dropdown-item.focused {
    background: var(--green-50);
    color: var(--green-800);
}

.searchable-dropdown-item.no-result {
    color: var(--gray-400);
    cursor: default;
    font-style: italic;
}

.searchable-dropdown-item mark {
    background: var(--green-200);
    color: var(--green-900);
    border-radius: 2px;
    padding: 0 1px;
    font-style: normal;
}

/* ─── ANIMATIONS ─────────────────────────────── */

@keyframes fadeIn {
    from { opacity: 0 }
    to { opacity: 1 }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(16px) }
    to { opacity: 1; transform: translateY(0) }
}

@keyframes spin {
    to { transform: rotate(360deg) }
}

/* ─── RESPONSIVE ─────────────────────────────── */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .main-area {
        margin-left: 0;
    }

    .hamburger {
        display: flex;
    }

    .content-area {
        padding: 16px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-grid.cols-3 {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        padding: 12px 16px;
    }

    .filter-group {
        min-width: 140px;
    }
}

@media (max-width: 480px) {
    .pagination {
        flex-direction: column;
        gap: 12px;
    }
}