/* Layout Wrapper */
.wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--dark);
    color: #fff;
    transition: var(--transition);
    position: fixed;
    height: 100vh;
    z-index: 1000;
    overflow-y: auto;
    box-shadow: 4px 0 10px rgba(0,0,0,0.1);
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar-header {
    padding: 1.5rem;
    text-align: center;
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 1px;
    background: linear-gradient(45deg, #4cc9f0, #4361ee);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-menu {
    list-style: none;
    padding: 1rem 0;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    padding: 0.8rem 1.5rem;
    color: #adb5bd;
    font-size: 0.95rem;
    font-weight: 500;
    border-left: 3px solid transparent;
}

.sidebar-menu li a i {
    margin-right: 12px;
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.sidebar-menu li a:hover,
.sidebar-menu li a.active {
    color: #fff;
    background: rgba(255,255,255,0.05);
    border-left-color: var(--primary);
}

.menu-header {
    padding: 1rem 1.5rem 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #6c757d;
    font-weight: 700;
    letter-spacing: 0.5px;
}

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

.main-content.expanded {
    margin-left: 0;
}

.topbar {
    background: #fff;
    height: 70px;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 999;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

#sidebar-toggle {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

#sidebar-toggle:hover {
    color: var(--primary);
}

.page-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
}

.user-name {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.content {
    padding: 2rem;
    flex: 1;
}

/* =========================================
   DASHBOARD STATS GRID - Modern Clean Style
   ========================================= */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Stats Grid: 5 kolom ringkasan operasional */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

@media (max-width: 1280px) {
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 860px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* ---- Card Stat Base ---- */
.card-stat {
    --accent: #6366f1;  /* default; overridden per-card via data-accent */
    background: #ffffff;
    border-radius: 16px;
    /* compact padding: top/right/bottom/left */
    padding: 1.1rem 1.2rem 1.2rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05), 0 4px 12px rgba(0,0,0,0.06);
    border: 1px solid #eef2f7;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    position: relative;
    overflow: visible;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    cursor: default;
}

.card-stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.09);
}

/* ---- Icon: absolute circle pojok kanan atas ---- */
.card-stat-icon {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 34px;
    height: 34px;
    min-width: 34px;
    background: color-mix(in srgb, var(--accent) 11%, transparent);
    border-radius: 50%;  /* lingkaran */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    color: var(--accent);
    transition: background 0.18s ease, transform 0.18s ease;
}

.card-stat:hover .card-stat-icon {
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    transform: scale(1.08);
}

/* ---- Top row: label (kiri), icon sudah absolute ---- */
.card-stat-top {
    display: flex;
    align-items: center;
    /* padding-right agar label tidak tertimpa icon */
    padding-right: 42px;
    min-height: 34px;  /* align dengan tinggi icon */
}

.card-stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Value: angka besar sebagai fokus utama ---- */
.card-stat-value {
    font-size: 2.25rem;  /* ≈ 36px */
    font-weight: 700;
    color: #0f172a;
    line-height: 1;
    letter-spacing: -1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* ruang kanan agar tidak bertabrakan dengan icon saat value panjang */
    padding-right: 42px;
}

/* Currency: auto-scale agar Rp 41.965.000 selalu 1 baris */
.card-stat-value.is-currency {
    font-size: clamp(1.15rem, 2vw, 1.65rem);
    letter-spacing: -0.5px;
    white-space: nowrap;
}

/* ---- Accent warna per card ---- */
.card-stat[data-accent="indigo"]  { --accent: #6366f1; }
.card-stat[data-accent="cyan"]    { --accent: #0891b2; }
.card-stat[data-accent="amber"]   { --accent: #d97706; }
.card-stat[data-accent="emerald"] { --accent: #059669; }
.card-stat[data-accent="violet"]  { --accent: #7c3aed; }

.card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05), 0 10px 15px rgba(0, 0, 0, 0.025);
    margin-bottom: 2rem;
    overflow: hidden;
}

.card-header {
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.card-body {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Print CSS */
@media print {
    .sidebar, .topbar, .btn, .action-column {
        display: none !important;
    }
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    .content {
        padding: 0 !important;
    }
    .card {
        box-shadow: none !important;
        border: none !important;
    }
    body {
        background: #fff;
    }
    @page { margin: 1cm; size: A4 portrait; }
}

/* Login Page */
.login-page {
    background: linear-gradient(135deg, #f0f4f8 0%, #d9e2ec 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
}

.login-card {
    background: #fff;
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-icon {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.login-card h2 {
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.login-card p {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.login-form {
    text-align: left;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Helpers */
.text-center { text-align: center; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mt-3 { margin-top: 1rem; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.d-flex { display: flex; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }

/* Responsive Design */
@media (max-width: 1024px) {
    .dashboard-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 10px rgba(0,0,0,0.1);
    }
    .main-content {
        margin-left: 0;
    }
    .topbar {
        padding: 0 1rem;
    }
    .user-name {
        font-size: 0;
    }
    .user-name i {
        font-size: 1.5rem;
    }
    .content {
        padding: 1rem;
    }
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .card-header .btn {
        width: 100%;
        margin-top: 0.5rem;
    }
    .dashboard-cards {
        grid-template-columns: 1fr;
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }
    .sidebar-overlay.active {
        display: block;
    }
    .table td .btn {
        margin-bottom: 5px;
    }
    /* Forms inside cards should take full width */
    .form-group, .form-control {
        width: 100% !important;
    }
    .form-group {
        flex: 0 0 100% !important;
        min-width: 100% !important;
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 1.5rem;
    }
    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    .form-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    .table th, .table td {
        padding: 0.8rem 0.5rem;
        font-size: 0.9rem;
    }
}

/* Utilities */
.mt-auto { margin-top: auto !important; }

/* Dashboard Top Prioritas Cards - force equal height and bottom-aligned buttons */
.dashboard-cards > .card {
    margin-bottom: 0;
}

.dashboard-cards > .card > .card-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    flex: 1;
}

.dashboard-cards > .card > .card-body > h2 {
    min-height: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
}

.dashboard-cards > .card > .card-body > a.btn {
    margin-top: auto;
}

/* Table Pagination Styles */
.table-pagination .btn-page {
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid #dee2e6;
    background: #fff;
    color: var(--primary);
    transition: var(--transition);
    cursor: pointer;
}
.table-pagination .btn-page:hover:not(:disabled) {
    background: #f8f9fa;
    border-color: var(--primary);
}
.table-pagination .btn-page.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.table-pagination .btn-page:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: #dee2e6;
    color: #6c757d;
}

@media print {
    .table-pagination {
        display: none !important;
    }
    .table tbody tr {
        display: table-row !important;
    }
}
