/* =========================================================
   LUMARA GLOBAL STYLES & COMPONENT SYSTEM
   Every screen in the app (public site, dashboard, builder)
   imports this file after tokens.css. Components here are
   intentionally framework-agnostic plain CSS classes so the
   same markup works from plain PHP views.
   ========================================================= */

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  transition: background var(--duration-base) var(--ease-standard), color var(--duration-base) var(--ease-standard);
}

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

a { color: inherit; text-decoration: none; }

h1, h2, h3, h4 { font-family: var(--font-display); line-height: var(--lh-tight); margin: 0; font-weight: 700; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--lumara-purple-600);
  outline-offset: 2px;
  border-radius: 4px;
}

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--space-5);
}

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

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 1000;
  background: var(--brand-solid); color: #fff; padding: var(--space-3) var(--space-4);
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

/* ---------------------------------------------------------
   BUTTONS
--------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.75rem 1.5rem;
  font-size: var(--fs-body);
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: transform var(--duration-fast) var(--ease-standard),
              box-shadow var(--duration-base) var(--ease-standard),
              background var(--duration-base) var(--ease-standard),
              border-color var(--duration-base) var(--ease-standard);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--brand-gradient);
  color: #fff;
  box-shadow: var(--shadow-glow);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 16px 40px rgba(124, 58, 237, 0.38); }

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--lumara-purple-500); background: var(--bg-surface-2); }

.btn-ghost {
  background: transparent;
  color: var(--text-primary);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-surface-2); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #B91C1C; }

.btn-sm { padding: 0.5rem 1rem; font-size: var(--fs-small); border-radius: var(--radius-sm); }
.btn-lg { padding: 1rem 2rem; font-size: var(--fs-body-lg); }
.btn-icon { padding: 0.6rem; border-radius: var(--radius-sm); }
.btn-block { width: 100%; }

/* ---------------------------------------------------------
   CARDS
--------------------------------------------------------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.card-glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--shadow-md);
}

.card-hover { transition: transform var(--duration-base) var(--ease-standard), box-shadow var(--duration-base) var(--ease-standard); }
.card-hover:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

/* ---------------------------------------------------------
   FORM CONTROLS
--------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-5); }

.field-label {
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--text-primary);
}
.field-label .required { color: var(--danger); margin-left: 2px; }

.field-hint { font-size: var(--fs-xsmall); color: var(--text-secondary); }
.field-error { font-size: var(--fs-xsmall); color: var(--danger); display: flex; align-items: center; gap: var(--space-1); }

.input, .select, .textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: var(--fs-body);
  transition: border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard);
}
.input::placeholder, .textarea::placeholder { color: var(--text-secondary); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--lumara-purple-500);
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.14);
  outline: none;
}
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--danger); }
.textarea { resize: vertical; min-height: 6rem; }

.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23675C86' stroke-width='1.6' fill='none' fill-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  padding-right: 2.2rem;
}

.checkbox-row, .radio-row { display: flex; align-items: flex-start; gap: var(--space-3); }
.checkbox-row input, .radio-row input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--lumara-purple-600); }

.toggle { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0; background: var(--border-strong); border-radius: var(--radius-full);
  transition: background var(--duration-base) var(--ease-standard);
}
.toggle-track::before {
  content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform var(--duration-base) var(--ease-standard);
}
.toggle input:checked + .toggle-track { background: var(--brand-gradient); }
.toggle input:checked + .toggle-track::before { transform: translateX(20px); }

/* ---------------------------------------------------------
   BADGES / STATUS
--------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 0.25rem 0.7rem; border-radius: var(--radius-full);
  font-size: var(--fs-xsmall); font-weight: 600;
}
.badge-brand { background: var(--brand-gradient-soft); color: var(--lumara-purple-700); }
.badge-success { background: rgba(23,166,115,0.12); color: var(--success); }
.badge-warning { background: rgba(217,119,6,0.12); color: var(--warning); }
.badge-danger { background: rgba(220,38,38,0.12); color: var(--danger); }
.badge-neutral { background: var(--bg-surface-2); color: var(--text-secondary); }

/* ---------------------------------------------------------
   ALERTS
--------------------------------------------------------- */
.alert {
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-4) var(--space-5); border-radius: var(--radius-md);
  border: 1px solid transparent; font-size: var(--fs-small);
}
.alert-icon { flex-shrink: 0; margin-top: 2px; }
.alert-info { background: var(--brand-gradient-soft); border-color: rgba(124,58,237,0.25); color: var(--lumara-purple-700); }
.alert-success { background: rgba(23,166,115,0.08); border-color: rgba(23,166,115,0.3); color: var(--success); }
.alert-warning { background: rgba(217,119,6,0.08); border-color: rgba(217,119,6,0.3); color: var(--warning); }
.alert-danger { background: rgba(220,38,38,0.08); border-color: rgba(220,38,38,0.3); color: var(--danger); }

/* ---------------------------------------------------------
   TOASTS
--------------------------------------------------------- */
.toast-region {
  position: fixed; bottom: var(--space-5); right: var(--space-5); z-index: 1200;
  display: flex; flex-direction: column; gap: var(--space-3); width: min(360px, 90vw);
}
.toast {
  display: flex; align-items: flex-start; gap: var(--space-3);
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--lumara-purple-600);
  border-radius: var(--radius-md); padding: var(--space-4);
  box-shadow: var(--shadow-lg);
  animation: toast-in var(--duration-slow) var(--ease-standard);
}
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-danger { border-left-color: var(--danger); }
.toast-title { font-weight: 600; font-size: var(--fs-small); }
.toast-message { font-size: var(--fs-xsmall); color: var(--text-secondary); }
.toast-close { margin-left: auto; background: none; border: none; color: var(--text-secondary); font-size: 1rem; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ---------------------------------------------------------
   MODAL
--------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(21,15,39,0.55);
  backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center;
  padding: var(--space-5); z-index: 1300;
}
.modal {
  background: var(--bg-surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 520px;
  padding: var(--space-6); max-height: 88vh; overflow-y: auto;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); }
.modal-title { font-size: var(--fs-h3); }
.modal-close { background: none; border: none; color: var(--text-secondary); font-size: 1.25rem; padding: var(--space-1); }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--space-3); margin-top: var(--space-6); }

/* ---------------------------------------------------------
   LOADING / SKELETON
--------------------------------------------------------- */
.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid rgba(124,58,237,0.2); border-top-color: var(--lumara-purple-600);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--bg-surface-2) 25%, var(--border-subtle) 37%, var(--bg-surface-2) 63%);
  background-size: 400% 100%;
  animation: skeleton-wave 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-wave { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------------------------------------------------------
   EMPTY / ERROR STATES
--------------------------------------------------------- */
.state-panel {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: var(--space-3); padding: var(--space-8) var(--space-5);
  color: var(--text-secondary);
}
.state-panel .state-icon {
  width: 56px; height: 56px; border-radius: var(--radius-md);
  background: var(--brand-gradient-soft); display: flex; align-items: center; justify-content: center;
  color: var(--lumara-purple-600);
}
.state-panel h3 { color: var(--text-primary); font-size: var(--fs-h3); }
.state-panel p { max-width: 40ch; font-size: var(--fs-small); }

/* ---------------------------------------------------------
   HEADER / NAV
--------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 900;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-bottom: 1px solid var(--border-subtle);
}
.nav-row {
  display: flex; align-items: center; justify-content: space-between;
  height: var(--header-height);
}
.brand { display: flex; align-items: center; gap: var(--space-2); font-weight: 800; font-size: 1.25rem; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--brand-gradient); display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1rem; font-weight: 800;
}
.nav-links { display: flex; align-items: center; gap: var(--space-6); }
.nav-links a { font-size: var(--fs-small); font-weight: 600; color: var(--text-secondary); transition: color var(--duration-fast); }
.nav-links a:hover { color: var(--text-primary); }
.nav-actions { display: flex; align-items: center; gap: var(--space-3); }
.nav-toggle { display: none; background: none; border: none; padding: var(--space-2); }

.theme-switch {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--radius-full);
  border: 1px solid var(--border-strong); background: var(--bg-surface); color: var(--text-primary);
}

@media (max-width: 880px) {
  .nav-links { position: fixed; top: var(--header-height); left: 0; right: 0; bottom: 0;
    background: var(--bg-canvas); flex-direction: column; align-items: flex-start; padding: var(--space-6) var(--space-5);
    transform: translateX(100%); transition: transform var(--duration-base) var(--ease-standard); gap: var(--space-5);
  }
  .nav-links.is-open { transform: translateX(0); }
  .nav-toggle { display: block; }
}

/* ---------------------------------------------------------
   APP SHELL (builder, dashboard, and other in-product screens)
--------------------------------------------------------- */
.app-body { height: 100%; overflow: hidden; }
html:has(.app-body) { height: 100%; }

.app-header {
  height: var(--header-height);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  flex-shrink: 0;
}
.app-header-row {
  height: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding-inline: var(--space-5);
}
.app-header-left { display: flex; align-items: center; gap: var(--space-3); flex-shrink: 0; }
.app-brand { display: flex; }
.app-breadcrumb-sep { color: var(--text-secondary); }
.app-breadcrumb { font-size: var(--fs-small); color: var(--text-secondary); font-weight: 600; }
.app-header-center { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; }
.app-header-right { display: flex; align-items: center; gap: var(--space-3); flex-shrink: 0; }

.app-main {
  height: calc(100vh - var(--header-height));
  overflow: auto;
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------
   FOOTER
--------------------------------------------------------- */
.site-footer { border-top: 1px solid var(--border-subtle); background: var(--bg-surface); padding-block: var(--space-8) var(--space-6); }
.footer-grid { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: var(--space-7); }
.footer-col h4 { font-size: var(--fs-small); margin-bottom: var(--space-4); }
.footer-col ul { display: flex; flex-direction: column; gap: var(--space-3); }
.footer-col a { font-size: var(--fs-small); color: var(--text-secondary); }
.footer-col a:hover { color: var(--lumara-purple-600); }
.footer-bottom {
  margin-top: var(--space-7); padding-top: var(--space-5); border-top: 1px solid var(--border-subtle);
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: var(--space-3);
  font-size: var(--fs-xsmall); color: var(--text-secondary);
}
@media (max-width: 780px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------------------------------------------------------
   UTILITIES
--------------------------------------------------------- */
.section { padding-block: var(--space-9); }
.section-tight { padding-block: var(--space-7); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-8); align-items: center; }
.text-center { text-align: center; }
.text-secondary { color: var(--text-secondary); }
.stack { display: flex; flex-direction: column; }
.gap-2 { gap: var(--space-2); } .gap-3 { gap: var(--space-3); } .gap-4 { gap: var(--space-4); } .gap-5 { gap: var(--space-5); }
.row { display: flex; align-items: center; }
.mt-6 { margin-top: var(--space-6); } .mt-7 { margin-top: var(--space-7); }

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; gap: var(--space-6); }
}

/* Honeypot: off-screen rather than display:none, since some bots
   skip display:none fields specifically — this still catches them
   while remaining invisible and unreachable for real visitors.
   Shared across any page with a spam-protected form (public form
   submission, registration, etc). */
.lumara-hp-wrap {
  position: absolute !important;
  left: -9999px !important;
  width: 1px; height: 1px; overflow: hidden;
}
