/* Closet Privé invoice tool — iPhone-first.
   Charcoal base, gold accent, big touch targets.
   Single-file vanilla CSS — no framework. */

:root {
  --bg: #0f0f0f;
  --bg-card: #181818;
  --bg-elev: #232323;
  --border: #2a2a2a;
  --text: #fafaf7;
  --muted: #9a9a96;
  --gold: #c9a84a;
  --gold-soft: #d8b86a;
  --good: #5fc18a;
  --warn: #e8c267;
  --bad: #e57373;
  --radius: 12px;
  --tap: 48px;
  --serif: "Times New Roman", Times, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

input, button, select, textarea {
  font-family: inherit;
  font-size: 16px;  /* iOS won't zoom on focus if ≥16px */
}

a { color: var(--gold-soft); }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ─── Header (compact) ─── */
.hdr {
  padding: max(6px, env(safe-area-inset-top, 0)) 16px 6px;
  border-bottom: 1px solid var(--border);
  text-align: center;
  background: var(--bg);
  position: sticky; top: 0;
  z-index: 5;
}
.hdr__brand {
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text);
  line-height: 1.2;
}

/* ─── Page + cards ─── */
.page {
  padding: 16px;
  padding-bottom: max(20px, env(safe-area-inset-bottom, 20px));
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px;
}
.card__title {
  margin: 0 0 12px;
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

/* ─── Form rows ─── */
.row {
  display: flex;
  gap: 10px;
}
.row--triple {
  display: grid;
  grid-template-columns: 1fr 80px 1fr;
  gap: 10px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.field--grow { flex-grow: 2; }
.field--narrow { flex: 0 0 80px; }
.field__label {
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}
input[type="text"], input[type="number"], input[type="date"] {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  min-height: var(--tap);
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
}
input:focus { border-color: var(--gold); }

/* ─── Voice mic ─── */
.input-with-mic {
  position: relative;
  display: flex;
}
.input-with-mic input { padding-right: 48px; }
.mic {
  position: absolute;
  right: 4px; top: 50%;
  transform: translateY(-50%);
  width: 40px; height: 40px;
  background: transparent;
  border: 0;
  color: var(--muted);
  border-radius: 8px;
  display: grid; place-items: center;
  cursor: pointer;
}
.mic:hover { color: var(--gold); }
.mic[aria-pressed="true"] {
  color: var(--gold);
  background: rgba(201,168,74,0.15);
}
.mic[aria-pressed="true"] svg { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.18); }
}

/* ─── Items list ─── */
.items {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.item {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.item__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.item__num {
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.item__remove {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 28px;
  line-height: 1;
  width: 36px; height: 36px;
  cursor: pointer;
  border-radius: 8px;
}
.item__remove:hover { color: var(--bad); background: rgba(229,115,115,0.1); }

/* ─── Totals ─── */
.totals {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px 0;
  font-size: 14px;
  color: var(--muted);
}
.totals strong {
  font-family: var(--serif);
  font-size: 22px;
  color: var(--text);
}

/* ─── Buttons ─── */
.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.actions--row {
  flex-direction: row;
  flex-wrap: wrap;
}
.actions--row > .btn { flex: 1 1 auto; min-width: 120px; }
.btn {
  min-height: var(--tap);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.3px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.06s ease, opacity 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.55; cursor: progress; }
.btn--primary {
  background: var(--gold);
  color: #0a0a0a;
}
.btn--primary:hover { background: var(--gold-soft); }
.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn--ghost:hover { background: var(--bg-elev); }

/* ─── Warnings ─── */
.warnings { border-color: rgba(232,194,103,0.5); background: rgba(232,194,103,0.06); }
.warnings ul { margin: 0; padding-left: 18px; }
.warnings li { color: var(--warn); margin-bottom: 4px; }

/* ─── Result + preview ─── */
.result { padding: 0; overflow: hidden; }
.result .card__title { padding: 14px 14px 0; }

/* Image preview: fits container width, no horizontal scroll. Aspect ratio
   of A4 portrait keeps the height reasonable on narrow screens. */
.pdf-preview {
  display: block;
  width: 100%;
  height: auto;
  background: #fafaf7;
  border: 0;
  margin: 10px 0 0;
}
/* Iframe fallback (used only if PNG preview is unavailable) */
.pdf-preview--iframe {
  height: 70vh;
  min-height: 420px;
  width: 100%;
}

.result__actions {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.result__actions .actions--row { gap: 10px; }

.btn--whatsapp {
  background: #25d366;          /* WhatsApp brand green */
  color: #ffffff;
  border-color: #25d366;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 17px;
  min-height: 56px;             /* primary, prominent */
}
.btn--whatsapp:hover {
  background: #1ebe5a;
  border-color: #1ebe5a;
}
.btn--whatsapp svg { flex-shrink: 0; }

.btn--text {
  background: transparent;
  border: 0;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 4px;
  min-height: 36px;
  padding: 6px 0;
  font-size: 14px;
}
.btn--text:hover { color: var(--text); }

/* ─── Toast ─── */
.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  max-width: 90vw;
  text-align: center;
  z-index: 99;
  box-shadow: 0 6px 24px rgba(0,0,0,0.6);
}
.toast--err { border-color: var(--bad); color: var(--bad); }
.toast--ok  { border-color: var(--good); color: var(--good); }

/* ─── Wider screens — keep mobile look but center ─── */
@media (min-width: 720px) {
  .pdf-preview { height: 75vh; }
}

/* ─── Reduced motion ─── */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

[hidden] { display: none !important; }
