/* ===== Google Fonts ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ===== CSS Variables ===== */
:root {
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --primary-light: #e8f0fe;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #0f172a;
    --sidebar-width: 260px;
    --topbar-height: 0px;
    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset & Base ===== */
* {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
    background-color: var(--body-bg);
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: #fff;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-brand {
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    text-decoration: none;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-brand:hover {
    color: #fff;
}

.sidebar-brand-icon {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.sidebar-brand-text {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
}

.sidebar-brand-text small {
    display: block;
    font-weight: 400;
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0;
    overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

.sidebar-heading {
    padding: 1rem 1.5rem 0.5rem;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.5rem;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 400;
    transition: var(--transition);
    border-left: 3px solid transparent;
    margin: 1px 0;
}

.sidebar-link i {
    font-size: 1.15rem;
    width: 22px;
    text-align: center;
    opacity: 0.7;
    transition: var(--transition);
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-link:hover i {
    opacity: 1;
}

.sidebar-link.active {
    background: var(--sidebar-active);
    color: #fff;
    border-left-color: var(--primary);
}

.sidebar-link.active i {
    color: var(--primary);
    opacity: 1;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-email {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-logout {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 1.1rem;
    padding: 4px;
    border-radius: 6px;
    transition: var(--transition);
    display: flex;
    align-items: center;
}

.sidebar-logout:hover {
    color: var(--danger);
    background: rgba(239,68,68,0.1);
}

/* ===== Main Content ===== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.content-wrapper {
    padding: 2rem;
    max-width: 1400px;
}

/* ===== Mobile Topbar ===== */
.mobile-topbar {
    display: none;
    position: sticky;
    top: 0;
    z-index: 1030;
    background: var(--sidebar-bg);
    padding: 0.75rem 1rem;
    align-items: center;
    justify-content: space-between;
}

.mobile-toggle {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    padding: 0.25rem;
    cursor: pointer;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1035;
}

/* ===== Page Header ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin: 0;
}

.page-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0.25rem 0 0 0;
}

/* ===== Cards ===== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.card-body {
    padding: 1.25rem;
}

.stat-card {
    border: none;
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
}

.stat-card .card-body {
    padding: 1.5rem;
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===== Tables ===== */
.table-card {
    border-radius: var(--radius);
    overflow: hidden;
}

.table {
    margin: 0;
    font-size: 0.875rem;
}

.table thead th {
    background: #f8fafc;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.table tbody td {
    padding: 0.875rem 1.25rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-primary);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover {
    background: #f8fafc;
}

/* ===== Badges ===== */
.badge {
    font-weight: 500;
    font-size: 0.7rem;
    padding: 0.35em 0.7em;
    border-radius: 6px;
    letter-spacing: 0.02em;
}

.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.badge-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.badge-status.active {
    background: #dcfce7;
    color: #166534;
}
.badge-status.inactive {
    background: #f1f5f9;
    color: #475569;
}
.badge-status.active::before { background: #16a34a; }
.badge-status.inactive::before { background: #94a3b8; }

.badge-group {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 500;
}

.badge-admin {
    background: #fef2f2;
    color: #dc2626;
}

.badge-user {
    background: #f0fdf4;
    color: #16a34a;
}

/* ===== Buttons ===== */
.btn {
    font-weight: 500;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
    padding: 0.5rem 1.15rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: -0.01em;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 1px 2px rgba(26,115,232,0.3);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(26,115,232,0.4);
    transform: translateY(-1px);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--border-color);
}

.btn-outline-primary:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-outline-secondary {
    color: var(--text-secondary);
    border-color: var(--border-color);
}

.btn-outline-secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: var(--text-primary);
}

.btn-outline-danger {
    color: var(--danger);
    border-color: var(--border-color);
}

.btn-outline-danger:hover {
    background: #fef2f2;
    border-color: var(--danger);
    color: var(--danger);
}

.btn-outline-warning {
    color: var(--warning);
    border-color: var(--border-color);
}

.btn-outline-warning:hover {
    background: #fffbeb;
    border-color: var(--warning);
    color: var(--warning);
}

.btn-outline-success {
    color: var(--success);
    border-color: var(--border-color);
}

.btn-outline-success:hover {
    background: #f0fdf4;
    border-color: var(--success);
    color: var(--success);
}

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
    border-radius: 6px;
}

.btn-lg {
    padding: 0.7rem 1.5rem;
    font-size: 0.95rem;
}

/* ===== Forms ===== */
.form-label {
    display: block;
    width: 100%;
    font-weight: 500;
    font-size: 0.825rem;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
}

.form-control, .form-select {
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.9rem;
    font-size: 0.875rem;
    transition: var(--transition);
    color: var(--text-primary);
    background-color: #fff;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,115,232,0.15);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-check-input {
    width: 1.1em;
    height: 1.1em;
    border: 1.5px solid #cbd5e1;
    border-radius: 4px;
    transition: var(--transition);
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(26,115,232,0.15);
}

.form-check-label {
    font-size: 0.85rem;
}

.form-text {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.invalid-feedback {
    font-size: 0.78rem;
}

/* ===== Alerts ===== */
.alert {
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.8rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-success {
    background: #f0fdf4;
    color: #15803d;
}

.alert-danger {
    background: #fef2f2;
    color: #dc2626;
}

.alert-warning {
    background: #fffbeb;
    color: #b45309;
}

.alert-info {
    background: #eff6ff;
    color: #1d4ed8;
}

/* ===== Login Page ===== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, var(--primary), #4f46e5);
    padding: 2rem 2rem 1.75rem;
    text-align: center;
    color: #fff;
}

.login-header-icon {
    width: 56px;
    height: 56px;
    background: rgba(255,255,255,0.2);
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    backdrop-filter: blur(10px);
}

.login-header h3 {
    font-weight: 700;
    font-size: 1.35rem;
    margin-bottom: 0.25rem;
}

.login-header p {
    opacity: 0.85;
    font-size: 0.85rem;
    margin: 0;
}

.login-body {
    padding: 2rem;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    display: block;
}

.empty-state p {
    font-size: 0.9rem;
    margin: 0;
}

/* ===== Action Buttons Group ===== */
.action-btns {
    display: flex;
    gap: 0.35rem;
    justify-content: flex-end;
}

/* ===== Group Checkbox List ===== */
.group-checkbox-list {
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    max-height: 200px;
    overflow-y: auto;
    background: #fff;
}

.group-checkbox-list .form-check {
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
}

/* ===== Responsive ===== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .sidebar-overlay.show {
        display: block;
    }

    .mobile-topbar {
        display: flex;
    }

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

    .content-wrapper {
        padding: 1.25rem;
    }
}

@media (max-width: 575.98px) {
    .content-wrapper {
        padding: 1rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-title {
        font-size: 1.25rem;
    }
}
