/* =====================================================================
   Zoe Wedding Dress — Estilos globais (protótipo de demonstração)
   Paleta baseada no Design System do projecto.
   ===================================================================== */

:root {
  --background: #FAF8F5;
  --surface: #FFFFFF;
  --surface-2: #F3EFE9;
  --primary: #2C3E50;
  --secondary: #34495E;
  --accent: #B89B72;
  --accent-soft: #E9DDC9;
  --text: #292929;
  --muted: #6E6E6E;
  --border: #E2DDD5;
  --success: #27AE60;
  --error: #E74C3C;
  --warning: #E67E22;
  --info: #2E86C1;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(44, 62, 80, 0.06);
  --shadow: 0 6px 20px rgba(44, 62, 80, 0.10);
  --sidebar-w: 268px;
  --gap: 1.25rem;
}

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

html {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }
body.no-scroll { overflow: hidden; }

h1, h2, h3, h4 { color: var(--primary); line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 1rem; }
p { margin: 0; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--accent); }
code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.85em;
  background: var(--surface-2);
  padding: 0.1em 0.4em;
  border-radius: 5px;
}

.muted { color: var(--muted); }
.link { color: var(--accent); font-weight: 600; font-size: 0.9rem; }
.link:hover { text-decoration: underline; }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 200;
  background: var(--primary); color: #fff; padding: 0.6rem 1rem; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* ------------------------------ Layout ------------------------------ */
.layout {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin .2s ease;
}

.app-main {
  flex: 1;
  padding: 1.5rem clamp(1rem, 3vw, 2.25rem) 2.5rem;
}

.screen { max-width: 1200px; margin: 0 auto; }

.page-header {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem clamp(1rem, 3vw, 2.25rem);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.header-left { display: flex; align-items: center; gap: 0.75rem; }
.header-title { font-size: 1.2rem; }
.header-crumb { color: var(--muted); font-size: 0.82rem; }
.header-user { color: var(--muted); font-size: 0.85rem; }
.header-user strong { color: var(--primary); }

.menu-toggle {
  display: none;
  background: transparent; color: var(--primary);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 0.35rem 0.6rem; font-size: 1.1rem; cursor: pointer;
}

.app-footer {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
  padding: 1rem clamp(1rem, 3vw, 2.25rem);
  border-top: 1px solid var(--border);
  color: var(--muted); font-size: 0.8rem;
}

/* ------------------------------ Sidebar ----------------------------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #24323f 0%, #1c2731 100%);
  color: #E7ECF1;
  z-index: 60;
  overflow-y: auto;
}
.sidebar__inner { display: flex; flex-direction: column; min-height: 100%; padding: 1.25rem 1rem; }
.sidebar__brand { display: flex; align-items: center; gap: 0.75rem; padding: 0.25rem 0.4rem 1.25rem; }
.sidebar__brand strong { display: block; font-size: 1rem; color: #fff; }
.sidebar__brand small { color: #9FB0BE; font-size: 0.75rem; }
.sidebar__logo {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--accent); color: #1c2731; font-weight: 800; font-size: 1.25rem;
}
.sidebar__nav { flex: 1; display: flex; flex-direction: column; gap: 0.9rem; }
.nav-group__title {
  font-size: 0.68rem; letter-spacing: 0.09em; text-transform: uppercase;
  color: #7C8C99; margin: 0 0.5rem 0.35rem;
}
.nav-link {
  display: block; padding: 0.55rem 0.7rem; border-radius: 8px;
  color: #C9D4DD; font-size: 0.92rem; transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-link.is-active { background: var(--accent); color: #1c2731; font-weight: 600; }

.sidebar__foot { border-top: 1px solid rgba(255,255,255,0.1); padding-top: 0.9rem; margin-top: 1rem; }
.sidebar__user { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.7rem; }
.sidebar__user strong { display: block; color: #fff; font-size: 0.88rem; }
.sidebar__user small { color: #9FB0BE; font-size: 0.72rem; }
.avatar {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: rgba(184,155,114,0.25); color: #E9DDC9; font-weight: 700;
}

/* ------------------------------ Botões ------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  font: inherit; font-size: 0.9rem; font-weight: 600;
  padding: 0.55rem 1rem; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--primary);
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--secondary); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--danger { background: var(--error); border-color: var(--error); color: #fff; }
.btn--danger:hover { filter: brightness(0.95); }
.btn--sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; border-radius: 7px; }
.btn--block { width: 100%; }

/* ------------------------------ Toolbar ----------------------------- */
.page-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem;
}
.toolbar-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.search-field { flex: 1; min-width: 240px; }
.search-field input {
  width: 100%; padding: 0.6rem 0.85rem; border: 1px solid var(--border);
  border-radius: 9px; font: inherit; background: var(--surface);
}
.search-field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.filters { display: flex; gap: 0.8rem; flex-wrap: wrap; }

.select-field { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; color: var(--muted); }
.select-field select {
  font: inherit; padding: 0.45rem 0.6rem; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); color: var(--text);
}

.segmented { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.seg {
  font: inherit; font-size: 0.82rem; padding: 0.4rem 0.7rem; border-radius: 7px;
  border: none; background: transparent; color: var(--muted); cursor: pointer;
}
.seg.is-active { background: var(--surface); color: var(--primary); font-weight: 600; box-shadow: var(--shadow-sm); }

.section-title { margin: 1.4rem 0 0.7rem; font-size: 1rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.subsection { margin: 1rem 0 0.5rem; font-size: 0.95rem; }

/* ------------------------------ Cards / KPIs ------------------------ */
.stat-grid {
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  margin-bottom: 1.4rem;
}
.stat-grid--3 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.stat-card {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow-sm);
}
.stat-card--primary { border-left-color: var(--primary); }
.stat-card--success { border-left-color: var(--success); }
.stat-card--warning { border-left-color: var(--warning); }
.stat-card--error { border-left-color: var(--error); }
.stat-card--info { border-left-color: var(--info); }
.stat-card--neutral { border-left-color: var(--accent); }
.stat-card__label { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card__value { font-size: 1.45rem; font-weight: 700; color: var(--primary); margin-top: 0.2rem; }
.stat-card__hint { font-size: 0.75rem; color: var(--muted); margin-top: 0.15rem; }
.stat-card__icon { font-size: 1.4rem; color: var(--accent); opacity: 0.7; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.2rem; box-shadow: var(--shadow-sm);
}
.card--danger { border-color: rgba(231,76,60,0.35); background: #FFF7F6; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.8rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--gap); margin-bottom: var(--gap); }
.grid-2 > .card { min-width: 0; }

.quick-links { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.quick {
  padding: 0.5rem 0.9rem; border-radius: 9px; background: var(--surface-2);
  color: var(--primary); font-size: 0.85rem; font-weight: 500; border: 1px solid var(--border);
}
.quick:hover { background: var(--accent-soft); }

/* ------------------------------ Listas ------------------------------ */
.list { list-style: none; display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.65rem 0; border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: none; }
.list-row strong { color: var(--primary); font-weight: 600; }
.list-row__meta { display: flex; align-items: center; gap: 0.6rem; color: var(--muted); font-size: 0.82rem; flex-wrap: wrap; }
.empty-inline { color: var(--muted); font-size: 0.88rem; padding: 0.6rem 0; }

/* ------------------------------ Tabelas ----------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th, .data-table td { padding: 0.7rem 0.85rem; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { background: var(--surface-2); color: var(--secondary); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; }
.data-table tbody tr:hover { background: #FBFAF8; }
.data-table tbody tr:last-child td { border-bottom: none; }
.col-actions { white-space: nowrap; }
.col-num { text-align: right; }

/* ------------------------------ Badges ------------------------------ */
.badge {
  display: inline-block; padding: 0.18rem 0.55rem; border-radius: 999px;
  font-size: 0.74rem; font-weight: 600; line-height: 1.4;
  background: var(--surface-2); color: var(--muted);
}
.badge--success { background: #E6F6EC; color: #1E8449; }
.badge--info { background: #E7F1FA; color: #1F618D; }
.badge--warning { background: #FCEFE1; color: #B9651A; }
.badge--error { background: #FDECEA; color: #B03A2E; }
.badge--neutral { background: var(--surface-2); color: var(--muted); }

.amount--warn { color: var(--warning); font-weight: 600; }

/* ------------------------------ Empty / loading --------------------- */
.empty-state {
  padding: 2rem 1rem; text-align: center; color: var(--muted);
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}
.empty-state--page { max-width: 560px; margin: 2rem auto; padding: 2.5rem; }
.empty-state h2 { margin-bottom: 0.5rem; }
.empty-state p { margin-bottom: 1rem; }

.loading, .loading-inline { display: flex; align-items: center; gap: 0.6rem; color: var(--muted); }
.loading { justify-content: center; padding: 3rem 1rem; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------ Formulários ------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.9rem; }
.field { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--secondary); }
.field--full { grid-column: 1 / -1; }
.field > span { font-weight: 600; }
.field input, .field select, .field textarea {
  font: inherit; padding: 0.55rem 0.7rem; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); color: var(--text); width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.field input:disabled { background: var(--surface-2); color: var(--muted); }
.field__group { position: relative; display: flex; }
.field__group input { padding-right: 4rem; }
.field__toggle {
  position: absolute; right: 0.4rem; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; color: var(--accent); font: inherit;
  font-size: 0.8rem; font-weight: 600; cursor: pointer; padding: 0.3rem 0.5rem;
}
.form-note { color: var(--muted); font-size: 0.82rem; }

.detail-list { display: grid; grid-template-columns: 150px 1fr; gap: 0.5rem 1rem; font-size: 0.9rem; }
.detail-list dt { color: var(--muted); font-weight: 600; }
.detail-list dd { color: var(--text); }

.doc { display: flex; flex-direction: column; gap: 0.7rem; }
.doc__clause { margin-top: 0.5rem; padding: 0.8rem; background: var(--surface-2); border-radius: 8px; font-size: 0.85rem; }

/* ------------------------------ Modal ------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20, 28, 36, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  animation: pop .16s ease;
}
@keyframes pop { from { transform: scale(.97); opacity: .6; } to { transform: scale(1); opacity: 1; } }
.modal--sm { max-width: 400px; }
.modal--lg { max-width: 720px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.2rem; border-bottom: 1px solid var(--border); }
.modal__head h3 { font-size: 1.05rem; }
.modal__close { background: transparent; border: none; font-size: 1rem; color: var(--muted); cursor: pointer; padding: 0.2rem 0.4rem; border-radius: 6px; }
.modal__close:hover { background: var(--surface-2); }
.modal__body { padding: 1.2rem; }
.modal__foot { display: flex; justify-content: flex-end; gap: 0.6rem; padding: 0.9rem 1.2rem; border-top: 1px solid var(--border); }

/* ------------------------------ Toasts ------------------------------ */
.toast-host { position: fixed; right: 1rem; bottom: 1rem; z-index: 200; display: flex; flex-direction: column; gap: 0.6rem; }
.toast {
  display: flex; align-items: center; gap: 0.6rem;
  min-width: 240px; max-width: 360px;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--info);
  border-radius: 10px; padding: 0.7rem 0.9rem; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s;
}
.toast--in { opacity: 1; transform: translateY(0); }
.toast--success { border-left-color: var(--success); }
.toast--error { border-left-color: var(--error); }
.toast--warning { border-left-color: var(--warning); }
.toast--info { border-left-color: var(--info); }
.toast__icon { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); font-weight: 700; font-size: 0.8rem; }
.toast__msg { font-size: 0.88rem; }

/* ------------------------------ Login ------------------------------- */
.login-mode .sidebar { display: none; }
.login-mode .layout { margin-left: 0; }
.login-mode .page-header { display: none; }
.login-mode .app-footer { display: none; }
.login-mode .app-main { padding: 0; }

.login { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.login__panel { display: flex; flex-direction: column; justify-content: center; padding: clamp(2rem, 6vw, 5rem); }
.login__brand { margin-bottom: 2rem; }
.login__logo { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 14px; background: var(--primary); color: var(--accent); font-size: 1.8rem; font-weight: 800; margin-bottom: 1rem; }
.login__brand h1 { font-size: 1.7rem; }
.login__brand p { color: var(--muted); margin-top: 0.3rem; }
.login__form { display: flex; flex-direction: column; gap: 1rem; max-width: 420px; }
.login__error { color: var(--error); font-size: 0.85rem; background: #FDECEA; padding: 0.5rem 0.7rem; border-radius: 8px; }
.login__demo-note { color: var(--muted); font-size: 0.78rem; text-align: center; }
.login__aside {
  background: linear-gradient(160deg, #24323f, #1c2731);
  color: #DCE4EA; display: flex; align-items: center; padding: clamp(2rem, 6vw, 5rem);
}
.login__aside-content h2 { color: #fff; margin-bottom: 1rem; }
.login__aside-content ul { list-style: none; display: flex; flex-direction: column; gap: 0.7rem; }
.login__aside-content li { padding-left: 1.4rem; position: relative; font-size: 0.95rem; }
.login__aside-content li::before { content: "✓"; position: absolute; left: 0; color: var(--accent); font-weight: 700; }
.login__badge { margin-top: 2rem; display: inline-block; padding: 0.4rem 0.8rem; border-radius: 999px; background: rgba(184,155,114,0.2); color: #E9DDC9; font-size: 0.78rem; }

.nojs { padding: 2rem; text-align: center; }

/* ------------------------------ Responsivo -------------------------- */
@media (max-width: 1024px) {
  .grid-2 { grid-template-columns: 1fr; }
  .login { grid-template-columns: 1fr; }
  .login__aside { display: none; }
}

@media (max-width: 900px) {
  :root { --sidebar-w: 268px; }
  .layout { margin-left: 0; }
  .menu-toggle { display: inline-block; }
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .sidebar.is-open { transform: translateX(0); }
  body.nav-open::after {
    content: ""; position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 50;
  }
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .page-header { flex-wrap: wrap; }
  .header-user { display: none; }
  .detail-list { grid-template-columns: 1fr; }
  .data-table { font-size: 0.82rem; }
  .app-footer { flex-direction: column; }
}
