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

:root {
  --primary: #6B21D6;
  --primary-dark: #5518b0;
  --primary-light: #EDE9FE;
  --primary-mid: #8B5CF6;
  --accent: #F59E0B;
  --danger: #EF4444;
  --success: #10B981;
  --warning: #F59E0B;
  --bg: #F5F3FF;
  --sidebar-bg: #1E0A3C;
  --sidebar-text: #C4B5FD;
  --card-bg: #FFFFFF;
  --text-main: #1E1B2E;
  --text-muted: #6B7280;
  --text-light: #9CA3AF;
  --border: #E5E7EB;
  --border-focus: #8B5CF6;
  --input-bg: #FAFAFA;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 25px rgba(107,33,214,0.12);
  --sidebar-width: 240px;
  --topbar-height: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text-main); min-height: 100vh; }

/* ---- SIDEBAR ---- */
#sidebar-container {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-width); height: 100vh;
  background: var(--sidebar-bg);
  z-index: 100; overflow-y: auto;
  display: flex; flex-direction: column;
}
#sidebar-container .sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.logo-text { font-size: 17px; font-weight: 700; color: #fff; display: flex; align-items: center; gap: 10px; }
.logo-icon {
  width: 36px; height: 36px; background: var(--primary);
  border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.logo-sub { font-size: 11px; color: var(--sidebar-text); margin-top: 2px; font-weight: 400; }
.sidebar-nav { padding: 16px 12px; flex: 1; }
.nav-section-label {
  font-size: 10px; font-weight: 600; color: rgba(196,181,253,0.5);
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0 8px; margin: 16px 0 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--sidebar-text); text-decoration: none;
  font-size: 14px; font-weight: 500;
  margin-bottom: 2px; transition: all 0.18s; cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,0.07); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item svg { flex-shrink: 0; }
.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background 0.18s;
}
.sidebar-user:hover { background: rgba(255,255,255,0.07); }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary); display: flex;
  align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; color: #fff; }
.user-role { font-size: 11px; color: var(--sidebar-text); }

/* ---- TOPBAR ---- */
#topbar-container {
  position: fixed; top: 0;
  left: var(--sidebar-width); right: 0;
  height: var(--topbar-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  z-index: 90;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
}
.topbar-title { font-size: 18px; font-weight: 700; color: var(--text-main); }

/* ---- MAIN ---- */
.main-content { margin-left: var(--sidebar-width); padding-top: var(--topbar-height); min-height: 100vh; }
.page-content { padding: 28px; }

/* ---- STATS ---- */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
  border: 1px solid var(--border);
}
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon.purple { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: #D1FAE5; color: #065F46; }
.stat-icon.amber { background: #FEF3C7; color: #92400E; }
.stat-icon.blue { background: #DBEAFE; color: #1E40AF; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text-main); }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-top: 2px; }

/* ---- CARD ---- */
.card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); overflow: hidden; }
.card-header { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 15px; font-weight: 700; color: var(--text-main); }
.card-body { padding: 20px; }

/* ---- BUTTONS ---- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; cursor: pointer; border: none; transition: all 0.18s; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { width: 34px; height: 34px; padding: 0; justify-content: center; border-radius: var(--radius-sm); }
.btn-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); line-height: 1; display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 6px; }
.btn-close:hover { background: var(--bg); }

/* ---- TABLE ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { padding: 12px 16px; text-align: left; background: var(--bg); color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--border); }
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); color: var(--text-main); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FAFAFA; }
.td-img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; }

/* ---- BADGES ---- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-purple { background: var(--primary-light); color: var(--primary); }
.badge-green { background: #D1FAE5; color: #065F46; }
.badge-amber { background: #FEF3C7; color: #92400E; }
.badge-red { background: #FEE2E2; color: #991B1B; }
.badge-gray { background: #F3F4F6; color: #4B5563; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-main); margin-bottom: 6px; }
.form-control { width: 100%; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; font-family: inherit; background: var(--input-bg); color: var(--text-main); transition: border-color 0.18s; outline: none; }
.form-control:focus { border-color: var(--border-focus); background: #fff; }
.form-control::placeholder { color: var(--text-light); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ---- MODAL ---- */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 200; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: var(--card-bg); border-radius: var(--radius); width: 90%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--card-bg); z-index: 1; }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; position: sticky; bottom: 0; background: var(--card-bg); }

/* ---- SEARCH ---- */
.search-bar { display: flex; align-items: center; gap: 8px; padding: 9px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--input-bg); transition: border-color 0.18s; }
.search-bar:focus-within { border-color: var(--border-focus); }
.search-bar input { border: none; outline: none; font-size: 13px; background: transparent; flex: 1; font-family: inherit; }

/* ---- TOGGLE ---- */
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: #D1D5DB; border-radius: 22px; cursor: pointer; transition: 0.2s; }
.toggle-slider:before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: 0.2s; }
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider:before { transform: translateX(18px); }

/* ---- ALERTS ---- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.alert-success { background: #D1FAE5; color: #065F46; }
.alert-danger { background: #FEE2E2; color: #991B1B; }
.alert-info { background: var(--primary-light); color: var(--primary); }

/* ---- EMPTY STATE ---- */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-state-icon { margin-bottom: 12px; display: flex; justify-content: center; color: var(--text-muted); }
.empty-state h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.empty-state p { font-size: 13px; color: var(--text-muted); }

/* ---- UPLOAD ---- */
.upload-area { border: 2px dashed var(--border); border-radius: var(--radius-sm); padding: 20px; text-align: center; cursor: pointer; transition: all 0.18s; background: var(--input-bg); }
.upload-area:hover { border-color: var(--primary); background: var(--primary-light); }
.upload-area.uploading { opacity: 0.7; pointer-events: none; }

/* ---- TOAST ---- */
.toast { position: fixed; bottom: 24px; right: 24px; padding: 12px 20px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; color: #fff; z-index: 9999; box-shadow: var(--shadow-md); transform: translateY(100px); opacity: 0; transition: all 0.3s; pointer-events: none; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ---- SPINNER ---- */
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- AUTH LOADING ---- */
.auth-loading { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 9999; flex-direction: column; gap: 12px; }
.auth-loading .spinner { width: 32px; height: 32px; border: 3px solid var(--primary-light); border-top-color: var(--primary); }
.auth-loading p { font-size: 13px; color: var(--text-muted); font-weight: 500; }

/* ---- ICON PREVIEW ---- */
.icon-preview { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 8px 12px; background: var(--primary-light); border-radius: var(--radius-sm); font-size: 13px; color: var(--primary); }

@media (max-width: 1024px) { .stats-grid { grid-template-columns: repeat(2,1fr); } }
