/* ===== Reset & Base ===== */
:root {
    --primary: #0072ff;
    --primary-dark: #005bb5;
    --secondary: #00c6ff;
    --bg-light: #f4f7fd;
    --text-dark: #333;
    --text-muted: #777;
    --white: #ffffff;
    --shadow: 0 5px 20px rgba(0, 0, 0, 0.05);
    --radius: 15px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
    text-decoration: none;
}

body {
    background: var(--bg-light);
    color: var(--text-dark);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 260px;
    background: var(--primary);
    color: var(--white);
    display: flex;
    flex-direction: column;
    padding: 20px;
    transition: 0.3s;
    flex-shrink: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.sidebar-header i {
    font-size: 32px;
}

.sidebar-header h2 {
    font-size: 24px;
    font-weight: 700;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.nav-links li a {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 15px;
    color: rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    transition: 0.3s;
    font-size: 15px;
    font-weight: 500;
}

.nav-links li a:hover,
.nav-links li a.active {
    background: rgba(255, 255, 255, 0.15);
    color: var(--white);
    transform: translateX(5px);
}

.nav-links li a i {
    font-size: 20px;
}

.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding-top: 20px;
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255, 255, 255, 0.8);
    transition: 0.3s;
}

.sidebar-footer a:hover {
    color: var(--white);
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: relative;
}

/* Topbar */
.topbar {
    background: var(--white);
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar h1 {
    font-size: 22px;
    color: var(--text-dark);
    font-weight: 600;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-profile span {
    font-weight: 600;
    color: var(--primary);
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: #e3f2fd;
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
}

/* Dashboard Content */
.dashboard-content {
    padding: 30px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--white);
    padding: 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 28px;
}

/* Icon Colors */
.icon-blue {
    background: #e3f2fd;
    color: #0072ff;
}

.icon-pink {
    background: #fce4ec;
    color: #e91e63;
}

.icon-green {
    background: #e8f5e9;
    color: #43a047;
}

.icon-orange {
    background: #fff3e0;
    color: #fb8c00;
}

.icon-purple {
    background: #f3e5f5;
    color: #8e24aa;
}

.stat-info h3 {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 5px;
}

.stat-info h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-dark);
}

/* Alert */
.alert {
    background: #eeffe0;
    color: #2e7d32;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    border-left: 5px solid #2e7d32;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Table Section */
.table-section {
    background: var(--white);
    padding: 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.table-header {
    margin-bottom: 20px;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 10px;
}

.table-header h3 {
    color: var(--primary);
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-response {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
}

th,
td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}

th {
    background: #f8f9fa;
    color: var(--text-dark);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

tr:hover {
    background: #f8f9fa;
}

.badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge.laki {
    background: #e3f2fd;
    color: #0072ff;
}

.badge.perempuan {
    background: #fce4ec;
    color: #e91e63;
}

.btn-action {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    transition: 0.3s;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn-delete {
    background: #fee2e2;
    color: #ef4444;
}

.btn-delete:hover {
    background: #fecaca;
}

.btn-edit {
    background: #e3f2fd;
    color: #0072ff;
}

.btn-edit:hover {
    background: #bbdefb;
}

/* Form Styles */
.form-card {
    background: var(--white);
    padding: 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    max-width: 600px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-dark);
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-size: 14px;
    transition: 0.3s;
}

.form-control:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 4px rgba(0, 114, 255, 0.1);
}

.btn-primary {
    background: var(--primary);
    color: white;
    padding: 12px;
    border-radius: 10px;
    width: 100%;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: 0.3s;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

/* Responsive */
/* Navigation Toggle (Checkbox Hack) */
#nav-toggle {
    display: none;
}

.nav-toggle-label {
    display: none;
    font-size: 26px;
    cursor: pointer;
    margin-right: 15px;
    color: var(--text-dark);
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 900;
    opacity: 0;
    visibility: hidden;
    transition: 0.3s;
}

#nav-toggle:checked~.sidebar-overlay {
    opacity: 1;
    visibility: visible;
}

/* Responsive */
@media(max-width: 900px) {
    body {
        overflow-x: hidden;
        /* Prevent horizontal scroll */
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        width: 280px;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
        box-shadow: 4px 0 15px rgba(0, 0, 0, 0.1);
        flex-direction: column;
        align-items: stretch;
        overflow-y: auto;
        /* Allow scrolling if content is tall */
    }

    /* Show sidebar when checked */
    #nav-toggle:checked~.sidebar {
        transform: translateX(0);
    }

    .nav-toggle-label {
        display: block;
    }

    .main-content {
        width: 100%;
        overflow-x: hidden;
    }

    /* Ensure internal sidebar elements look good on mobile */
    .sidebar-header {
        margin-bottom: 20px;
        padding-bottom: 20px;
        justify-content: flex-start;
        border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    }

    .nav-links {
        flex-direction: column;
        overflow-x: hidden;
        flex: 0 0 auto;
        /* Fix: use auto basis so it takes content height, not 0 */
        margin-bottom: 20px;
    }

    .nav-links li a {
        justify-content: flex-start;
    }

    .sidebar-footer {
        display: block;
        /* Show footer again */
    }

    /* Adjust Stats Grid for Mobile */
    .stats-grid {
        grid-template-columns: 1fr;
        /* Single column on small screens */
    }

    /* Adjust Topbar */
    .topbar {
        padding: 15px 20px;
    }

    .topbar h1 {
        font-size: 18px;
    }
}

/* ===== Login Styles ===== */
.login-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    z-index: 1000;
}

@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-box h2 {
    margin-bottom: 5px;
    color: var(--primary);
}

.subtitle {
    font-size: 14px;
    color: #666;
    margin-bottom: 30px;
}

.login-container form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.login-container input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #eee;
    background: #fdfdfd;
    border-radius: 10px;
    outline: none;
    transition: 0.3s;
    font-size: 14px;
}

.login-container input:focus {
    border-color: var(--primary);
    background: white;
}

.login-container button {
    background: var(--primary);
    color: white;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.3s;
    margin-top: 10px;
}

.login-container button:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 114, 255, 0.3);
}

.error {
    background: #ffebee;
    color: #c62828;
    padding: 10px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 20px;
    border-left: 4px solid #c62828;
    text-align: left;
}