/* ════════════════════════════════════════════════════════════
   TEMENOS LIFE · css/base.css
   Foundations: custom properties, resets, typography, shared
   utility classes. All colour references go through CSS vars so
   theme.js swaps them at runtime.
   ════════════════════════════════════════════════════════════ */

/* ── Design tokens (defaults; theme.js overrides via <body> style) */
:root {
  --bg-color:       #1C201C;
  --bg-surface:     #232823;
  --bg-raised:      #2A2F2A;
  --thread-color:   #4FA86A;
  --thread-dim:     #3a7d50;
  --ai-color:       #7eb8a0;
  --text-primary:   #E8EDE8;
  --text-secondary: #9aaa9a;
  --text-muted:     #8a9a8a;
  --border:         rgba(255,255,255,0.07);
  --radius-sm:      6px;
  --radius-md:      12px;
  --radius-lg:      20px;
  --shadow-card:    0 2px 16px rgba(0,0,0,0.4);
  --font-display:   'Cormorant Garamond', Georgia, serif;
  --font-body:      'Inter', system-ui, sans-serif;
  --sidebar-w:      220px;
  --tabbar-h:       64px;
  --transition:     200ms ease;
}

/* ── Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
ul, ol { list-style: none; }
a { color: var(--thread-color); text-decoration: none; }

/* ── Typography scale */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.2;
  color: var(--text-primary);
}
h1 { font-size: 2.2rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.05rem; }
p  { color: var(--text-secondary); }

/* ── Auth gate */
#auth-gate {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.auth-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}
.brand-mark {
  display: block;
  aspect-ratio: 1;
  background: var(--thread-color);
  -webkit-mask: url('../img/temenos-master-clean.png') center / contain no-repeat;
  mask: url('../img/temenos-master-clean.png') center / contain no-repeat;
}
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  color: var(--thread-color);
}
.auth-brand-name {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1em;
  color: var(--thread-color);
  text-transform: uppercase;
}
.auth-brand-temenos {
  font-family: var(--font-display);
  font-size: clamp(2rem, 7vw, 2.85rem);
  line-height: 1;
  letter-spacing: 0.08em;
}
.auth-brand-life {
  font-family: var(--font-display);
  font-size: clamp(0.85rem, 3vw, 1.15rem);
  line-height: 1;
  letter-spacing: 0.32em;
  opacity: 0.7;
}
.brand-mark-large {
  width: clamp(6rem, 20vw, 8.5rem);
  opacity: 0.95;
  filter: drop-shadow(0 0 18px color-mix(in srgb, var(--thread-color) 16%, transparent));
}
.auth-tagline {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--text-secondary);
}
.auth-form {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  padding-top: 0.15rem;
}
.auth-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
  width: 100%;
  padding: 0.25rem;
  margin-bottom: 1.1rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.auth-mode-btn {
  padding: 0.5rem 0.5rem;
  border-radius: calc(var(--radius-md) - 0.25rem);
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}
.auth-mode-btn.is-active {
  background: color-mix(in srgb, var(--thread-color) 16%, transparent);
  color: var(--text-primary);
  font-weight: 500;
}
.auth-hint {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.5;
  text-align: left;
  margin: -0.4rem 0 0.9rem;
}
.auth-submit {
  width: 100%;
  margin-top: 0.25rem;
}
.auth-forgot-link {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.75rem 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.95rem;
  text-align: center;
  cursor: pointer;
  transition: color var(--transition);
}
.auth-forgot-link:hover { color: var(--thread-color); }
.auth-reset-intro {
  font-size: 1.05rem;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 0.5rem;
  line-height: 1.5;
}
.auth-error {
  font-size: 0.82rem;
  color: #e06c75;
  margin-bottom: 0.5rem;
}
.auth-error.is-notice { color: var(--thread-color); }
.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  width: 100%;
  max-width: 320px;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.btn-email-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 320px;
  padding: 0.68rem 1.5rem;
  border: 1px solid color-mix(in srgb, var(--thread-color) 48%, var(--border));
  border-radius: var(--radius-md);
  color: var(--text-primary);
  background: color-mix(in srgb, var(--thread-color) 8%, transparent);
  font-size: 0.9rem;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}
.btn-email-toggle:hover,
.btn-email-toggle[aria-expanded="true"] {
  border-color: var(--thread-color);
  background: color-mix(in srgb, var(--thread-color) 14%, transparent);
  color: var(--text-primary);
}
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.65rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  color: var(--text-primary);
  width: 100%;
  max-width: 320px;
  transition: border-color var(--transition), background var(--transition);
}
.btn-google:hover { border-color: var(--text-secondary); background: var(--bg-raised); }

.auth-providers {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  max-width: 320px;
  margin-top: 0.1rem;
}
.auth-provider-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.1rem;
  height: 2.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary); /* Apple glyph uses currentColor */
  transition: border-color var(--transition), background var(--transition);
}
.auth-provider-btn:hover {
  border-color: var(--text-secondary);
  background: var(--bg-raised);
}

.auth-legal {
  margin-top: 1.4rem;
  max-width: 320px;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.6;
  text-align: center;
}
.auth-legal a {
  color: var(--text-secondary);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.auth-legal a:hover { color: var(--thread-color); }

/* ── Buttons */
.btn-primary {
  padding: 0.65rem 1.75rem;
  background: transparent;
  color: var(--thread-color);
  border: 1px solid color-mix(in srgb, var(--thread-color) 55%, var(--border));
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.9rem;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.btn-primary:hover {
  background: var(--thread-color);
  color: #111;
  border-color: var(--thread-color);
}
.btn-ghost {
  padding: 0.55rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.875rem;
  transition: border-color var(--transition), color var(--transition);
}
.btn-ghost:hover { border-color: var(--thread-color); color: var(--text-primary); }
.btn-danger {
  padding: 0.65rem 1.75rem;
  background: transparent;
  color: var(--color-error);
  border: 1px solid color-mix(in srgb, var(--color-error) 55%, var(--border));
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.9rem;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.btn-danger:hover {
  background: var(--color-error);
  color: #111;
  border-color: var(--color-error);
}

/* Small variant — inline actions, table rows, compact UI */
.btn-sm { padding: 0.3rem 0.85rem; font-size: 0.8rem; }

/* Disabled + loading states */
.btn-primary:disabled, .btn-ghost:disabled, .btn-danger:disabled,
.btn-primary.is-disabled, .btn-ghost.is-disabled, .btn-danger.is-disabled {
  opacity: 0.38;
  pointer-events: none;
}
.btn-primary.is-loading, .btn-ghost.is-loading, .btn-danger.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn-primary.is-loading::after, .btn-ghost.is-loading::after, .btn-danger.is-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
}
.btn-primary.is-loading::after { border-color: var(--thread-color); border-right-color: transparent; }
.btn-ghost.is-loading::after { border-color: var(--text-secondary); border-right-color: transparent; }
.btn-danger.is-loading::after { border-color: var(--color-error); border-right-color: transparent; }
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* ── Cards */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
}

/* ── App shell layout */
#app-shell {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}
.content-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.5rem;
  /* bottom padding so content clears the mobile tab bar */
  padding-bottom: calc(var(--tabbar-h) + 1rem);
}
@media (min-width: 768px) {
  .content-area {
    padding-bottom: 1.5rem;
    margin-left: var(--sidebar-w);
  }
}

/* ── Admin cockpit fullscreen mode */
#app-shell.is-cockpit .sidebar,
#app-shell.is-cockpit .tab-bar {
  display: none !important;
}
#app-shell.is-cockpit .content-area {
  margin-left: 0;
  padding: 0;
}

/* ── Placeholder (pillar stubs) */
.pillar-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 40vh;
  color: var(--text-muted);
}
.pillar-icon { font-size: 2.5rem; }

/* ── Form elements */
.form-group { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem; }
label { font-size: 0.8rem; color: var(--text-secondary); letter-spacing: 0.04em; text-transform: uppercase; }
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: border-color var(--transition);
}
/* Focus ring: inputs get a glow ring, all other interactive elements get an outline */
*:focus-visible {
  outline: 2px solid var(--thread-color);
  outline-offset: 2px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--thread-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--thread-color) 18%, transparent);
}
textarea { resize: vertical; min-height: 80px; }

/* ── Chip row (multi-select tags) */
.chip-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  padding: 0.5rem 1rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.chip.is-selected {
  background: var(--thread-color);
  border-color: var(--thread-color);
  color: #111;
}

/* ── Accordion (shared structure — visual theming stays in pillar CSS) */
.acc-list { display: flex; flex-direction: column; gap: 0.4rem; }
.acc-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--transition);
}
.acc-item.is-open { border-color: var(--thread-color); }
.acc-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  text-align: left;
  background: transparent;
  cursor: pointer;
  transition: background var(--transition);
}
.acc-trigger:hover { background: var(--bg-raised); }
.acc-chevron {
  flex-shrink: 0;
  font-size: 1rem;
  color: var(--text-muted);
  transition: transform var(--transition);
  line-height: 1;
  margin-left: auto;
}
.acc-item.is-open .acc-chevron { transform: rotate(90deg); }
.acc-body {
  border-top: 1px solid var(--border);
  padding: 0.85rem 1rem 1rem;
}

/* ── Utility */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.text-muted  { color: var(--text-muted); }
.text-thread { color: var(--thread-color); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

/* ── Skeleton loading */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.35; }
  50%       { opacity: 0.6;  }
}
.skeleton-block {
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}
.skeleton-line {
  height: 13px;
  margin-bottom: 10px;
  background: var(--bg-raised);
  border-radius: 4px;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}
.skeleton-line.short  { width: 38%; }
.skeleton-line.medium { width: 62%; }
.skeleton-card {
  height: 158px;
  background: var(--bg-raised);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* ── View error state */
.view-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  min-height: 35vh;
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
}
.view-error p { font-size: 0.9rem; }
