/* Maika admin panel. Colours and type follow maika-website's warm-white theme
   (site/white-theme.css): Figtree, purple #814ac8, soft lilac lines. */

:root {
  color-scheme: light;
  --bg: #fbf9fd;
  --bg-soft: #f4f0f8;
  --card: #ffffff;
  --line: #e6dfec;
  --line-strong: #d3c6df;
  --text: #443b4c;
  --text-soft: #6d6276;
  --purple: #814ac8;
  --purple-hover: #6d3baa;
  --purple-tint: #f1e8fb;
  --focus-ring: #5b3d73;
  --ok: #2f8a5c;
  --ok-tint: #e5f5ec;
  --warn: #a5640e;
  --warn-tint: #fdf1de;
  --danger: #b4334a;
  --danger-tint: #fbe8ec;
  --shadow: 0 20px 55px rgba(68, 59, 76, 0.11);
  --shadow-sm: 0 7px 20px rgba(68, 59, 76, 0.07);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Figtree", ui-sans-serif, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: var(--purple);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

::selection {
  background: rgba(129, 74, 200, 0.22);
}

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Soft glow behind the welcome and sign-in pages, as on the website. */
.glow-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 15% 0%, rgba(198, 184, 217, 0.35), transparent 55%),
    radial-gradient(ellipse at 85% 15%, rgba(190, 166, 222, 0.3), transparent 55%),
    radial-gradient(ellipse at 50% 100%, rgba(129, 74, 200, 0.14), transparent 60%);
}

/* ---------- Brand ---------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--text);
  text-decoration: none;
}

.brand img {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  object-fit: cover;
}

.brand-label {
  display: grid;
  line-height: 1.15;
}

.brand-label strong {
  font-size: 1.05rem;
  font-weight: 800;
}

.brand-label span {
  font-size: 0.8rem;
  color: var(--text-soft);
}

/* ---------- Buttons and fields ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.6rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.btn:hover {
  border-color: var(--line-strong);
  box-shadow: 0 11px 26px rgba(68, 59, 76, 0.11);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--purple);
  border-color: var(--purple);
  color: #fff;
  box-shadow: 0 10px 28px rgba(129, 74, 200, 0.28);
}

.btn-primary:hover {
  background: var(--purple-hover);
  border-color: var(--purple-hover);
}

.btn-ghost {
  background: transparent;
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--bg-soft);
  box-shadow: none;
}

.btn-small {
  min-height: 34px;
  padding: 0.35rem 0.85rem;
  font-size: 0.875rem;
}

.btn-block {
  width: 100%;
}

.btn.is-busy::before {
  content: "";
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.field {
  display: grid;
  gap: 0.4rem;
}

.field-label {
  font-weight: 700;
  font-size: 0.92rem;
}

.field-hint,
.field-counter {
  font-size: 0.82rem;
  color: var(--text-soft);
}

.field-counter {
  justify-self: end;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 46px;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 4px rgba(129, 74, 200, 0.14);
}

.segmented {
  display: inline-flex;
  justify-self: start;
  align-self: start;
  padding: 4px;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-soft);
}

.segmented label {
  position: relative;
}

.segmented input {
  position: absolute;
  opacity: 0;
  inset: 0;
}

.segmented span {
  display: inline-block;
  padding: 0.45rem 1.1rem;
  border-radius: 999px;
  font-weight: 700;
  color: var(--text-soft);
  cursor: pointer;
}

.segmented input:checked + span {
  background: var(--card);
  color: var(--purple);
  box-shadow: var(--shadow-sm);
}

.segmented input:focus-visible + span {
  outline: 3px solid var(--focus-ring);
}

.alert {
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
}

.alert-error {
  background: var(--danger-tint);
  color: var(--danger);
}

.alert-info {
  background: var(--purple-tint);
  color: var(--focus-ring);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--bg-soft);
  color: var(--text-soft);
  white-space: nowrap;
}

.badge-purple {
  background: var(--purple-tint);
  color: var(--purple);
}

.badge-ok {
  background: var(--ok-tint);
  color: var(--ok);
}

.badge-warn {
  background: var(--warn-tint);
  color: var(--warn);
}

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

/* ---------- Welcome ---------- */

.welcome-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
}

.welcome {
  max-width: 1120px;
  margin: 0 auto;
  padding: 3.5rem 1.5rem 4rem;
}

.hero {
  max-width: 720px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--purple);
}

.eyebrow::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--purple);
  box-shadow: 0 0 0 5px rgba(129, 74, 200, 0.13);
}

.hero h1 {
  margin: 1.25rem 0 1rem;
  font-size: clamp(2.3rem, 5vw, 3.6rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 800;
}

.gradient-text {
  background: linear-gradient(135deg, #443b4c 10%, #7a4faa 48%, #a178c7 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero p {
  margin: 0 0 2rem;
  max-width: 560px;
  font-size: 1.15rem;
  color: var(--text-soft);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.hero-signed-in {
  font-size: 0.92rem;
  color: var(--text-soft);
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 3.5rem;
}

.feature {
  padding: 1.5rem;
}

.feature-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 1rem;
  border-radius: 14px;
  background: var(--purple-tint);
  color: var(--purple);
}

.feature-icon svg {
  width: 22px;
  height: 22px;
}

.feature h2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 0 0.4rem;
  font-size: 1.1rem;
}

.feature p {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.95rem;
}

.feature-muted {
  background: rgba(255, 255, 255, 0.6);
  box-shadow: none;
}

.site-footer {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.5rem;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
  color: var(--text-soft);
}

/* ---------- Sign in ---------- */

.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 2.25rem 2rem 2rem;
  box-shadow: var(--shadow);
}

.auth-card .brand {
  margin-bottom: 1.75rem;
}

.auth-card h1 {
  margin: 0 0 0.35rem;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}

.auth-card > p {
  margin: 0 0 1.5rem;
  color: var(--text-soft);
}

.auth-form {
  display: grid;
  gap: 1rem;
}

.auth-note {
  margin: 1.25rem 0 0;
  font-size: 0.85rem;
  color: var(--text-soft);
}

.auth-back {
  display: inline-block;
  margin-top: 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.password-row {
  position: relative;
}

.password-row .input {
  padding-right: 4.5rem;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.5rem;
  transform: translateY(-50%);
  padding: 0.3rem 0.6rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--purple);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

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

.shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  height: 100vh;
  padding: 1.5rem 1rem;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
}

.sidebar .brand {
  padding: 0 0.5rem;
}

.nav {
  display: grid;
  gap: 0.25rem;
}

.nav-section {
  margin: 0 0 0.5rem;
  padding: 0 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex: none;
}

.nav-item[aria-current="page"] {
  background: var(--purple-tint);
  color: var(--purple);
}

.nav-item.is-disabled {
  color: var(--text-soft);
  cursor: default;
}

.nav-item .badge {
  margin-left: auto;
}

.main {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 249, 253, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h1 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
}

.topbar p {
  margin: 0.15rem 0 0;
  font-size: 0.9rem;
  color: var(--text-soft);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--purple);
  color: #fff;
  font-weight: 800;
  text-transform: uppercase;
}

.user-email {
  font-size: 0.9rem;
  font-weight: 600;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content {
  padding: 1.5rem 2rem 3rem;
  max-width: 1200px;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}

.tab {
  padding: 0.75rem 1rem;
  white-space: nowrap;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  font-weight: 700;
  color: var(--text-soft);
  cursor: pointer;
}

.tab[aria-selected="true"] {
  color: var(--purple);
  border-bottom-color: var(--purple);
}

.panel-intro {
  margin: 0 0 1.25rem;
  color: var(--text-soft);
  max-width: 720px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.toolbar .spacer {
  flex: 1;
}

.toolbar .select {
  width: auto;
  min-width: 180px;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.92rem;
  cursor: pointer;
}

/* ---------- Send ---------- */

.send-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 1.5rem;
  align-items: start;
}

.send-form {
  display: grid;
  gap: 1.25rem;
  padding: 1.5rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}

.preview {
  position: sticky;
  top: 96px;
  padding: 1.25rem;
}

.preview h2 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

.preview > p {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: var(--text-soft);
}

.phone {
  padding: 1rem;
  border-radius: 24px;
  background: linear-gradient(160deg, #5b3d73, #814ac8 60%, #a178c7);
}

.notification {
  padding: 0.85rem 0.95rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.15);
}

.notification-app {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-soft);
}

.notification-app img {
  width: 18px;
  height: 18px;
  border-radius: 5px;
}

.notification-title {
  font-weight: 700;
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.notification-body {
  font-size: 0.88rem;
  color: var(--text-soft);
  overflow-wrap: anywhere;
}

.result {
  padding: 1.25rem 1.5rem;
  margin-top: 1.5rem;
}

.result h3 {
  margin: 0 0 1rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

.stat {
  padding: 0.85rem;
  border-radius: var(--radius-md);
  background: var(--bg-soft);
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
}

.stat-label {
  font-size: 0.82rem;
  color: var(--text-soft);
}

/* ---------- Templates ---------- */

.template-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.template {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem;
}

.template.is-retired {
  opacity: 0.7;
}

.template-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.template-name {
  margin: 0;
  font-size: 1rem;
}

.template-badges {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.template-message {
  flex: 1;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}

.template-actions {
  display: flex;
  gap: 0.5rem;
}

/* ---------- History ---------- */

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  padding: 0.85rem 1rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

th {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-soft);
  background: var(--bg-soft);
}

tr:last-child td {
  border-bottom: 0;
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cell-title {
  font-weight: 700;
}

.cell-date {
  white-space: nowrap;
}

.cell-sub {
  color: var(--text-soft);
  font-size: 0.85rem;
}

.empty {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-soft);
}

.empty strong {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--text);
}

.loading {
  padding: 2rem;
  text-align: center;
  color: var(--text-soft);
}

/* ---------- Dialogs and toasts ---------- */

.dialog {
  width: min(520px, calc(100vw - 2rem));
  padding: 1.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(68, 59, 76, 0.35);
}

.dialog-title {
  margin: 0 0 1rem;
  font-size: 1.25rem;
}

.dialog-body {
  display: grid;
  gap: 1rem;
  color: var(--text-soft);
}

.dialog-body p {
  margin: 0;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.toasts {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 50;
  display: grid;
  gap: 0.5rem;
}

.toast {
  max-width: 380px;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease-out;
  transition: opacity 0.3s, transform 0.3s;
}

.toast-success {
  background: var(--ok);
}

.toast-error {
  background: var(--danger);
}

.toast-leaving {
  opacity: 0;
  transform: translateY(6px);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ---------- Small screens ---------- */

/* Below this the form would get too narrow beside the preview. */
@media (max-width: 1180px) {
  .send-grid {
    grid-template-columns: 1fr;
  }

  .preview {
    position: static;
    max-width: 420px;
  }
}

@media (max-width: 760px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar .brand-label,
  .nav-section,
  .nav-item.is-disabled {
    display: none;
  }

  .topbar,
  .content {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .user-email {
    display: none;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .stats {
    grid-template-columns: 1fr 1fr;
  }

  .welcome {
    padding-top: 2rem;
  }
}
