/* ============================================
   HORUS DESK DASHBOARD — DARK GOLD THEME
   ============================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --surface-hover: #1a1a26;
  --border: #1e1e2e;
  --border-strong: #2a2a3a;
  --text: #eaeaea;
  --text-muted: #8a8a9a;
  --text-subtle: #5a5a6a;
  --primary: #b8860b;
  --primary-hover: #d4a017;
  --primary-light: rgba(184, 134, 11, 0.12);
  --success: #22c55e;
  --success-light: rgba(34, 197, 94, 0.12);
  --warning: #f59e0b;
  --warning-light: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-light: rgba(239, 68, 68, 0.12);
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.3);
  --gold-gradient: linear-gradient(135deg, #b8860b 0%, #d4a017 100%);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* Custom scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); }

/* ── Utility classes ─────────────────────────── */

.text-xs { font-size: 11px; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.font-semibold { font-weight: 600; }
.font-mono { font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace; }
.mb-4 { margin-bottom: 20px; }
.flex-row { display: flex; align-items: center; gap: 8px; }
.flex-row-spread { display: flex; align-items: center; justify-content: space-between; }
.org-link { font-weight: 600; color: var(--primary); cursor: pointer; text-decoration: none; }
.org-link:hover { color: var(--primary-hover); }
.card-body-flush { padding: 0; }
.stat-value-sm { font-size: 14px; margin-top: 8px; }
.stat-value-md { font-size: 18px; margin-top: 8px; }
.stat-value-lg { font-size: 16px; margin-top: 8px; }

/* ── Layout ───────────────────────────────── */

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: #0d0d14;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 10;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.3px;
  background: var(--gold-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-logo span {
  background: none;
  -webkit-background-clip: unset;
  -webkit-text-fill-color: var(--text-muted);
  background-clip: unset;
  font-weight: 400;
  font-size: 11px;
  display: block;
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  user-select: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  border-left: 2px solid transparent;
}

.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  border-left-color: var(--primary);
}

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.main {
  margin-left: 220px;
  flex: 1;
  padding: 32px;
  max-width: 1100px;
}

/* ── Page header ──────────────────────────── */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text);
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 2px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.breadcrumb a {
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
}

.breadcrumb a:hover { color: var(--primary-hover); text-decoration: underline; }
.breadcrumb-sep { color: var(--text-subtle); }

/* ── Cards ────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.card-body { padding: 20px; }

/* ── Tabs ─────────────────────────────────── */

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  gap: 0;
}

.tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Buttons ──────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s, box-shadow 0.15s;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}

.btn svg { width: 14px; height: 14px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--gold-gradient);
  color: #ffffff;
  border-color: transparent;
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 0 16px rgba(184, 134, 11, 0.3);
}

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--text-subtle); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { background: #dc2626; box-shadow: 0 0 12px rgba(239, 68, 68, 0.3); }

.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #16a34a; }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }

/* ── Forms ────────────────────────────────── */

.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

label .hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-subtle);
  margin-left: 4px;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="url"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  background: #0d0d14;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
  line-height: 1.5;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(184, 134, 11, 0.15);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8a9a' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

select option {
  background: var(--surface);
  color: var(--text);
}

textarea { resize: vertical; min-height: 100px; }

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.toggle-row:last-child { border-bottom: none; }

.toggle-label { font-size: 13px; font-weight: 500; color: var(--text); }
.toggle-desc { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

.toggle {
  position: relative;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border-strong);
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

/* ── Tables ───────────────────────────────── */

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-subtle);
  border-bottom: 1px solid var(--border);
  background: #0d0d14;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-hover); }

.table-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── Badges ───────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-green { background: var(--success-light); color: var(--success); }
.badge-yellow { background: var(--warning-light); color: var(--warning); }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-gray { background: rgba(90, 90, 106, 0.12); color: var(--text-muted); border: 1px solid var(--border); }
.badge-blue { background: var(--primary-light); color: var(--primary); }

/* ── Progress bar ─────────────────────────── */

.progress-wrap { display: flex; align-items: center; gap: 10px; }

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--gold-gradient);
  transition: width 0.3s;
}

.progress-fill.warning { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.progress-fill.danger { background: linear-gradient(135deg, #ef4444, #f87171); }

.progress-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ── Alerts ───────────────────────────────── */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-info { background: var(--primary-light); color: var(--primary); border: 1px solid rgba(184, 134, 11, 0.25); }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid rgba(34, 197, 94, 0.25); }
.alert-warning { background: var(--warning-light); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.25); }
.alert-danger { background: var(--danger-light); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.25); }

/* ── Code / snippet ───────────────────────── */

.code-block {
  background: #0d0d14;
  color: #c4c4d4;
  padding: 16px;
  border-radius: var(--radius-sm);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre;
  overflow-x: auto;
  position: relative;
  border: 1px solid var(--border);
}

.copy-btn-wrap {
  position: relative;
}

/* ── Stat grid ────────────────────────────── */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.stat-card:hover {
  border-color: rgba(184, 134, 11, 0.3);
  box-shadow: 0 0 20px rgba(184, 134, 11, 0.06);
}

.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; margin-top: 4px; color: var(--text); }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Misc ─────────────────────────────────── */

.divider { height: 1px; background: var(--border); margin: 24px 0; }
.spacer { flex: 1; }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state svg { width: 40px; height: 40px; opacity: 0.3; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--primary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--text-muted);
  gap: 10px;
}

.tag-input-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  min-height: 40px;
  cursor: text;
  background: #0d0d14;
}

.tag-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(184, 134, 11, 0.15);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 500;
}

.tag button {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  padding: 0;
  line-height: 1;
  opacity: 0.7;
  font-size: 14px;
}

.tag button:hover { opacity: 1; }

.tag-input {
  border: none !important;
  outline: none !important;
  padding: 2px 4px !important;
  font-size: 13px !important;
  flex: 1;
  min-width: 120px;
  box-shadow: none !important;
  background: transparent !important;
  color: var(--text) !important;
}

/* ── Toast ────────────────────────────────── */

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  background: #1e1e2e;
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.2s ease;
  max-width: 320px;
  border: 1px solid var(--border);
}

.toast.success { background: var(--success); color: white; border-color: var(--success); }
.toast.error { background: var(--danger); color: white; border-color: var(--danger); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ── Modal ────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-size: 16px; font-weight: 600; color: var(--text); }

.modal-body { padding: 20px 24px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Login screen ─────────────────────────────── */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 40px;
  width: 100%;
  max-width: 380px;
  position: relative;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gold-gradient);
  border-radius: var(--radius) var(--radius) 0 0;
}

.login-logo {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin-bottom: 4px;
  background: var(--gold-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

/* ── Sidebar footer ───────────────────────────── */

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 8px;
}

/* ── Color input (widget tab) ────────────────── */

input[type="color"] {
  width: 36px;
  height: 28px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  cursor: pointer;
  padding: 2px;
  background: transparent;
}

input[type="color"]::-webkit-color-swatch-wrapper { padding: 1px; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 2px; }

/* ── Checkbox styling ────────────────────────── */

input[type="checkbox"] {
  accent-color: var(--primary);
}
