/* =======================================================
   Stylesheet Profesional - Monitoring Pembayaran Madrasah/RA
   Aksen: Emerald Islamic SaaS Theme (#064e3b, #047857, #10b981)
   ======================================================= */

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

:root {
    --primary-emerald: #047857;
    --emerald-dark: #064e3b;
    --emerald-light: #10b981;
    --emerald-soft: #ecfdf5;
    --emerald-border: #a7f3d0;
    
    --bg-page: #f8fafc;
    --surface-card: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
    --shadow-md: 0 4px 12px -2px rgba(0,0,0,0.06), 0 2px 6px -1px rgba(0,0,0,0.04);
    --shadow-lg: 0 12px 24px -4px rgba(0,0,0,0.08), 0 4px 8px -2px rgba(0,0,0,0.03);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

body {
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    letter-spacing: -0.01em;
}

.main-wrapper {
    flex: 1 0 auto;
}

/* Navbar Premium */
.navbar-custom {
    background: linear-gradient(135deg, #064e3b 0%, #047857 60%, #0f766e 100%);
    box-shadow: 0 4px 20px rgba(6, 78, 59, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

/* User Chip & Logout Nav Button (Sleek, Clean, No Strange Borders) */
.user-chip {
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: var(--radius-full);
    padding: 3px 12px 3px 4px;
    backdrop-filter: blur(8px);
    transition: all 0.2s ease;
}

.user-chip:hover {
    background: rgba(255, 255, 255, 0.2);
}

.user-chip-avatar {
    width: 30px;
    height: 30px;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.user-chip-name {
    font-size: 0.84rem;
    color: #ffffff;
    letter-spacing: -0.01em;
}

.user-chip-role {
    font-size: 0.62rem;
    color: #a7f3d0;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.btn-logout-nav {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    border-radius: var(--radius-full);
    padding: 5px 14px;
    font-size: 0.8rem;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
}

.btn-logout-nav:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(220, 38, 38, 0.3);
}

/* Badge Nav Tahun Pelajaran Aktif */
.nav-tapel-badge {
    background: rgba(255, 255, 255, 0.92);
    color: #064e3b !important;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-full);
    padding: 5px 14px;
    font-size: 0.78rem;
    font-weight: 600;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
}

.nav-tapel-badge:hover {
    background: #ffffff;
    color: #047857 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* Stat Cards */
.stat-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--surface-card);
    box-shadow: var(--shadow-sm);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.stat-card.total::before {
    background: linear-gradient(90deg, #0284c7, #38bdf8);
}

.stat-card.lunas::before {
    background: linear-gradient(90deg, #047857, #10b981);
}

.stat-card.belum-lunas::before {
    background: linear-gradient(90deg, #e11d48, #f43f5e);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: #cbd5e1;
}

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

.stat-card.total .icon-wrapper {
    background: #e0f2fe;
    color: #0369a1;
}

.stat-card.lunas .icon-wrapper {
    background: #dcfce7;
    color: #15803d;
}

.stat-card.belum-lunas .icon-wrapper {
    background: #ffe4e6;
    color: #be123c;
}

.stat-card .stat-number {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1;
}

.stat-card .stat-label {
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

/* Mini Progress Bar in Stat Card */
.stat-progress {
    height: 6px;
    border-radius: var(--radius-full);
    background-color: #f1f5f9;
    overflow: hidden;
    margin-top: 10px;
}

.stat-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #047857, #10b981);
    border-radius: var(--radius-full);
    transition: width 0.4s ease;
}

/* Content Box (Panel Utama) */
.content-box {
    background: var(--surface-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
}

/* Table Styling */
.custom-table {
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
}

.custom-table thead th {
    background-color: #f8fafc;
    color: #475569;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    padding: 0.9rem 1.1rem;
    border-top: 1px solid var(--border-color);
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

.custom-table tbody td {
    padding: 1rem 1.1rem;
    color: #1e293b;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    transition: background-color 0.15s ease;
}

.custom-table tbody tr:hover td {
    background-color: #f8fafc;
}

/* Pulsing Status Dot */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.dot-lunas {
    background-color: #16a34a;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.2);
    animation: pulse-green 2s infinite;
}

.dot-belum {
    background-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
    animation: pulse-red 2s infinite;
}

@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(22, 163, 74, 0); }
    100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

/* =======================================================
   INTERACTIVE CLICKABLE STATUS BADGE / BUTTON (FITUR UTAMA)
   User & Admin dapat merubah Lunas / Belum hanya dengan 1 klik!
   ======================================================= */
.btn-status-toggle {
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    border-radius: var(--radius-full);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    user-select: none;
    outline: none;
}

.btn-status-toggle:focus-visible {
    box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.35);
}

.btn-status-toggle .status-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0.45rem 0.95rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* Tampilan Status LUNAS */
.btn-status-toggle.is-lunas .status-pill {
    background-color: #ecfdf5;
    color: #065f46;
    border-color: #a7f3d0;
}

.btn-status-toggle.is-lunas:hover .status-pill {
    background-color: #d1fae5;
    border-color: #6ee7b7;
    transform: scale(1.03);
    box-shadow: 0 4px 10px rgba(4, 120, 87, 0.15);
}

/* Tampilan Status BELUM LUNAS */
.btn-status-toggle.is-belum .status-pill {
    background-color: #fff1f2;
    color: #9f1239;
    border-color: #fecdd3;
}

.btn-status-toggle.is-belum:hover .status-pill {
    background-color: #ffe4e6;
    border-color: #fda4af;
    transform: scale(1.03);
    box-shadow: 0 4px 10px rgba(225, 29, 72, 0.15);
}

.btn-status-toggle .toggle-hint {
    font-size: 0.68rem;
    opacity: 0.75;
    font-weight: 600;
    margin-left: 2px;
}

/* Loading State saat Toggle AJAX */
.btn-status-toggle.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

.btn-status-toggle.is-loading .status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 2px solid #64748b;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    background: transparent !important;
    box-shadow: none !important;
}

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

/* Link RDM Button */
.btn-rdm {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    color: #ffffff;
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 4px rgba(2, 132, 199, 0.2);
}

.btn-rdm:hover {
    background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.35);
}

/* Tombol Hijau Utama */
.btn-green {
    background: linear-gradient(135deg, #047857 0%, #059669 100%);
    color: #ffffff;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(4, 120, 87, 0.25);
}

.btn-green:hover {
    background: linear-gradient(135deg, #064e3b 0%, #047857 100%);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(4, 120, 87, 0.35);
}

/* Segmented Control Filter Buttons */
.filter-segmented {
    background-color: #f1f5f9;
    padding: 4px;
    border-radius: var(--radius-md);
    display: inline-flex;
    gap: 3px;
    border: 1px solid #e2e8f0;
}

.filter-segmented .btn-filter {
    border: none;
    background: transparent;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 0.4rem 0.95rem;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.filter-segmented .btn-filter:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.6);
}

.filter-segmented .btn-filter.active {
    background-color: #ffffff;
    color: var(--primary-emerald);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
}

/* Search Box Modern */
.search-box-group {
    position: relative;
}

.search-box-group .form-control {
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding-left: 2.3rem;
    padding-right: 2.2rem;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.search-box-group .form-control:focus {
    border-color: var(--emerald-light);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.search-box-group .search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
}

.search-box-group .btn-clear-search {
    position: absolute;
    right: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    display: none;
    padding: 0 4px;
}

.search-box-group .btn-clear-search:hover {
    color: var(--text-primary);
}

/* Floating Notification Toast */
.toast-container-top {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 1090;
    max-width: 380px;
    pointer-events: none;
}

.toast-modern {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 0.85rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
    pointer-events: auto;
    animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Upload Dropzone */
.upload-dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-lg);
    background-color: #f8fafc;
    transition: all 0.2s ease;
}

.upload-dropzone:hover {
    border-color: var(--primary-emerald);
    background-color: #f0fdf4;
}

/* NSM Badge */
.nsm-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    font-weight: 600;
    background-color: #f1f5f9;
    color: #334155;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm);
    border: 1px solid #e2e8f0;
}

/* Login Card Professional */
.login-card {
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    background-color: #ffffff;
}

.login-header {
    background: linear-gradient(135deg, #064e3b 0%, #047857 60%, #0f766e 100%);
    padding: 2.4rem 1.5rem;
    text-align: center;
    color: #ffffff;
    position: relative;
}

.login-header::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    right: 0;
    height: 20px;
    background: #ffffff;
    border-radius: 20px 20px 0 0;
}

.login-avatar {
    width: 68px;
    height: 68px;
    margin: 0 auto 1.1rem;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    font-size: 2rem;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Login Input Group dengan Jarak Ikon & Teks yang Pas */
.login-input-group {
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.login-input-group .input-group-text {
    background-color: #f8fafc !important;
    border-color: #cbd5e1;
    color: #64748b;
    padding-left: 1rem;
    padding-right: 0.85rem;
    border-top-left-radius: 10px !important;
    border-bottom-left-radius: 10px !important;
}

.login-input-group .form-control {
    border-color: #cbd5e1;
    padding-left: 0.95rem !important; /* Memberikan jarak nyaman antara ikon dan teks yang diketik */
    padding-right: 1rem;
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
    font-size: 0.95rem;
    color: #1e293b;
    border-top-right-radius: 10px !important;
    border-bottom-right-radius: 10px !important;
}

.login-input-group .form-control:focus {
    border-color: var(--primary-emerald);
    box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.15);
}

.login-input-group:focus-within .input-group-text {
    border-color: var(--primary-emerald);
    color: var(--primary-emerald);
}

/* =======================================================
   Responsive & Mobile-First Optimization
   Memastikan pengalaman di layar smartphone (HP) benar-benar fit, rapi, dan mudah di-tap.
   ======================================================= */
@media (max-width: 768px) {
    .content-box {
        padding: 1.1rem;
        border-radius: var(--radius-md);
    }
    
    .stat-card .stat-number {
        font-size: 1.75rem;
    }

    .stat-card .icon-wrapper {
        width: 48px;
        height: 48px;
        font-size: 1.4rem;
    }

    .filter-segmented {
        width: 100%;
        display: flex;
    }

    .filter-segmented .btn-filter {
        flex: 1 1 0;
        text-align: center;
        padding: 0.5rem 0.4rem;
        font-size: 0.78rem;
    }

    .custom-table tbody td, .custom-table thead th {
        padding: 0.8rem 0.75rem;
        font-size: 0.82rem;
    }

    .table-responsive {
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        background: #ffffff;
        -webkit-overflow-scrolling: touch;
    }

    /* Target sentuh tombol aksi minimal 38px di HP agar nyaman ditekan */
    .btn-status-toggle .status-pill {
        padding: 0.5rem 0.85rem;
        font-size: 0.78rem;
    }

    .btn-rdm {
        padding: 0.45rem 0.8rem;
        font-size: 0.78rem;
    }
}

@media (max-width: 576px) {
    .container-fluid {
        padding-left: 0.85rem !important;
        padding-right: 0.85rem !important;
    }

    .brand-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .navbar-brand .fs-6 {
        font-size: 0.92rem !important;
    }

    .user-chip {
        padding: 2px 8px 2px 3px;
    }

    .user-chip-avatar {
        width: 26px;
        height: 26px;
        font-size: 0.8rem;
    }

    .btn-logout-nav {
        padding: 5px 10px;
        font-size: 0.75rem;
    }

    .page-header-actions {
        width: 100%;
    }

    .page-header-actions .btn {
        flex: 1 1 0;
        text-align: center;
        justify-content: center;
    }
}
