/* Self-hosted (fonts/general_sans/) - replaces Poppins as the heading font. Only
   the weights actually used by --font-heading (600/700, matching how Poppins was
   loaded) are declared, to avoid fetching weights nothing on the page uses. */
@font-face {
  font-family: "General Sans";
  src:
    url("../fonts/general_sans/GeneralSans-Semibold.woff2") format("woff2"),
    url("../fonts/general_sans/GeneralSans-Semibold.woff") format("woff");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "General Sans";
  src:
    url("../fonts/general_sans/GeneralSans-Bold.woff2") format("woff2"),
    url("../fonts/general_sans/GeneralSans-Bold.woff") format("woff");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --purple: #6c60aa;
  --purple-dark: #574c8c;
  --pink: #dc4f9c;
  --pink-dark: #c33e89;
  --yellow: #fdb515;
  --teal: #67c7c3;
  --navy: #161741;
  --danger: #d14343;
  --danger-dark: #b23838;

  --ink: #161741;
  --ink-muted: #5b5c78;
  --ink-faint: #8b8ca6;

  --bg: #f8f8fc;
  --surface: #ffffff;
  --border: #ecebf4;
  --border-strong: #dedcec;

  --sidebar-width: 276px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(22, 23, 65, 0.06);
  --shadow-md: 0 6px 16px rgba(22, 23, 65, 0.08);
  --shadow-lg: 0 16px 40px rgba(22, 23, 65, 0.12);

  --font-heading: "General Sans", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

html {
  overflow-y: auto;
  scrollbar-gutter: stable;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* ---------- Sidebar ---------- */

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 28px 20px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  display: block;
  padding: 4px 8px 28px;
  transition: opacity 0.15s ease;
}

.sidebar-logo:hover {
  opacity: 0.8;
}

.sidebar-logo img {
  height: 24px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  display: block;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.nav-primary {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.nav-primary-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.nav-btn-caption {
  padding: 0 4px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-faint);
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: none;
  cursor: pointer;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 14.5px;
  font-weight: 600;
  color: #fff;
  text-align: left;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    filter 0.15s ease;
  box-shadow: var(--shadow-sm);
}

.nav-btn-icon {
  display: inline-flex;
  flex-shrink: 0;
}

.nav-btn--create {
  background: linear-gradient(
    135deg,
    var(--purple) 0%,
    var(--purple-dark) 100%
  );
}

.nav-btn--send {
  background: linear-gradient(135deg, var(--pink) 0%, var(--pink-dark) 100%);
}

.nav-btn:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.nav-btn:active {
  transform: translateY(0);
}

.nav-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 4px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 500;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.nav-link-icon {
  display: inline-flex;
  flex-shrink: 0;
  color: var(--ink-faint);
  transition: color 0.15s ease;
}

.nav-link:hover {
  background: #f4f2fb;
  color: var(--ink);
}

.nav-link:hover .nav-link-icon {
  color: var(--purple);
}

.nav-link.is-active {
  background: #f4f2fb;
  color: var(--ink);
}

.nav-link.is-active .nav-link-icon {
  color: var(--purple);
}

.sidebar-footer {
  /* Pinned to the bottom of the sidebar: when the menu is taller than the window, the menu
     scrolls underneath and the usage bar and user name stay in view. */
  position: sticky;
  bottom: -20px;
  z-index: 2;
  margin-top: 16px;
  margin-bottom: -20px;
  padding: 16px 0 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

/* ---------- Emails sent this month ---------- */

.usage {
  margin-bottom: 10px;
  padding: 12px 14px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.usage-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.usage-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
}

.usage-count {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
}

.usage-bar {
  height: 8px;
  margin-top: 9px;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
  overflow: hidden;
}

.usage-fill {
  display: block;
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--purple) 0%, var(--pink) 100%);
}

.usage-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-faint);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: var(--radius-md);
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal), var(--purple));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 12px;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Main ---------- */

.main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
  position: relative;
  overflow: hidden;
}

/* Every other page that lives inside the sidebar shell has real, often tall,
   content (tables, grids) rather than the dashboard's one small centered card, so
   it needs plain document flow and a scrollable page instead of the dashboard's
   centering + overflow:hidden (which would clip anything taller than the viewport). */
.main.main--pages {
  display: block;
  overflow: visible;
  padding: 0;
  min-width: 0;
}

.main-content {
  position: relative;
  max-width: 640px;
  width: 100%;
  text-align: center;
  z-index: 1;
}

.greeting-decoration {
  position: absolute;
  inset: -220px -160px auto;
  height: 520px;
  pointer-events: none;
  z-index: 0;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.18;
}

.blob--teal {
  width: 280px;
  height: 280px;
  background: var(--teal);
  top: 0;
  left: -40px;
}

.blob--yellow {
  width: 220px;
  height: 220px;
  background: var(--yellow);
  top: 60px;
  right: 0;
}

.blob--pink {
  width: 240px;
  height: 240px;
  background: var(--pink);
  bottom: -160px;
  left: 40%;
}

.eyebrow {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--purple);
  margin: 0 0 10px;
}

.greeting {
  font-family: var(--font-heading);
  font-size: 42px;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}

.subheading {
  font-size: 17px;
  color: var(--ink-muted);
  margin: 0 0 40px;
}

.cta-row {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.cta-row--primary {
  margin-bottom: 20px;
  align-items: flex-start;
}

.cta-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
}

.cta-caption {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-faint);
}

.cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: none;
  cursor: pointer;
  padding: 16px 28px;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  box-shadow: var(--shadow-md);
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    filter 0.15s ease;
}

.cta-icon {
  display: inline-flex;
}

.cta-btn--create {
  background: linear-gradient(
    135deg,
    var(--purple) 0%,
    var(--purple-dark) 100%
  );
}

.cta-btn--send {
  background: linear-gradient(135deg, var(--pink) 0%, var(--pink-dark) 100%);
}

.cta-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  filter: brightness(1.05);
}

.cta-btn:active {
  transform: translateY(0);
}

.cta-btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  cursor: pointer;
  padding: 12px 22px;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-muted);
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.cta-btn-secondary svg {
  color: var(--ink-faint);
  transition: color 0.15s ease;
}

.cta-btn-secondary:hover {
  background: #f8f7fc;
  border-color: var(--purple);
  color: var(--navy);
}

.cta-btn-secondary:hover svg {
  color: var(--purple);
}

/* ---------- Mobile nav ---------- */

.mobile-nav-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 30;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--navy);
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(22, 23, 65, 0.35);
  z-index: 15;
}

@media (max-width: 960px) {
  .mobile-nav-toggle {
    display: flex;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg);
  }

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

  .sidebar-overlay.is-visible {
    display: block;
  }

  .main {
    padding-top: 88px;
  }

  .main.main--pages {
    padding-top: 88px;
  }

  .greeting {
    font-size: 32px;
  }
}

@media (max-width: 540px) {
  .cta-btn,
  .cta-btn-secondary {
    width: 100%;
    justify-content: center;
  }

  .cta-row {
    flex-direction: column;
  }

  .cta-option {
    width: 100%;
  }
}

/* ---------- Modal (shared) ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(22, 23, 65, 0.55);
}

.modal-dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-dialog--narrow {
  max-width: 400px;
}

.modal-dialog--wide {
  max-width: 660px;
}

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

.modal-header-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.modal-header h3 {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  margin: 0;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
}

.modal-body img {
  display: block;
  width: 100%;
  height: auto;
}

.modal-body.modal-body--padded {
  padding: 20px;
  background: var(--surface);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-footer[hidden] {
  display: none;
}

.modal-field label {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 6px;
}

.modal-field input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 14.5px;
  color: var(--ink);
  background: var(--bg);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}

.modal-field input:focus {
  outline: none;
  border-color: var(--purple);
  background: var(--surface);
  box-shadow: 0 0 0 4px rgba(108, 96, 170, 0.12);
}

.modal-field select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 100%;
  font-family: var(--font-body);
  font-size: 14.5px;
  color: var(--ink);
  background: var(--bg)
    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='%238B8CA6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E")
    no-repeat right 14px center;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px 36px 12px 14px;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease;
}

.modal-field select:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 4px rgba(108, 96, 170, 0.12);
}

.modal-field input:disabled,
.modal-field select:disabled {
  background: var(--border);
  border-color: var(--border);
  color: var(--ink-muted);
  cursor: not-allowed;
}

.modal-field + .modal-field {
  margin-top: 14px;
}

.modal-field-row {
  display: flex;
  gap: 12px;
}

.modal-field-row .modal-field {
  flex: 1;
  min-width: 0;
}

.modal-field-row .modal-field + .modal-field {
  margin-top: 0;
}

.modal-field-row + .modal-field {
  margin-top: 14px;
}

.modal-field-hint {
  font-size: 12.5px;
  color: var(--ink-faint);
  margin: 8px 0 0;
}

.modal-confirm {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  padding: 8px 20px;
}

.modal-confirm-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(103, 199, 195, 0.18);
  color: var(--teal);
}

.modal-confirm-icon--danger {
  background: rgba(209, 67, 67, 0.12);
  color: var(--danger);
}

.modal-confirm-icon--warning {
  background: rgba(253, 181, 21, 0.2);
  color: #8a5a00;
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: var(--danger);
  color: #fff;
  font-family: var(--font-body);
  font-size: 14.5px;
  font-weight: 700;
  padding: 12px 22px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition:
    background 0.15s ease,
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

.btn-danger:hover {
  background: var(--danger-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.modal-confirm p {
  font-size: 14px;
  color: var(--ink-muted);
  line-height: 1.5;
  margin: 0;
}

.modal-confirm strong {
  color: var(--navy);
}

/* ---------- Toast (shared) ---------- */

.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translate(-50%, 12px);
  background: var(--navy);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  z-index: 400000;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Group chips + hover tooltip (shared) ---------- */

.group-chip {
  display: inline-flex;
  background: var(--bg);
  color: var(--ink-muted);
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.group-more {
  position: relative;
  display: inline-flex;
}

.group-more-trigger {
  display: inline-flex;
  background: #f1eff9;
  color: var(--purple);
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  cursor: default;
}

/* Generic wrapper for anything else that should reveal a .group-more-tooltip on hover
   (e.g. an audience summary line), without looking like a "+N" chip itself. */
.hover-tooltip {
  position: relative;
  cursor: default;
}

/* Positioned via JS (top/left set on show) rather than anchored purely in CSS, and
   fixed rather than absolute, so it can never be clipped by an ancestor's overflow
   (e.g. a horizontally-scrollable table card) - a fixed-position box's containing
   block is the viewport, so ancestor `overflow` never applies to it. */
.group-more-tooltip {
  position: fixed;
  top: 0;
  left: 0;
  background: var(--navy);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  min-width: 200px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
  transform: translateY(4px);
  z-index: 1000;
}

.group-more-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--navy);
}

.group-more-tooltip--flipped::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: var(--navy);
}

.group-more-tooltip.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.group-more-tooltip-title {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.65);
  padding-bottom: 6px;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.group-more-tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 2px 0;
  font-size: 12.5px;
  font-weight: 600;
}

.group-more-tooltip-row span:last-child {
  color: rgba(255, 255, 255, 0.68);
  font-weight: 600;
}
