@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700;800&display=swap');

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --white: #ffffff;
    --background: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.9);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --glass: rgba(255, 255, 255, 0.7);
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --sidebar-width: 270px;
    --sidebar-mini: 72px;
    --header-h: 60px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--background);
    background-image: radial-gradient(at 0% 0%, hsla(225, 39%, 30%, 1) 0, transparent 50%),
        radial-gradient(at 50% 0%, hsla(225, 39%, 20%, 1) 0, transparent 50%),
        radial-gradient(at 100% 0%, hsla(225, 39%, 30%, 1) 0, transparent 50%);
    min-height: 100vh;
    color: var(--text-main);
}

.auth-body {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ==================== Login Card ==================== */
.login-container {
    width: 100%;
    max-width: 450px;
    padding: 20px;
}

.login-card {
    background: var(--glass);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 24px;
    padding: 40px;
    box-shadow: var(--shadow);
    text-align: center;
    animation: fadeIn 0.8s ease-out;
}

.login-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-muted);
    margin-bottom: 30px;
    font-size: 0.95rem;
}

/* ==================== Forms ==================== */
.form-group {
    text-align: left;
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: white;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 12px;
    background: var(--primary);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3);
}

.footer-text {
    margin-top: 25px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== Dashboard Layout ==================== */
.dashboard-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
    background: #f1f5f9;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--white);
    border-right: 1px solid #e2e8f0;
    padding: 25px 12px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.3s ease, min-width 0.3s ease, padding 0.3s ease;
    z-index: 100;
    flex-shrink: 0;
}

/* Scrollbar sidebar */
.sidebar::-webkit-scrollbar {
    width: 3px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

.sidebar-logo {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 28px;
    padding: 0 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.nav-menu {
    list-style: none;
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-menu::-webkit-scrollbar {
    width: 3px;
}

.nav-menu::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

.nav-item {
    margin-bottom: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.18s ease;
    white-space: nowrap;
    overflow: hidden;
}

.nav-link-icon {
    font-size: 1.15rem;
    min-width: 22px;
    display: inline-flex;
    justify-content: center;
    flex-shrink: 0;
}

.nav-link span:not(.nav-link-icon) {
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-link:hover,
.nav-link.active {
    background: #eff6ff;
    color: var(--primary);
}

.sidebar-footer {
    flex-shrink: 0;
    padding-top: 10px;
    border-top: 1px solid #f1f5f9;
}

/* ==================== MOBILE HEADER (always in DOM) ==================== */
.mobile-header {
    display: none;
    /* hidden by default, shown via CSS on small screens */
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: var(--header-h);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9000;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.07);
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
}

.mobile-logo {
    font-weight: 800;
    color: var(--primary);
    font-size: 1.05rem;
    letter-spacing: -0.3px;
}

.menu-toggle {
    width: 42px;
    height: 42px;
    background: #eff6ff;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--primary);
    font-size: 1.2rem;
    border: none;
    flex-shrink: 0;
    transition: background 0.2s;
}

.menu-toggle:hover {
    background: #dbeafe;
}

/* Sidebar Close Button (visible only on mobile) */
.sidebar-close {
    display: none;
    position: absolute;
    right: 14px;
    top: 14px;
    font-size: 1.1rem;
    color: var(--text-muted);
    cursor: pointer;
    background: #f1f5f9;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: none;
    z-index: 10;
    transition: background 0.2s;
}

.sidebar-close:hover {
    background: #e2e8f0;
}

/* Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 8999;
}

.sidebar-overlay.active {
    display: block;
}

/* ==================== Main Content ==================== */
.main-content {
    flex-grow: 1;
    padding: 40px;
    min-width: 0;
    overflow-x: hidden;
}

/* ==================== Header Content ==================== */
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-name {
    font-weight: 600;
}

/* ==================== Stats ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--white);
    padding: 24px;
    border-radius: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
}

/* ==================== Table ==================== */
.table-container {
    background: var(--white);
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding-bottom: 15px;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}

td {
    padding: 12px 0;
    border-top: 1px solid #f1f5f9;
}

/* ==================== Buttons ==================== */
.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: 8px;
    text-decoration: none;
    display: inline-block;
    font-weight: 600;
}

.bg-primary {
    background: var(--primary);
    color: white;
}

.bg-success {
    background: var(--success);
    color: white;
}

/* ==================== RESPONSIVE: Tablet / Mini Sidebar 651–1024px ==================== */
@media (min-width: 651px) and (max-width: 1024px) {
    .sidebar {
        width: var(--sidebar-mini);
        min-width: var(--sidebar-mini);
        padding: 25px 8px;
        align-items: center;
    }

    .sidebar-logo {
        font-size: 0;
        /* hide text */
        padding: 0;
        text-align: center;
        margin-bottom: 30px;
    }

    .sidebar-logo::before {
        content: '📘';
        font-size: 1.5rem;
        display: block;
    }

    .nav-link {
        justify-content: center;
        padding: 12px 0;
        width: 100%;
        gap: 0;
        position: relative;
    }

    /* Tooltip on hover */
    .nav-link::after {
        content: attr(data-label);
        position: absolute;
        left: calc(var(--sidebar-mini) + 8px);
        background: #1e293b;
        color: white;
        padding: 5px 10px;
        border-radius: 8px;
        font-size: 0.8rem;
        white-space: nowrap;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.15s;
        z-index: 999;
    }

    .nav-link:hover::after {
        opacity: 1;
    }

    .nav-link span:not(.nav-link-icon) {
        display: none;
    }

    .nav-link-icon {
        margin: 0;
        font-size: 1.3rem;
    }

    .sidebar-footer .nav-link {
        justify-content: center;
    }

    /* Section label (Pengaturan Data) */
    .sidebar .nav-section-label {
        display: none;
    }

    .main-content {
        padding: 30px 20px;
    }

    /* Collapse arrow hidden in mini mode */
    #admin-menu-arrow {
        display: none !important;
    }

    /* Always show submenu in mini mode */
    #admin-menu-container {
        display: block !important;
    }
}

/* ==================== RESPONSIVE: Mobile ≤650px ==================== */
@media (max-width: 650px) {

    /* Show mobile header */
    .mobile-header {
        display: flex;
    }

    /* Show close button inside sidebar */
    .sidebar-close {
        display: flex;
    }

    /* Dashboard wrapper becomes block */
    .dashboard-wrapper {
        display: block;
    }

    /* Sidebar slides in from left */
    .sidebar {
        position: fixed;
        top: 0;
        left: -290px;
        bottom: 0;
        width: 270px;
        min-width: 270px;
        height: 100%;
        z-index: 9100;
        transition: left 0.32s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 30px rgba(0, 0, 0, 0.15);
        padding-top: 20px;
        border-right: none;
        overflow-y: auto;
    }

    .sidebar.active {
        left: 0;
    }

    /* Push main content down for fixed header */
    .main-content {
        padding: 80px 14px 40px;
        width: 100%;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .header-content .btn-sm,
    .header-content .btn {
        width: 100%;
        text-align: center;
        padding: 11px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .table-container {
        padding: 12px;
        border-radius: 14px;
    }
}

@media (max-width: 400px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}