@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --secondary: #64748B;
    --success: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
    --dark: #1E293B;
    --light: #F8FAFC;
    --white: #FFFFFF;
    --border: #E2E8F0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--light);
    color: var(--dark);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Login Page */
.login-wrap {
    width: 100%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--primary) 0%, #312E81 100%);
    padding: 20px;
}

.login-card {
    background: var(--white);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
}

.login-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 24px;
    text-align: center;
    color: var(--dark);
}

/* Sidebar & Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

.sidebar {
    width: 250px;
    background-color: var(--dark);
    color: var(--white);
    padding: 20px 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar.active {
    transform: translateX(0) !important;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    padding: 0 20px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 20px;
    text-align: center;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: #CBD5E1;
    text-decoration: none;
    transition: 0.3s;
}

.nav-link:hover,
.nav-link.active {
    background-color: var(--primary);
    color: var(--white);
    border-left: 4px solid #818CF8;
}

.nav-link i {
    width: 24px;
    font-size: 18px;
}

/* Main Content */
.main-content {
    margin-left: 250px;
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    width: calc(100% - 250px);
    transition: margin-left 0.3s ease;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.page-title {
    font-size: 24px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    background: transparent;
    color: var(--dark);
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
}

/* Dashboard Cards */
.grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card-stat {
    background: var(--white);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    border-left: 5px solid var(--primary);
}

.card-stat.success {
    border-left-color: var(--success);
}

.card-stat.warning {
    border-left-color: var(--warning);
}

.card-stat.danger {
    border-left-color: var(--danger);
}

.stat-title {
    font-size: 13px;
    color: var(--secondary);
    font-weight: 500;
    text-transform: uppercase;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    margin-top: 5px;
}

/* Infographic / Charts Section */
.grid-2 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background: var(--white);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

.card-header {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
    display: flex;
    justify-content: space-between;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    min-width: 500px;
}

th,
td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

th {
    background-color: var(--light);
    color: var(--secondary);
    font-weight: 600;
    white-space: nowrap;
}

tr:hover {
    background-color: #F8FAFC;
}

.top-category-block {
    margin-bottom: 0;
}

.top-category-block:last-child {
    margin-bottom: 0;
}

.top-category-select {
    margin-bottom: 14px;
}

.top-category-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #F8FAFC;
    color: var(--dark);
    font-size: 14px;
    font-weight: 700;
}

.top-category-table {
    margin-top: 6px;
}

.top-category-table td:last-child {
    width: 130px;
    text-align: right;
    white-space: nowrap;
}

.empty-state {
    padding: 18px;
    text-align: center;
    color: #999;
}

.badge {
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.badge-danger {
    background: #FEE2E2;
    color: var(--danger);
}

.badge-success {
    background: #D1FAE5;
    color: var(--success);
}

/* Forms & Buttons */
.form-group {
    margin-bottom: 15px;
}

.form-label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    font-weight: 500;
    color: var(--dark);
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    outline: none;
    transition: 0.3s;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.3s;
    color: var(--white);
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--secondary);
}

.btn-secondary:hover {
    background-color: #475569;
}

.btn-danger {
    background-color: var(--danger);
}

.btn-danger:hover {
    background-color: #DC2626;
}

.btn-success {
    background-color: var(--success);
}

.btn-success:hover {
    background-color: #059669;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* Filter Box */
.filter-box {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
    background: var(--white);
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    flex-wrap: wrap;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1050;
    justify-content: center;
    align-items: center;
    padding: 15px;
}

.modal-content {
    background: var(--white);
    padding: 25px;
    border-radius: 10px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: 600;
}

.close {
    cursor: pointer;
    font-size: 24px;
    color: var(--secondary);
}

/* 📱 RESPONSIVE MOBILE */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 15px;
    }

    .mobile-menu-btn {
        display: block;
    }

    .grid-2,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 20px;
    }

    .filter-box {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-box select,
    .filter-box input,
    .filter-box button {
        width: 100% !important;
    }

    .card {
        padding: 15px;
    }

    /* Menyesuaikan jarak grid form di modal */
    div[style*="display:flex; gap:15px;"] {
        flex-direction: column;
        gap: 10px !important;
    }

    div[style*="display:flex; gap:10px; margin-top:10px;"] {
        flex-direction: column;
    }

    /* Responsive Table Tanpa Scroll Samping */
    .table-responsive {
        overflow-x: hidden;
    }

    table {
        min-width: 100%;
        word-break: break-word;
    }

    th,
    td {
        padding: 8px 5px;
        font-size: 11px;
        white-space: normal;
    }

    th {
        font-size: 12px;
    }

    .badge {
        padding: 2px 5px;
        font-size: 10px;
    }

    .top-category-title {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
        padding: 8px;
        font-size: 12px;
    }

    .top-category-select {
        margin-bottom: 10px;
    }

    .top-category-table td:last-child {
        width: 95px;
        white-space: normal;
    }
}
