@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --primary-glow: rgba(99,102,241,0.2);
    --secondary: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;

    --sidebar-width: 255px;
    --header-height: 60px;
    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;

    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.07);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
}

/* ── BASE ── */
*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    overflow-x: hidden;
    margin: 0;
}

/* ── SIDEBAR ── */
.sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-width);
    background: linear-gradient(160deg, #1e1b4b 0%, #0f172a 100%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    border-right: 1px solid rgba(255,255,255,0.05);
}
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.sidebar-brand {
    padding: 1.25rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
    text-decoration: none;
}
.brand-icon {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 20px; flex-shrink: 0;
    box-shadow: 0 4px 15px rgba(99,102,241,0.5);
}
.brand-name { font-size: 1rem; font-weight: 700; color: white; letter-spacing: -0.2px; line-height: 1.2; }
.brand-sub  { font-size: 0.65rem; color: rgba(255,255,255,0.4); font-weight: 500; }

.sidebar-nav { flex: 1; padding: 0.75rem 0.75rem; }
.nav-section-title {
    font-size: 0.6rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 1.2px; color: rgba(255,255,255,0.3);
    padding: 0.75rem 0.5rem 0.3rem;
}
.nav-link {
    display: flex; align-items: center; gap: 0.7rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 0.85rem; font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
}
.nav-link i { font-size: 1rem; width: 18px; text-align: center; flex-shrink: 0; }
.nav-link:hover { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.95); }
.nav-link.active {
    background: linear-gradient(135deg, rgba(99,102,241,0.4), rgba(139,92,246,0.25));
    color: white;
    border: 1px solid rgba(99,102,241,0.3);
}
.nav-link.active i { color: var(--primary-light); }

.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}
.user-card {
    display: flex; align-items: center; gap: 0.7rem;
    padding: 0.6rem 0.75rem; border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.05);
    text-decoration: none; transition: var(--transition);
    cursor: pointer;
}
.user-card:hover { background: rgba(255,255,255,0.1); }
.user-name  { color: rgba(255,255,255,0.9); font-size: 0.8rem; font-weight: 600; }
.user-role  { color: rgba(255,255,255,0.4); font-size: 0.68rem; }

/* ── MAIN ── */
.main-wrapper { margin-left: var(--sidebar-width); min-height: 100vh; display: flex; flex-direction: column; }

.main-header {
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center;
    padding: 0 1.5rem; gap: 1rem;
    position: sticky; top: 0; z-index: 500;
    box-shadow: var(--shadow-xs);
}
.breadcrumb { font-size: 0.8rem; margin: 0; align-items: center; }
.breadcrumb-item + .breadcrumb-item::before { content: "›"; color: var(--text-muted); }
.breadcrumb-item a { color: var(--text-muted); text-decoration: none; }
.breadcrumb-item a:hover { color: var(--primary); }
.breadcrumb-item.active { color: var(--text-secondary); font-weight: 500; }

.main-content { flex: 1; padding: 1.5rem; }

/* ── CARDS ── */
.card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    background: var(--bg-card);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 0.875rem 1.25rem;
    display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 0.875rem; font-weight: 700; color: var(--text-primary); margin: 0; }
.card-body { padding: 1.25rem; }

/* ── STAT CARDS ── */
.stat-card {
    border-radius: var(--radius-lg);
    padding: 1.4rem 1.5rem;
    color: white; position: relative; overflow: hidden;
    border: none;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card .bg-circle-1 {
    position: absolute; top: -25px; right: -15px;
    width: 90px; height: 90px; border-radius: 50%;
    background: rgba(255,255,255,0.12); pointer-events: none;
}
.stat-card .bg-circle-2 {
    position: absolute; bottom: -35px; right: 25px;
    width: 70px; height: 70px; border-radius: 50%;
    background: rgba(255,255,255,0.07); pointer-events: none;
}
.stat-icon {
    width: 44px; height: 44px;
    background: rgba(255,255,255,0.2); border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem; margin-bottom: 1rem;
    position: relative; z-index: 1;
}
.stat-value { font-size: 2rem; font-weight: 800; line-height: 1; letter-spacing: -1px; margin-bottom: 0.2rem; position: relative; z-index: 1; }
.stat-label { font-size: 0.78rem; opacity: 0.85; font-weight: 500; position: relative; z-index: 1; }
.stat-trend { font-size: 0.72rem; opacity: 0.75; margin-top: 0.4rem; position: relative; z-index: 1; }

.sc-indigo  { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.sc-emerald { background: linear-gradient(135deg, #10b981, #059669); }
.sc-amber   { background: linear-gradient(135deg, #f59e0b, #d97706); }
.sc-rose    { background: linear-gradient(135deg, #f43f5e, #e11d48); }
.sc-cyan    { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.sc-violet  { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }

/* ── AVATAR ── */
.avatar {
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; flex-shrink: 0; text-transform: uppercase;
}
.av-xs  { width: 24px; height: 24px; font-size: 0.6rem; }
.av-sm  { width: 32px; height: 32px; font-size: 0.72rem; }
.av-md  { width: 40px; height: 40px; font-size: 0.875rem; }
.av-lg  { width: 56px; height: 56px; font-size: 1.1rem; }
.av-xl  { width: 72px; height: 72px; font-size: 1.5rem; }

/* ── TABLE ── */
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.855rem; }
.data-table thead tr { background: #f8fafc; border-bottom: 2px solid var(--border-color); }
.data-table thead th {
    padding: 0.7rem 1rem; font-size: 0.68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted);
    white-space: nowrap; border: none;
}
.data-table tbody td {
    padding: 0.8rem 1rem; border-bottom: 1px solid #f1f5f9;
    vertical-align: middle; color: var(--text-secondary);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #f8fafc; }

/* ── BADGES ── */
.role-badge {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 2px 9px; border-radius: 20px;
    font-size: 0.7rem; font-weight: 600; white-space: nowrap;
}
.rb-admin   { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.rb-vip     { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }
.rb-user    { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
.rb-default { background: #f1f5f9; color: #64748b; border: 1px solid #e2e8f0; }

.status-badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 9px; border-radius: 20px;
    font-size: 0.7rem; font-weight: 600;
}
.status-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.sb-active   { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }
.sb-active::before { background: #10b981; }
.sb-inactive { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.sb-inactive::before { background: #ef4444; }
.sb-warning  { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }
.sb-warning::before  { background: #f59e0b; }

/* ── FORMS ── */
.form-control, .form-select {
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.575rem 0.875rem;
    font-size: 0.875rem; color: var(--text-primary);
    background: #fff; transition: var(--transition);
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    outline: none;
}
.form-label { font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.3rem; }
.input-group-text {
    background: #f8fafc;
    border: 1.5px solid var(--border-color);
    color: var(--text-muted); font-size: 0.875rem;
}

/* ── BUTTONS ── */
.btn {
    font-size: 0.855rem; font-weight: 600;
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
    transition: var(--transition);
    display: inline-flex; align-items: center; gap: 0.375rem;
    cursor: pointer;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none; color: white;
    box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), #4338ca);
    color: white; transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(99,102,241,0.4);
}
.btn-primary:active { transform: translateY(0); }
.btn-light { background: #fff; border: 1.5px solid var(--border-color); color: var(--text-secondary); }
.btn-light:hover { background: #f8fafc; border-color: #cbd5e1; color: var(--text-primary); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.78rem; border-radius: 6px; }
.btn-icon {
    width: 30px; height: 30px; padding: 0; border-radius: 7px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.85rem; cursor: pointer;
}
.btn-edit   { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
.btn-delete { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.btn-view   { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.btn-edit:hover   { background: #dbeafe; }
.btn-delete:hover { background: #fee2e2; }
.btn-view:hover   { background: #dcfce7; }

/* ── PAGE HEADER ── */
.page-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap;
}
.page-header h1 { font-size: 1.2rem; font-weight: 800; color: var(--text-primary); margin: 0 0 0.15rem; letter-spacing: -0.3px; }
.page-header p  { font-size: 0.78rem; color: var(--text-muted); margin: 0; }

/* ── SEARCH ── */
.search-wrap { position: relative; }
.search-wrap input { padding-left: 2.25rem; }
.search-wrap .si { position: absolute; left: 0.7rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 0.875rem; pointer-events: none; }

/* ── MODALS ── */
.modal-content { border: none; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.modal-header  { border-bottom: 1px solid var(--border-color); padding: 1.1rem 1.5rem; }
.modal-title   { font-size: 0.95rem; font-weight: 700; }
.modal-body    { padding: 1.5rem; }
.modal-footer  { border-top: 1px solid var(--border-color); padding: 0.875rem 1.5rem; }

/* ── DROPDOWN ── */
.dropdown-menu {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 0.35rem; font-size: 0.875rem;
}
.dropdown-item { border-radius: 8px; padding: 0.45rem 0.75rem; color: var(--text-secondary); transition: var(--transition); }
.dropdown-item:hover { background: #f8fafc; color: var(--text-primary); }
.dropdown-item.text-danger:hover { background: #fef2f2; color: #dc2626; }

/* ── CODE BADGE (invite code) ── */
.code-badge {
    font-family: 'Courier New', monospace;
    background: #f1f5f9; border: 1px solid var(--border-color);
    padding: 3px 10px; border-radius: 7px;
    font-size: 0.85rem; color: var(--primary); font-weight: 700;
    letter-spacing: 2px; cursor: pointer; transition: var(--transition);
    display: inline-block;
}
.code-badge:hover { background: var(--primary); color: white; border-color: var(--primary); }

/* ── PERMISSION GRID ── */
.perm-group { border: 1px solid var(--border-color); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 0.75rem; }
.perm-group-header {
    padding: 0.55rem 0.875rem; background: #f8fafc;
    font-weight: 700; font-size: 0.78rem; color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; gap: 0.5rem;
}
.perm-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); }
.perm-item {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.55rem 0.875rem;
    border-right: 1px solid #f1f5f9; border-bottom: 1px solid #f1f5f9;
    font-size: 0.78rem; color: var(--text-secondary); cursor: pointer;
    transition: var(--transition);
}
.perm-item:hover { background: #f8fafc; }
.perm-item input[type="checkbox"] { accent-color: var(--primary); width: 14px; height: 14px; }

/* ── AUTH PAGES ── */
.auth-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 55%, #1a1744 100%);
    display: flex; align-items: center; justify-content: center;
    padding: 2rem; position: relative; overflow: hidden;
}
.auth-page::before {
    content: ''; position: absolute;
    width: 600px; height: 600px; border-radius: 50%;
    background: radial-gradient(circle, rgba(99,102,241,0.15) 0%, transparent 70%);
    top: -120px; left: -200px; pointer-events: none;
}
.auth-page::after {
    content: ''; position: absolute;
    width: 500px; height: 500px; border-radius: 50%;
    background: radial-gradient(circle, rgba(139,92,246,0.1) 0%, transparent 70%);
    bottom: -100px; right: -100px; pointer-events: none;
}
.auth-card {
    background: rgba(255,255,255,0.04);
    backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 24px; padding: 2.5rem;
    width: 100%; max-width: 420px;
    position: relative; z-index: 1;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-logo-icon {
    width: 56px; height: 56px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 16px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 26px; color: white; margin-bottom: 0.75rem;
    box-shadow: 0 8px 25px rgba(99,102,241,0.5);
}
.auth-title    { font-size: 1.5rem; font-weight: 800; color: white; margin: 0; letter-spacing: -0.5px; }
.auth-subtitle { font-size: 0.82rem; color: rgba(255,255,255,0.5); margin: 0.2rem 0 0; }
.auth-form .form-label { color: rgba(255,255,255,0.75); font-size: 0.78rem; font-weight: 600; }
.auth-form .form-control {
    background: rgba(255,255,255,0.08);
    border: 1.5px solid rgba(255,255,255,0.12);
    color: white; font-size: 0.9rem; padding: 0.65rem 1rem;
}
.auth-form .form-control::placeholder { color: rgba(255,255,255,0.3); }
.auth-form .form-control:focus {
    background: rgba(255,255,255,0.12);
    border-color: rgba(99,102,241,0.7);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.2); color: white;
}
.auth-form .input-group-text {
    background: rgba(255,255,255,0.08);
    border: 1.5px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.45);
}
.auth-link { color: var(--primary-light); text-decoration: none; font-size: 0.82rem; }
.auth-link:hover { color: white; }
.auth-divider {
    display: flex; align-items: center; gap: 0.75rem;
    margin: 1.25rem 0; color: rgba(255,255,255,0.3); font-size: 0.75rem;
}
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: rgba(255,255,255,0.1); }

/* ── ANIMATIONS ── */
@keyframes fadeUp { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:translateY(0); } }
.stat-card { animation: fadeUp 0.35s ease both; }
.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.10s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.20s; }
.card { animation: fadeUp 0.3s ease both; }

/* ── FLASH ── */
.alert { border-radius: var(--radius-sm); border: none; font-size: 0.855rem; }

/* ── PAGINATION ── */
.page-link { font-size: 0.8rem; border-radius: 7px; margin: 0 2px; border-color: var(--border-color); color: var(--text-secondary); }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); }
.page-link:hover { border-color: var(--primary); color: var(--primary); }

/* ── MISC ── */
.text-primary-custom { color: var(--primary) !important; }
.fs-xs { font-size: 0.72rem; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.3s ease; }
    .sidebar.open { transform: translateX(0); }
    .main-wrapper { margin-left: 0; }
    .main-content { padding: 1rem; }
}
