@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --sidebar-w: 260px;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;

  /* Light mode */
  --sidebar-bg: #ffffff;
  --sidebar-text: #64748b;
  --sidebar-text-hover: #0f172a;
  --sidebar-border: #e2e8f0;
  --nav-hover-bg: rgba(0,0,0,0.04);
  --nav-active-bg: #0f172a;
  --nav-active-color: #ffffff;
  --nav-active-border: #0f172a;
  --content-bg: #f1f5f9;
  --card-bg: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --topbar-bg: #ffffff;
  --input-bg: #f8fafc;
  --hover-bg: #f1f5f9;
  --table-head-bg: #f8fafc;
  --table-hover: #f8fafc;
}

body.dark {
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-text-hover: #f1f5f9;
  --sidebar-border: rgba(255,255,255,0.07);
  --nav-hover-bg: rgba(255,255,255,0.06);
  --nav-active-bg: #ffffff;
  --nav-active-color: #0f172a;
  --nav-active-border: #ffffff;
  --content-bg: #0a0f1e;
  --card-bg: #1e293b;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --border: rgba(255,255,255,0.08);
  --topbar-bg: #1e293b;
  --input-bg: rgba(255,255,255,0.06);
  --hover-bg: rgba(255,255,255,0.06);
  --table-head-bg: rgba(255,255,255,0.04);
  --table-hover: rgba(255,255,255,0.03);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--content-bg);
  color: var(--text-primary);
  transition: background 0.2s, color 0.2s;
}

/* ─── LAYOUT ─── */
.layout { display: flex; min-height: 100vh; }

/* ─── SIDEBAR ─── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: background 0.2s, border-color 0.2s;
}

.sidebar-logo {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-logo-icon {
  width: 38px; height: 38px;
  background: #0f172a;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
body.dark .sidebar-logo-icon { box-shadow: 0 0 0 1px rgba(255,255,255,0.12); }
.sidebar-logo-name { font-size: 18px; font-weight: 800; color: var(--text-primary); letter-spacing: -0.5px; }
.sidebar-logo-sub  { font-size: 10px; color: var(--sidebar-text); text-transform: uppercase; letter-spacing: 1px; }

/* Search */
.sidebar-search { padding: 16px 16px 4px; }
.search-wrap { position: relative; }
.search-wrap i {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--sidebar-text); font-size: 16px; pointer-events: none;
}
.sidebar-search input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--sidebar-border);
  border-radius: 8px;
  padding: 9px 12px 9px 34px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
.sidebar-search input::placeholder { color: var(--sidebar-text); }
.sidebar-search input:focus { border-color: rgba(59,130,246,0.5); }

/* Nav */
.sidebar-nav { flex: 1; padding: 8px 12px; overflow-y: auto; }
.nav-section { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--sidebar-text); opacity: 0.7; padding: 16px 8px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--sidebar-text);
  font-size: 14px; font-weight: 500;
  transition: all 0.15s;
  text-decoration: none;
  margin-bottom: 2px;
  border-left: 3px solid transparent;
  user-select: none;
}
.nav-item:hover { background: var(--nav-hover-bg); color: var(--sidebar-text-hover); }
.nav-item.active { background: var(--nav-active-bg); color: var(--nav-active-color); border-left-color: var(--nav-active-border); }
.nav-item.disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.nav-item i { font-size: 18px; width: 20px; display: flex; align-items: center; justify-content: center; }
.nav-soon { margin-left: auto; font-size: 10px; background: rgba(148,163,184,0.15); color: var(--sidebar-text); padding: 2px 6px; border-radius: 4px; font-weight: 500; }

/* Sidebar footer */
.sidebar-footer { padding: 12px; border-top: 1px solid var(--sidebar-border); display: flex; flex-direction: column; gap: 2px; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; margin-bottom: 4px; }
.user-avatar {
  width: 32px; height: 32px;
  background: #0f172a; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: white; flex-shrink: 0;
}
body.dark .user-avatar { box-shadow: 0 0 0 1px rgba(255,255,255,0.15); }
.user-name { font-size: 13px; font-weight: 500; color: var(--text-primary); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-action-btn {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 9px 12px;
  background: none; border: none; cursor: pointer;
  color: var(--sidebar-text);
  font-size: 14px; font-weight: 500; font-family: inherit;
  border-radius: 8px; border-left: 3px solid transparent;
  transition: all 0.15s; text-align: left;
}
.sidebar-action-btn:hover { background: var(--nav-hover-bg); color: var(--sidebar-text-hover); }
.sidebar-action-btn i { font-size: 18px; width: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sidebar-action-btn.danger:hover { background: rgba(239,68,68,0.08); color: var(--danger); }

/* ─── MAIN ─── */
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
  transition: background 0.2s, border-color 0.2s;
}
.topbar-title { font-size: 20px; font-weight: 700; }
.topbar-sub { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.theme-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary);
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  transition: all 0.15s;
}
.theme-toggle:hover { background: var(--hover-bg); color: var(--text-primary); }

.page { padding: 32px; flex: 1; }

/* ─── STATS ─── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 20px; margin-bottom: 28px; }
.stat-card { background: var(--card-bg); border-radius: 12px; padding: 20px; border: 1px solid var(--border); display: flex; align-items: center; gap: 16px; transition: background 0.2s; }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.stat-icon.blue   { background: rgba(59,130,246,0.1); color: var(--accent); }
.stat-icon.green  { background: rgba(34,197,94,0.1);  color: #16a34a; }
.stat-icon.orange { background: rgba(245,158,11,0.1); color: #d97706; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* ─── CARD ─── */
.card { background: var(--card-bg); border-radius: 12px; border: 1px solid var(--border); overflow: hidden; transition: background 0.2s; }
.card-header { padding: 18px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.card-title { font-size: 15px; font-weight: 600; }

/* ─── TABLE ─── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th { padding: 11px 16px; text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); background: var(--table-head-bg); border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--table-hover); }
tbody td { padding: 13px 16px; }
.empty-row td { text-align: center; padding: 48px; color: var(--text-secondary); font-size: 14px; }

/* ─── BADGES ─── */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-green  { background: rgba(34,197,94,0.1);   color: #16a34a; }
.badge-orange { background: rgba(245,158,11,0.1);  color: #d97706; }
.badge-gray   { background: rgba(100,116,139,0.1); color: #64748b; }
.badge-blue   { background: rgba(59,130,246,0.1);  color: #2563eb; }
.badge-red    { background: rgba(239,68,68,0.1);   color: #dc2626; }

/* ─── BUTTONS ─── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; border: none; transition: all 0.15s; font-family: inherit; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--hover-bg); color: var(--text-primary); }
.btn-icon { background: transparent; border: none; cursor: pointer; color: var(--text-secondary); padding: 6px; border-radius: 6px; transition: all 0.15s; display: inline-flex; align-items: center; font-size: 16px; }
.btn-icon:hover { background: var(--hover-bg); color: var(--text-primary); }
.btn-icon.danger:hover { background: rgba(239,68,68,0.08); color: var(--danger); }

/* Search in card header */
.card-search-wrap { position: relative; }
.card-search-wrap i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-secondary); font-size: 16px; pointer-events: none; }
.card-search { padding: 8px 12px 8px 34px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; outline: none; width: 220px; background: var(--input-bg); color: var(--text-primary); transition: all 0.2s; }
.card-search:focus { border-color: var(--accent); background: var(--card-bg); }

/* ─── MODAL ─── */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--card-bg); border-radius: 16px; width: 100%; max-width: 580px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.modal-header { padding: 24px 24px 0; display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-secondary); font-size: 22px; padding: 4px; border-radius: 6px; display: flex; align-items: center; transition: all 0.15s; }
.modal-close:hover { background: var(--hover-bg); color: var(--text-primary); }
.modal-body { padding: 0 24px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ─── FORM ─── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.4px; }
.form-input, .form-select, .form-textarea {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; outline: none; font-family: inherit; transition: border-color 0.2s;
  background: var(--card-bg); color: var(--text-primary);
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--accent); }
.form-textarea { resize: vertical; min-height: 72px; }
.form-section { grid-column: 1 / -1; padding-top: 12px; margin-top: 4px; border-top: 1px solid var(--border); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); }
.checkbox-row { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.checkbox-row input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }
.checkbox-label { font-size: 14px; font-weight: 500; }

/* ─── PLACEHOLDER ─── */
.placeholder-page { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 400px; text-align: center; color: var(--text-secondary); }
.placeholder-icon { font-size: 56px; margin-bottom: 16px; opacity: 0.4; }
.placeholder-title { font-size: 20px; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.placeholder-text { font-size: 14px; max-width: 320px; line-height: 1.6; }

/* ─── LOGIN ─── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #0f172a; }
.login-card { background: white; border-radius: 20px; padding: 48px 40px; width: 100%; max-width: 400px; box-shadow: 0 30px 60px rgba(0,0,0,0.3); }
.login-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.login-logo-icon { width: 48px; height: 48px; background: var(--accent); border-radius: 14px; display: flex; align-items: center; justify-content: center; }
.login-logo-name { font-size: 26px; font-weight: 800; color: #0f172a; letter-spacing: -1px; }
.login-tagline { font-size: 13px; color: #64748b; margin-bottom: 32px; padding-left: 2px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-error { background: rgba(239,68,68,0.08); color: var(--danger); padding: 10px 14px; border-radius: 8px; font-size: 13px; }
.login-btn { justify-content: center; padding: 12px; font-size: 14px; font-weight: 600; border-radius: 10px; margin-top: 4px; }
.login-btn:disabled { opacity: 0.7; cursor: not-allowed; }

/* ─── ALERTS ─── */
.alert-ok  { background: rgba(34,197,94,0.1);  color: #16a34a; padding: 10px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-err { background: rgba(239,68,68,0.08); color: var(--danger); padding: 10px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }

/* ─── PROFIL HERO ─── */
.profile-hero { display: flex; align-items: center; gap: 20px; padding: 24px; }
.profile-avatar-wrap { position: relative; flex-shrink: 0; }
.profile-photo { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; border: 3px solid var(--border); }
.profile-photo-placeholder {
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--input-bg); border: 3px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: var(--text-secondary);
}
.profile-photo-btn {
  position: absolute; bottom: 0; right: 0;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; cursor: pointer; border: 2px solid var(--card-bg);
}
.profile-photo-btn:hover { background: var(--accent-hover); }

/* ─── LOADING ─── */
.spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
