/* ==========================================================================
   MectarisTech — Admin panel styles
   Same dark, indigo-violet brand system as the public site (see
   public/css/styles.css :root), rebuilt here standalone since the admin
   panel ships as its own small page. No external fonts/icons/CDNs.
   ========================================================================== */

:root {
  color-scheme: dark;

  --bg-base: #0a0b10;
  --bg-surface: #12141c;
  --bg-surface-2: #181b26;
  --bg-input: #14161f;

  --text-primary: #f5f6f8;
  --text-secondary: #a6abba;
  --text-tertiary: #6f7383;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  --accent-400: #8a93ff;
  --accent-500: #6a6bf0;
  --accent-600: #5850e0;
  --accent-glow: rgba(106, 107, 240, 0.35);
  --gradient-brand: linear-gradient(135deg, #6a6bf0 0%, #8b5cf6 100%);

  --success-500: #34d399;
  --success-bg: rgba(52, 211, 153, 0.14);
  --warning-500: #f5b342;
  --warning-bg: rgba(245, 179, 66, 0.14);
  --error-500: #f87171;
  --error-bg: rgba(248, 113, 113, 0.14);
  --neutral-500: #a6abba;
  --neutral-bg: rgba(166, 171, 186, 0.14);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --font-body: -apple-system, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI",
    ui-sans-serif, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

.muted { color: var(--text-secondary); }
.error {
  color: var(--error-500);
  font-size: 0.85rem;
  margin: 0.6rem 0 0;
}

[hidden] { display: none !important; }

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.1rem;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, opacity 150ms ease;
}
.btn-primary { background: var(--gradient-brand); color: #fff; }
.btn-primary:hover { opacity: 0.92; }
.btn-sm { padding: 0.5rem 0.85rem; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--text-primary); }
.btn-ghost:hover { background: var(--bg-surface-2); }
.btn-danger { background: transparent; border-color: var(--error-500); color: var(--error-500); }
.btn-danger:hover { background: var(--error-bg); }

/* ---- Login --------------------------------------------------------------- */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--accent-glow), transparent 60%),
    var(--bg-base);
}
.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2.25rem 2rem;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  box-shadow: 0 24px 64px -20px rgba(0, 0, 0, 0.65);
}
.login-card .brand-mark { margin-bottom: 0.5rem; }
.login-card h1 { font-size: 1.35rem; margin: 0; letter-spacing: -0.01em; }
.login-card > .muted { margin: 0 0 0.5rem; font-size: 0.9rem; }
.login-card label { font-size: 0.82rem; margin-top: 0.5rem; color: var(--text-secondary); }
.login-card input {
  font: inherit;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
}
.login-card input:focus {
  outline: none;
  border-color: var(--accent-400);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.login-card .btn { margin-top: 1rem; }

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--gradient-brand);
  flex: none;
}

/* ---- App shell: sidebar + main ------------------------------------------- */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  padding: 0 0.4rem;
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font: inherit;
  font-weight: 500;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.sidebar-link:hover { background: var(--bg-surface-2); color: var(--text-primary); }
.sidebar-link.is-active {
  background: var(--bg-surface-2);
  color: var(--text-primary);
  box-shadow: inset 2px 0 0 var(--accent-500);
}
.sidebar-link-icon { color: var(--accent-400); font-size: 0.95rem; }

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border-top: 1px solid var(--border-subtle);
  padding-top: 1rem;
}
.sidebar-user { display: flex; align-items: center; gap: 0.55rem; font-size: 0.85rem; }
.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--gradient-brand);
  flex: none;
}

.mobile-nav-toggle {
  display: none;
  position: fixed;
  top: 0.9rem;
  right: 1rem;
  z-index: 20;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
}
.mobile-nav-toggle span { width: 18px; height: 2px; background: var(--text-primary); border-radius: 1px; }

.admin-main {
  padding: 2rem 2.25rem 3rem;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.admin-section { display: none; flex-direction: column; gap: 1.75rem; }
.admin-section.is-active { display: flex; }

.section-head h1 { margin: 0 0 0.25rem; font-size: 1.5rem; letter-spacing: -0.01em; }
.section-head p { margin: 0; }

/* ---- Stat cards ----------------------------------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.stat-value {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stat-label { font-size: 0.82rem; color: var(--text-secondary); }

/* ---- Panels ---------------------------------------------------------------- */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}
.panel-header { margin-bottom: 1rem; }
.panel-header h2 { margin: 0; font-size: 1.05rem; letter-spacing: -0.005em; }

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.inline-form input,
.inline-form select {
  font: inherit;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  flex: 1 1 150px;
  min-width: 0;
}
.inline-form input:focus,
.inline-form select:focus {
  outline: none;
  border-color: var(--accent-400);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.inline-form input::placeholder { color: var(--text-tertiary); }

/* ---- Tables ----------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.data-table th, .data-table td {
  text-align: left;
  padding: 0.65rem 0.6rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  white-space: nowrap;
}
.data-table th {
  color: var(--text-tertiary);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.data-table tbody tr:hover { background: var(--bg-surface-2); }
.data-table .row-actions { display: flex; gap: 0.4rem; }

.empty-state {
  text-align: center;
  color: var(--text-tertiary);
  padding: 1.5rem 0.5rem;
  font-size: 0.9rem;
}

/* ---- Status pills / select ---------------------------------------------------- */
.status-select {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  appearance: none;
  background-repeat: no-repeat;
  background-position: right 0.55rem center;
}
.status-select:focus { outline: none; box-shadow: 0 0 0 3px var(--accent-glow); }
.status-lead { background: var(--neutral-bg); color: var(--neutral-500); }
.status-in_progress { background: rgba(106, 107, 240, 0.16); color: var(--accent-400); }
.status-review { background: var(--warning-bg); color: var(--warning-500); }
.status-completed { background: var(--success-bg); color: var(--success-500); }
.status-on_hold { background: var(--error-bg); color: var(--error-500); }

/* ---- Responsive ---------------------------------------------------------------- */
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 25% 0 0;
    z-index: 15;
    transform: translateX(-100%);
    transition: transform 200ms ease;
    box-shadow: 24px 0 48px -24px rgba(0, 0, 0, 0.6);
  }
  .sidebar.is-open { transform: translateX(0); }
  .mobile-nav-toggle { display: flex; }
  .admin-main { padding: 4.5rem 1.25rem 2.5rem; }
}
