/* Guisera — dashboard design system.
 *
 * Deliberately follows the LeadsSentry portal's structure (sidebar shell, Inter,
 * stat cards, 12px card / 8px button radius, --shadow-sm/md/lg) so the two
 * products read as one family.
 *
 * One departure: the palette. The family currently has two accents — the portal's
 * indigo (#1a237e) and the website's blue (#0078D4) — which is why they don't
 * look like one product today. The website AND the desktop app already use
 * #0078D4, so the indigo is the odd one out. Standardising here.
 *
 * Not copied: the branding-injected :root machinery. It slices hex in Jinja
 * (`primary_color[1:3]|int(base=16)`), which is fragile, and Guisera has no
 * white-labelling requirement.
 */

:root {
  --primary: #0078d4;
  --primary-dark: #005a9e;
  --primary-light: #4aa3e8;
  --primary-gradient: linear-gradient(135deg, #0078d4 0%, #0086ed 50%, #00a8ff 100%);
  --primary-rgb: 0, 120, 212;

  --teal: #4edea3;
  --teal-dark: #006b49;

  --sidebar-width: 270px;
  --header-height: 68px;

  --sidebar-bg: #ffffff;
  --sidebar-border: #eef0f6;
  --sidebar-nav-text: #4a5568;
  --sidebar-nav-icon: #94a3b8;

  --bg-main: #f7f8fc;
  --bg-card: #ffffff;
  --bg-input: #f8fafc;

  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;

  --border-color: #e5e7eb;
  --border-light: #f1f5f9;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.12);

  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg-main);
  color: var(--text-primary);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  color: var(--primary-dark);
}

/* ---------------- shell ---------------- */

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

.portal-sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  transition: transform 0.3s ease;
}

.portal-content {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
}

.portal-header {
  height: var(--header-height);
  background: #fff;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.portal-main {
  flex: 1;
  padding: 24px;
}

.sidebar-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 20px;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--primary-gradient);
  color: #fff;
  font-weight: 700;
  font-size: 17px;
}

.sidebar-title {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.1;
  /* The gradient-clipped brand text is a portal signature worth keeping. */
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.sidebar-subtitle {
  display: block;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  -webkit-text-fill-color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  padding: 14px 12px;
  overflow-y: auto;
}

.sidebar-nav .nav-section {
  margin: 16px 0 6px;
  padding: 0 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  font-weight: 500;
  font-size: 0.88rem;
  color: var(--sidebar-nav-text);
  margin-bottom: 2px;
  transition: var(--transition);
}
.sidebar-nav .nav-link:hover {
  background: var(--border-light);
  color: var(--text-primary);
}
.sidebar-nav .nav-link.active {
  background: rgba(var(--primary-rgb), 0.1);
  color: var(--primary);
  font-weight: 600;
  border-left: 3px solid var(--primary);
  margin-left: -3px;
  box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.08);
}

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

.user-profile-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px;
  border-radius: 10px;
  background: var(--bg-input);
}
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--primary-gradient);
  color: #fff;
  font-weight: 600;
  flex: 0 0 34px;
}
.user-meta {
  min-width: 0;
  flex: 1;
}
.user-meta strong {
  display: block;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-meta span {
  font-size: 11px;
  color: var(--text-muted);
}

/* ---------------- credits ---------------- */

.credit-pill {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(var(--primary-rgb), 0.08);
  border: 1px solid rgba(var(--primary-rgb), 0.18);
}
.credit-pill strong {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
}
.credit-pill span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

/* ---------------- cards ---------------- */

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

.stat-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  gap: 1rem;
  border: 1px solid var(--border-light);
  transition: var(--transition);
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.25rem;
  flex: 0 0 52px;
  background: var(--primary-gradient);
}
.stat-icon.teal {
  background: linear-gradient(135deg, #00c853, #4edea3);
}
.stat-icon.amber {
  background: linear-gradient(135deg, #ff6f00, #ffa000);
}
.stat-icon.slate {
  background: linear-gradient(135deg, #475569, #94a3b8);
}
.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}
.card-body {
  padding: 1.25rem;
}

.welcome-section {
  background: var(--primary-gradient);
  border-radius: 16px;
  padding: 1.75rem;
  color: #fff;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.welcome-section h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 650;
}
.welcome-section p {
  margin: 0;
  opacity: 0.9;
  font-size: 13px;
}

/* ---------------- buttons ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 500;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  border: 1px solid var(--border-color);
  background: #fff;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}
.btn:hover {
  background: var(--bg-input);
}
.btn-primary {
  background: var(--primary-gradient);
  border: none;
  color: #fff;
}
.btn-primary:hover {
  /* RESTATES THE BACKGROUND, and it has to.
   *
   * `.btn:hover` above sets `background: var(--bg-input)`. A pseudo-class counts
   * as a class, so that selector scores (0,2,0) while plain `.btn-primary`
   * scores (0,1,0) -- the generic hover therefore BEATS the variant's own
   * background, and hovering the primary button swapped the gradient for a
   * near-white input colour while this rule went on setting `color: #fff`.
   * White text on a white button: the Sign in control vanished under the cursor
   * on the customer and admin sign-in pages alike.
   *
   * This selector also scores (0,2,0), so it wins on SOURCE ORDER by sitting
   * after `.btn:hover`. Keep it there.
   *
   * Fixed here rather than by loosening `.btn:hover`, because that generic rule
   * is correct for the default (white) button; it is the variants that must say
   * what they become on hover. */
  background: var(--primary-gradient);
  filter: brightness(1.06);
  color: #fff;
}
.btn-danger {
  background: transparent;
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--danger);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.08);
}
.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
}
.btn-block {
  width: 100%;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------------- forms ---------------- */

.field {
  margin-bottom: 1rem;
}
.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}
.field .hint {
  margin-top: 5px;
  font-size: 11px;
  color: var(--text-muted);
}
.input,
.select,
textarea.input {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
}
.input:focus,
.select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
}
.input-row {
  display: flex;
  gap: 8px;
}

/* A secret field is write-only: it renders empty and shows its state beside it. */
.secret-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}
.secret-state.set {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}
.secret-state.unset {
  background: rgba(148, 163, 184, 0.14);
  color: var(--text-muted);
}

/* ---------------- tables ---------------- */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th {
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border-color);
  padding: 0.875rem 1rem;
}
.table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-light);
}
.table tr:last-child td {
  border-bottom: none;
}
.table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.amount-pos {
  color: var(--success);
  font-weight: 600;
}
.amount-neg {
  color: var(--danger);
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 0.4em 0.75em;
  font-weight: 500;
  font-size: 0.75rem;
  border-radius: 6px;
  background: var(--border-light);
  color: var(--text-secondary);
}
.badge-success {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
}
.badge-warning {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
}
.badge-danger {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}
.badge-info {
  background: rgba(var(--primary-rgb), 0.12);
  color: var(--primary);
}

/* ---------------- alerts ---------------- */

.alert {
  padding: 0.85rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 13px;
  border: 1px solid transparent;
}
.alert-success {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.25);
  color: #065f46;
}
.alert-danger {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.25);
  color: #991b1b;
}
.alert-warning {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.25);
  color: #92400e;
}
.alert-info {
  background: rgba(var(--primary-rgb), 0.08);
  border-color: rgba(var(--primary-rgb), 0.25);
  color: #075985;
}

.empty-state {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ---------------- auth ---------------- */

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--primary-gradient);
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 450px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  padding: 2rem;
  animation: slideUp 0.5s ease-out;
}
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.auth-card h1 {
  margin: 0 0 4px;
  font-size: 21px;
}
.auth-card .lead {
  margin: 0 0 1.5rem;
  color: var(--text-secondary);
  font-size: 13px;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-bottom: 1.25rem;
  /* It is an <a> now, so the anchor defaults have to be cleared: without this
     the product name renders underlined in link blue, which reads as a broken
     heading rather than a logo. */
  text-decoration: none;
  color: inherit;
  border-radius: 10px;
  padding: 4px 8px;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.auth-brand:hover,
.auth-brand:focus-visible {
  text-decoration: none;
  color: inherit;
  /* A slight lift, not a colour change: the mark is an uploaded image whose
     palette is unknown, so anything that tints it can clash with itself. */
  opacity: 0.85;
}
.auth-brand:focus-visible {
  /* Keyboard users need to SEE where they are. `:focus-visible` rather than
     `:focus`, so a mouse click does not leave a ring behind on the logo. */
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: 2px;
  opacity: 1;
}

/* ---------------- page header ---------------- */

.page-title {
  font-size: 18px;
  font-weight: 650;
  margin: 0;
}
.page-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin: 2px 0 0;
}
.spacer {
  flex: 1;
}

/* Mobile: sidebar becomes a drawer, as the portal does below 991.98px. */
@media (max-width: 991.98px) {
  .portal-sidebar {
    transform: translateX(-100%);
  }
  .portal-sidebar.open {
    transform: none;
  }
  .portal-content {
    margin-left: 0;
  }
}

/* ---------------- admin sidebar extras ---------------- */

.sidebar-nav .nav-link {
  justify-content: space-between;
}

.nav-badge {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.nav-badge.live {
  background: var(--success);
}

/* An area that exists in the plan but is not built yet. Shown rather than hidden,
   so the nav tells the truth about what is coming. */
.sidebar-nav .nav-link.disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: default;
}
.sidebar-nav .nav-link.disabled::after {
  content: 'soon';
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ---------------- filter bar ---------------- */

.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1rem;
}
.filter-bar .input,
.filter-bar .select {
  width: auto;
  min-width: 180px;
}

.pagination {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  padding: 14px;
  font-size: 13px;
}
.pagination a,
.pagination span {
  padding: 5px 10px;
  border-radius: 7px;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}
.pagination .current {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
.pagination .disabled {
  opacity: 0.4;
}

.danger-zone {
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 12px;
  padding: 1.25rem;
  background: rgba(239, 68, 68, 0.03);
}
.danger-zone h2 {
  color: var(--danger);
  margin-top: 0;
  font-size: 15px;
}

/* ---------------- signed-out pages on a phone ---------------- */

/* The sign-in and sign-up card is the most important funnel on the site and was
 * sized entirely for a mouse: 14px inputs, a 33px submit button.
 *
 * THE FONT SIZE IS NOT A STYLE CHOICE. iOS Safari zooms the page whenever a
 * focused text input is under 16px, and it does NOT zoom back out on blur. So
 * tapping the email field magnified the whole page, and the customer finished
 * signing up on a zoomed, sideways-scrolling layout -- on the one screen where a
 * moment's friction loses the account.
 *
 * Scoped to the auth card rather than added to mobile.css, because these pages
 * load guisera.css alone: they are deliberately standalone shells and do not
 * pull in the portal or admin stylesheets.
 */
@media (max-width: 767px) {
  .auth-card .input,
  .auth-card .select,
  .auth-card input[type="text"],
  .auth-card input[type="email"],
  .auth-card input[type="password"],
  .auth-card input[type="number"] {
    font-size: 16px;
    min-height: 46px;
  }

  /* The primary action deserves a full-size target: 33px is a miss waiting to
     happen, and the miss lands on "Forgot password?" just above it. */
  .auth-card .btn {
    min-height: 48px;
    font-size: 15px;
  }

  /* The checkbox itself stays small, so the label carries the tap area --
     otherwise "Keep me signed in" is a 13px square. */
  .auth-card label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
  }
  .auth-card input[type="checkbox"] {
    width: 18px;
    height: 18px;
  }
}
