/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps.
 */

/* ─── Variables ─────────────────────────────────────────────── */
:root {
  /* Slate */
  --slate-900: #0F172A;
  --slate-800: #1E293B;
  --slate-700: #334155;
  --slate-500: #64748B;
  --slate-400: #94A3B8;
  --slate-200: #E2E8F0;
  --slate-100: #F1F5F9;
  --slate-50:  #F8FAFC;

  /* Indigo */
  --indigo-700: #4338CA;
  --indigo-600: #4F46E5;
  --indigo-100: #E0E7FF;

  /* Amber */
  --amber-500: #F59E0B;
  --amber-100: #FEF3C7;

  /* Green */
  --green-600: #059669;
  --green-100: #D1FAE5;

  /* Red */
  --red-600: #DC2626;
  --red-100: #FEE2E2;

  /* Layout */
  --sidebar-width: 240px;
  --topbar-height: 56px;
}

/* ─── Base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  padding: 0;
  color: var(--slate-800);
  background: var(--slate-50);
}

a { color: var(--indigo-600); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── App shell ──────────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────────── */
.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--slate-800);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform 0.25s ease;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  height: var(--topbar-height);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  text-decoration: none;
  flex-shrink: 0;
}

.sidebar-brand:hover { text-decoration: none; color: #fff; opacity: 0.9; }

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
}

.sidebar-section {
  margin-bottom: 0.5rem;
}

.sidebar-section-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slate-400);
  padding: 0.75rem 1.25rem 0.25rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.55rem 1.25rem;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background 0.1s, color 0.1s;
  border-left: 3px solid transparent;
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
  text-decoration: none;
}

.sidebar-link.active {
  background: rgba(99,102,241,0.2);
  color: #fff;
  border-left-color: var(--indigo-600);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.sidebar-user-email {
  font-size: 0.8rem;
  color: var(--slate-400);
  margin-bottom: 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Top bar ────────────────────────────────────────────────── */
.app-topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  z-index: 100;
  gap: 1rem;
}

.topbar-burger {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--slate-700);
  padding: 0.25rem;
  line-height: 1;
}

.topbar-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--slate-800);
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ─── Main content area ──────────────────────────────────────── */
.app-main {
  margin-left: var(--sidebar-width);
  padding-top: var(--topbar-height);
  min-height: 100vh;
  width: 100%;
}

.app-main .container,
.app-main main.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ─── Sidebar overlay (mobile) ───────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 199;
}

/* ─── Flash messages ─────────────────────────────────────────── */
.flash-notice {
  background: var(--green-100);
  border: 1px solid #6ee7b7;
  color: var(--green-600);
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.flash-alert {
  background: var(--red-100);
  border: 1px solid #fca5a5;
  color: var(--red-600);
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

/* ─── Card ───────────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  padding: 1.5rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  margin-bottom: 1.5rem;
}

.card h2 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  color: var(--slate-800);
}

/* ─── Form ───────────────────────────────────────────────────── */
.form-section {
  max-width: 480px;
  margin: 0 auto;
}

.auth-form,
.form-section form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--slate-700);
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--slate-200);
  border-radius: 6px;
  font-size: 1rem;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--indigo-600);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

/* ─── Buttons ────────────────────────────────────────────────── */
.cta-button {
  display: inline-block;
  background: var(--indigo-600);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.6rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: background 0.15s;
}

.cta-button:hover {
  background: var(--indigo-700);
  text-decoration: none;
  color: #fff;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.875rem;
}

.btn-danger {
  background: var(--red-600);
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-secondary {
  background: #fff;
  color: var(--slate-700);
  border: 1px solid var(--slate-200);
}

.btn-secondary:hover {
  background: var(--slate-50);
  color: var(--slate-800);
}

/* ─── Data table ─────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--slate-200);
}

.data-table th {
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--slate-500);
  background: var(--slate-50);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: var(--slate-50);
}

/* ─── Stat cards ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.stat-card .stat-value {
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1;
  color: var(--indigo-600);
}

.stat-card .stat-label {
  font-size: 0.82rem;
  color: var(--slate-500);
  margin-top: 0.35rem;
}

/* ─── Tier badges ────────────────────────────────────────────── */
[class^="badge-tier-"] {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-tier-1 { background: var(--slate-100); color: var(--slate-600, #475569); }
.badge-tier-2 { background: var(--green-100); color: var(--green-600); }
.badge-tier-3 { background: var(--indigo-100); color: var(--indigo-700); }
.badge-tier-4 { background: var(--amber-100); color: #92400e; }

/* ─── Plan card ──────────────────────────────────────────────── */
.plan-card {
  background: linear-gradient(135deg, var(--indigo-600) 0%, var(--indigo-700) 100%);
  color: #fff;
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.plan-card .plan-name {
  font-size: 1.4rem;
  font-weight: 700;
}

.plan-card .plan-meta {
  opacity: 0.85;
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* ─── Responsive: mobile sidebar ─────────────────────────────── */
@media (max-width: 768px) {
  .app-sidebar {
    transform: translateX(-100%);
  }

  .app-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open {
    display: block;
  }

  .app-topbar {
    left: 0;
  }

  .topbar-burger {
    display: block;
  }

  .app-main {
    margin-left: 0;
  }
}

/* ── Admin console ──────────────────────────────────────────────────────── */

.impersonation-banner {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.65rem 1rem;
  background: #7c2d12;
  color: #fff;
  font-size: 0.9rem;
}

.impersonation-banner strong { font-weight: 600; }

.impersonation-banner form { display: inline; }

.impersonation-banner-stop {
  background: #fff;
  color: #7c2d12;
  border: none;
  border-radius: 4px;
  padding: 0.3rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.impersonation-banner-stop:hover { background: #fed7aa; }

.admin-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.admin-filter-input {
  padding: 0.45rem 0.6rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.9rem;
  background: #fff;
  color: #0f172a;
}

.admin-filter-reset {
  font-size: 0.9rem;
  color: #64748b;
  text-decoration: none;
}

.admin-filter-reset:hover { text-decoration: underline; }

.admin-inline-link {
  font-size: 0.85rem;
  font-weight: 400;
  margin-left: 0.5rem;
}

.admin-danger-link {
  background: none;
  border: none;
  color: #b91c1c;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.badge-comped {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-admin {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: #e0e7ff;
  color: #3730a3;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.comped-note {
  background: #f0fdf4;
  border-left: 3px solid #16a34a;
  padding: 0.75rem 1rem;
  border-radius: 4px;
}

.warning-panel {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-left: 4px solid #b45309;
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  color: #78350f;
}

.warning-panel p { margin: 0.5rem 0 0; }

.warning-panel a { color: #7c2d12; }

.form-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
  max-width: 32rem;
}

.form-row label { font-weight: 600; font-size: 0.9rem; }

.form-row small { color: #64748b; font-size: 0.82rem; }

.pagy-nav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.pagy-nav a,
.pagy-nav span {
  padding: 0.3rem 0.6rem;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  text-decoration: none;
  color: #334155;
}

.pagy-nav a.current,
.pagy-nav span.current {
  background: #4f46e5;
  border-color: #4f46e5;
  color: #fff;
  font-weight: 600;
}

.pagy-nav span.gap { border: none; }
