/* ============================================
   Rapot Nilai Tahfidz - Design System
   Modern Minimalist Green Theme
   ============================================ */

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

:root {
    /* Green Palette */
    --primary: #43A047;
    --primary-light: #66BB6A;
    --primary-dark: #2E7D32;
    --primary-50: #E8F5E9;
    --primary-100: #C8E6C9;
    --primary-200: #A5D6A7;
    --primary-300: #81C784;
    --primary-400: #66BB6A;
    --primary-500: #4CAF50;
    --primary-600: #43A047;
    --primary-700: #388E3C;
    --primary-800: #2E7D32;
    --primary-900: #1B5E20;

    /* Neutrals */
    --gray-50: #FAFAFA;
    --gray-100: #F5F5F5;
    --gray-200: #EEEEEE;
    --gray-300: #E0E0E0;
    --gray-400: #BDBDBD;
    --gray-500: #9E9E9E;
    --gray-600: #757575;
    --gray-700: #616161;
    --gray-800: #424242;
    --gray-900: #212121;

    /* Accents */
    --danger: #EF5350;
    --danger-light: #FFEBEE;
    --warning: #FFA726;
    --warning-light: #FFF3E0;
    --info: #42A5F5;
    --info-light: #E3F2FD;
    --success: #66BB6A;
    --success-light: #E8F5E9;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
    --shadow-xl: 0 20px 40px rgba(0,0,0,0.1);

    /* Layout */
    --sidebar-width: 260px;
    --header-height: 64px;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-50) 0%, var(--primary-100) 50%, #fff 100%);
    position: relative;
    overflow: hidden;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--primary-200) 0%, transparent 70%);
    top: -200px;
    right: -200px;
    opacity: 0.5;
}

.login-wrapper::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, var(--primary-300) 0%, transparent 70%);
    bottom: -150px;
    left: -100px;
    opacity: 0.3;
}

.login-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--border-radius-lg);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-xl);
    position: relative;
    z-index: 1;
    animation: fadeInUp 0.6s ease-out;
}

.login-card .logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-card .logo i {
    font-size: 48px;
    color: var(--primary);
    margin-bottom: 12px;
    display: block;
}

.login-card .logo h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.login-card .logo p {
    font-size: 14px;
    color: var(--gray-500);
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--primary-800) 0%, var(--primary-900) 100%);
    z-index: 1000;
    transition: var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
}

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

.sidebar-brand i {
    font-size: 32px;
    color: var(--primary-200);
}

.sidebar-brand .brand-text h5 {
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    line-height: 1.3;
}

.sidebar-brand .brand-text small {
    color: var(--primary-300);
    font-size: 11px;
}

.sidebar-menu {
    padding: 16px 12px;
}

.sidebar-menu .menu-label {
    color: var(--primary-300);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 12px 4px;
    margin-top: 8px;
}

.sidebar-menu .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: rgba(255,255,255,0.7);
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    font-weight: 400;
    transition: var(--transition);
    text-decoration: none;
    margin-bottom: 2px;
}

.sidebar-menu .nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
    transform: translateX(4px);
}

.sidebar-menu .nav-link.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-weight: 500;
    box-shadow: inset 3px 0 0 var(--primary-300);
}

.sidebar-menu .nav-link i {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

/* ============================================  
   MAIN CONTENT
   ============================================ */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

/* Top Navbar */
.top-navbar {
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--gray-200);
    height: var(--header-height);
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 999;
}

.top-navbar .page-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.top-navbar .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
    cursor: pointer;
    text-decoration: none;
    color: var(--gray-700);
}

.top-navbar .user-info:hover {
    background: var(--primary-50);
}

.top-navbar .user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.top-navbar .user-name {
    font-size: 14px;
    font-weight: 500;
}

.top-navbar .user-role {
    font-size: 11px;
    color: var(--gray-500);
}

.btn-sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--gray-700);
    cursor: pointer;
    padding: 4px;
}

/* Content Area */
.content-area {
    padding: 28px;
    flex-grow: 1;
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

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

.card-header h5 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
}

.card-body {
    padding: 24px;
}

/* Stat Cards */
.stat-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.stat-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.stat-card .stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.stat-card .stat-icon.green {
    background: var(--primary-50);
    color: var(--primary);
}

.stat-card .stat-icon.blue {
    background: var(--info-light);
    color: var(--info);
}

.stat-card .stat-icon.orange {
    background: var(--warning-light);
    color: var(--warning);
}

.stat-card .stat-icon.red {
    background: var(--danger-light);
    color: var(--danger);
}

.stat-card .stat-info h3 {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.2;
}

.stat-card .stat-info p {
    font-size: 13px;
    color: var(--gray-500);
    margin: 0;
}

/* ============================================
   FORMS
   ============================================ */
.form-control, .form-select {
    border: 1.5px solid var(--gray-300);
    border-radius: var(--border-radius-sm);
    padding: 10px 14px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    transition: var(--transition);
    color: var(--gray-800);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 160, 71, 0.15);
    outline: none;
}

.form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 14px;
    border-radius: var(--border-radius-sm);
    padding: 8px 20px;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(67, 160, 71, 0.3);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
}

.btn-success:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-outline-danger {
    color: var(--danger);
    border-color: var(--danger);
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
}

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

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius-sm);
}

/* ============================================
   TABLE
   ============================================ */
.table {
    font-size: 14px;
}

.table thead th {
    background: var(--primary-50);
    color: var(--primary-800);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    padding: 12px 16px;
    white-space: nowrap;
}

.table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--gray-200);
    color: var(--gray-700);
}

.table tbody tr:hover {
    background: var(--primary-50);
}

/* ============================================
   BADGES
   ============================================ */
.badge {
    font-weight: 500;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
}

.badge-predikat-A {
    background: var(--success-light);
    color: var(--primary-dark);
}

.badge-predikat-B {
    background: var(--info-light);
    color: #1565C0;
}

.badge-predikat-C {
    background: var(--warning-light);
    color: #E65100;
}

.badge-predikat-D {
    background: var(--danger-light);
    color: #C62828;
}

.badge-active {
    background: var(--success-light);
    color: var(--primary-dark);
}

.badge-inactive {
    background: var(--gray-200);
    color: var(--gray-600);
}

/* ============================================
   MODAL
   ============================================ */
.modal-content {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-xl);
}

.modal-header {
    background: var(--primary-50);
    border-bottom: 1px solid var(--primary-100);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    padding: 16px 24px;
}

.modal-header .modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-800);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    border-top: 1px solid var(--gray-200);
    padding: 16px 24px;
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.fade-in-up {
    animation: fadeInUp 0.4s ease-out;
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Staggered animation for cards */
.stat-card:nth-child(1) { animation: fadeInUp 0.4s ease-out 0.0s both; }
.stat-card:nth-child(2) { animation: fadeInUp 0.4s ease-out 0.1s both; }
.stat-card:nth-child(3) { animation: fadeInUp 0.4s ease-out 0.2s both; }
.stat-card:nth-child(4) { animation: fadeInUp 0.4s ease-out 0.3s both; }

/* ============================================
   PRINT STYLES (Rapot)
   ============================================ */
@media print {
    .sidebar, .top-navbar, .no-print, .btn {
        display: none !important;
    }
    .main-content {
        margin-left: 0 !important;
    }
    .content-area {
        padding: 0 !important;
    }
    .rapot-container {
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        padding: 20px 30px !important;
        max-width: 100% !important;
    }
    body {
        background: #fff !important;
    }
    @page {
        size: A4 portrait;
        margin: 15mm 10mm;
    }
}

/* ============================================
   RAPOT PRINT LAYOUT
   ============================================ */
.rapot-container {
    background: #fff;
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 44px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    font-size: 13px;
    color: #000;
    line-height: 1.5;
    font-family: "Times New Roman", Times, serif;
}

/* ---------- Letterhead ---------- */
.rapot-letterhead {
    display: flex;
    align-items: center;
    gap: 15px;
    border-top: 3px solid #000;
    border-bottom: 2px solid #000;
    padding: 8px 0;
    margin-bottom: 12px;
    position: relative;
}

.rapot-letterhead::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 100%;
    border-bottom: 1px solid #000;
}

.letterhead-logo img {
    width: 80px;
    height: 80px;
    object-fit: contain;
}

.letterhead-text {
    flex: 1;
    text-align: center;
}

.letterhead-text h4 {
    font-size: 14px;
    font-weight: 400;
    color: #000;
    margin: 0 0 2px;
}

.letterhead-text h2 {
    font-size: 22px;
    font-weight: 800;
    color: #000;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin: 0 0 2px;
}

.letterhead-text p {
    font-size: 11px;
    color: #000;
    margin: 0;
}

.rapot-title {
    text-align: center;
    font-weight: bold;
    font-size: 14px;
    margin: 20px 0 30px;
    line-height: 1.6;
}

/* ---------- Identity (2 columns simple) ---------- */
.rapot-id-simple {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
}

.rapot-id-simple td {
    padding: 4px 6px;
    font-size: 13px;
    vertical-align: top;
    color: #000;
}
.rapot-section-title {
    font-size: 13px;
    font-weight: 700;
    color: #000;
    margin: 20px 0 8px;
}

/* ---------- Nilai Table ---------- */
.rapot-nilai-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
}

.rapot-nilai-table th,
.rapot-nilai-table td {
    border: 1px solid #000;
    padding: 7px 10px;
    text-align: center;
    font-size: 12.5px;
    color: #000;
}

.rapot-nilai-table th {
    background: transparent;
    font-weight: 600;
    color: #000;
    font-size: 12px;
}

.rapot-row-total {
    background: transparent;
    font-weight: 700;
}

.rapot-row-total td {
    color: #000;
}

/* ---------- Bottom Row (Kehadiran + Predikat side by side) ---------- */
.rapot-bottom-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 8px;
}

.rapot-kehadiran-table {
    border-collapse: collapse;
    width: 100%;
}

.rapot-kehadiran-table td {
    padding: 4px 6px;
    font-size: 12.5px;
    vertical-align: top;
    color: #000;
}

.rapot-kehadiran-table .kh-label {
    width: 60px;
    color: #000;
}

.rapot-kehadiran-table .kh-sep {
    width: 12px;
    text-align: center;
    color: #000;
}

.rapot-kehadiran-table .kh-value {
    color: #000;
}

/* ---------- Print Date ---------- */
.rapot-print-date {
    text-align: right;
    font-size: 13px;
    color: #000;
    margin: 20px 0 10px;
    line-height: 1.5;
}

/* ---------- Signature (3 columns) ---------- */
.rapot-signature-3col-custom {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    margin-top: 15px;
    text-align: center;
}

.rapot-signature-3col-custom .sign-box {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.rapot-signature-3col-custom .sign-box .sign-title {
    font-size: 13px;
    font-weight: 400;
    color: #000;
    margin-bottom: 0;
}

.rapot-signature-3col-custom .sign-box .sign-space {
    height: 70px;
}

.rapot-signature-3col-custom .sign-box .sign-name {
    font-size: 14px;
    color: #000;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .btn-sidebar-toggle {
        display: block;
    }
    .content-area {
        padding: 20px 16px;
    }
}

@media (max-width: 768px) {
    .stat-card {
        padding: 16px;
    }
    .stat-card .stat-icon {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
    .stat-card .stat-info h3 {
        font-size: 22px;
    }
    .card-body {
        padding: 16px;
    }
    .rapot-container {
        padding: 20px;
    }
}

/* ============================================
   DATATABLES OVERRIDE
   ============================================ */
.dataTables_wrapper .dataTables_filter input {
    border: 1.5px solid var(--gray-300);
    border-radius: var(--border-radius-sm);
    padding: 6px 12px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 160, 71, 0.15);
    outline: none;
}

.dataTables_wrapper .dataTables_length select {
    border: 1.5px solid var(--gray-300);
    border-radius: var(--border-radius-sm);
    padding: 4px 8px;
    font-family: 'Inter', sans-serif;
}

.dataTables_wrapper .dataTables_info {
    font-size: 13px;
    color: var(--gray-600);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: var(--border-radius-sm) !important;
    font-size: 13px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
}

/* ============================================
   SWEETALERT2 OVERRIDES
   ============================================ */
.swal2-popup {
    border-radius: var(--border-radius) !important;
    font-family: 'Inter', sans-serif !important;
}

.swal2-confirm {
    background: var(--primary) !important;
    border-radius: var(--border-radius-sm) !important;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--gray-500);
}

.empty-state i {
    font-size: 64px;
    color: var(--gray-300);
    margin-bottom: 16px;
}

.empty-state h5 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    max-width: 400px;
    margin: 0 auto;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 999;
}

.sidebar-overlay.show {
    display: block;
}

/* Select2/Multi-select overrides */
.select2-container--default .select2-selection--multiple {
    border: 1.5px solid var(--gray-300);
    border-radius: var(--border-radius-sm);
    min-height: 42px;
    padding: 4px 8px;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background: var(--primary-50);
    border: 1px solid var(--primary-200);
    color: var(--primary-800);
    border-radius: 6px;
    font-size: 13px;
    padding: 2px 8px;
}

.select2-container--default .select2-selection--multiple:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 160, 71, 0.15);
}
