/* Quote / proforma invoice builder demo */

:root {
  --ink: #18181b;
  --ink-2: #3f3f46;
  --muted: #71717a;
  --line: #e4e4e7;
  --bg: #eeedf3;
  --card: #fff;
  --brand: #4338ca;
  --brand-soft: #eef2ff;
  --bad: #b91c1c;
  --radius: 16px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); line-height: 1.5; overflow-x: hidden; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.muted { color: var(--muted); }

.demo-strip {
  display: flex; flex-wrap: wrap; gap: 4px 14px; justify-content: space-between; align-items: center;
  padding: 8px 16px; font-size: 0.78rem; background: #0c0a1d; color: #d4d4d8;
}
.demo-strip strong { color: #c7d2fe; }
.demo-strip a { color: #fff; font-weight: 600; text-decoration: none; }
.demo-strip a:hover { text-decoration: underline; }

/* ---- App bar ------------------------------------------------------------------------ */
.appbar {
  position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px clamp(14px, 3vw, 28px); background: #1e1b4b; color: #fff;
}
.title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.title strong { display: block; font-size: 1.02rem; }
.title small { display: block; color: #c7d2fe; font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, #818cf8, #4338ca); flex: none; }
.mark svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px; border-radius: 10px;
  border: 1px solid transparent; background: #fff; color: #1e1b4b; font-weight: 700; font-size: 0.9rem; transition: filter 0.15s, transform 0.1s;
}
.btn:hover { filter: brightness(0.95); }
.btn:active { transform: scale(0.98); }
.btn.ghost { background: rgb(255 255 255 / 0.08); color: #fff; border-color: rgb(255 255 255 / 0.18); }
.btn.ghost b { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: rgb(255 255 255 / 0.18); font-size: 0.75rem; }
.editor .btn.ghost { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 0.85rem; }

.tabs { display: none; }

/* ---- Workspace ---------------------------------------------------------------------- */
.workspace { display: grid; grid-template-columns: minmax(360px, 460px) minmax(0, 1fr); gap: 24px; padding: 20px clamp(14px, 3vw, 28px) 60px; align-items: start; }
.editor { display: grid; gap: 14px; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; gap: 12px; }
.card h2 { font-size: 0.98rem; font-weight: 800; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; }
.card-head .muted { font-size: 0.82rem; }
details.card summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
details.card summary::-webkit-details-marker { display: none; }
details.card summary .muted { font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
details.card summary h2::after { content: " ▾"; color: var(--muted); font-weight: 500; }
details[open].card summary h2::after { content: " ▴"; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.f { display: grid; gap: 4px; min-width: 0; }
.f > span, .line-grid label span { font-size: 0.76rem; font-weight: 700; color: var(--muted); }
.f input, .f select, .f textarea, .line input, .line select {
  width: 100%; min-width: 0; height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; background: #fafafa; color: var(--ink);
}
.f textarea { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.45; }
.f input:focus, .f select:focus, .f textarea:focus, .line input:focus, .line select:focus { outline: 0; border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgb(67 56 202 / 0.15); }
.seg { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 11px; background: #f4f4f5; }
.seg button { border: 0; background: none; padding: 8px; border-radius: 8px; font-weight: 700; font-size: 0.88rem; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / 0.12); }
.iban-state { font-style: normal; color: #15803d; font-weight: 700; margin-left: 4px; }
.iban-state.bad { color: var(--bad); }

.lines { display: grid; gap: 10px; }
.line { border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: grid; gap: 8px; background: #fcfcfd; animation: rise 0.2s ease-out; }
.line-top { display: flex; gap: 6px; align-items: center; }
.ln { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: var(--brand-soft); color: var(--brand); font-weight: 800; font-size: 0.78rem; flex: none; }
.line .desc { flex: 1; font-weight: 600; }
.icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--muted); font-size: 1rem; flex: none; }
.icon:hover:not(:disabled) { color: var(--ink); background: #f4f4f5; }
.icon:disabled { opacity: 0.35; cursor: default; }
.line-grid { display: grid; grid-template-columns: 0.8fr 0.9fr 1.2fr 0.8fr 0.8fr; gap: 6px; }
.line-grid label { display: grid; gap: 3px; min-width: 0; }
.line-grid input, .line-grid select { height: 36px; padding: 0 8px; font-size: 0.88rem; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 0.82rem; }
.chip { border: 1px dashed #c7d2fe; background: var(--brand-soft); color: var(--brand); border-radius: 999px; padding: 4px 10px; font-weight: 600; font-size: 0.8rem; }
.chip:hover { border-style: solid; }
.after-lines { margin-top: 4px; }
.mini-total { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 12px 14px; border-radius: 12px; background: #f4f4f5; font-size: 0.86rem; color: var(--muted); }
.mini-total b { color: var(--ink); font-variant-numeric: tabular-nums; }
.mini-total .grand { margin-left: auto; }
.mini-total .grand b { color: var(--brand); font-size: 1.02rem; }
.colors { display: flex; gap: 8px; align-items: center; font-size: 0.76rem; font-weight: 700; color: var(--muted); }
.colors button { width: 28px; height: 28px; border-radius: 50%; border: 3px solid #fff; background: var(--c); box-shadow: 0 0 0 1px var(--line); }
.colors button[aria-checked="true"] { box-shadow: 0 0 0 2px var(--c); }

/* ---- A4 preview ---------------------------------------------------------------------- */
.preview { position: sticky; top: 84px; min-width: 0; }
.paper-scale { --s: 1; width: calc(794px * var(--s)); margin: 0 auto; }
.paper {
  --accent: #4f46e5;
  width: 794px; min-height: 1123px; padding: 56px 60px 40px; background: #fff; color: #1f2937;
  transform: scale(var(--s)); transform-origin: top left; box-shadow: 0 20px 50px rgb(30 27 75 / 0.18); border-radius: 4px;
  display: flex; flex-direction: column; font-size: 13px; line-height: 1.5;
}
.p-head { display: flex; justify-content: space-between; gap: 30px; padding-bottom: 24px; border-bottom: 3px solid var(--accent); }
.p-seller { display: flex; gap: 14px; max-width: 360px; }
.p-logo { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 14px; background: var(--accent); color: #fff; font-weight: 800; font-size: 20px; flex: none; }
.p-seller strong { font-size: 15px; display: block; margin-bottom: 2px; }
.p-seller p { color: #6b7280; font-size: 11.5px; }
.p-title { text-align: right; }
.p-title h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; color: var(--accent); }
.p-title dl { margin: 10px 0 0; display: grid; gap: 2px; }
.p-title dl div { display: flex; justify-content: flex-end; gap: 12px; }
.p-title dt { color: #6b7280; }
.p-title dd { margin: 0; font-weight: 700; min-width: 100px; }
.p-to { margin: 24px 0 14px; padding: 14px 16px; border-radius: 10px; background: #f8fafc; max-width: 360px; }
.p-to strong { font-size: 14px; }
.p-to p { color: #4b5563; font-size: 12px; }
.p-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 800; color: var(--accent); margin-bottom: 2px; }
.p-intro { color: #4b5563; margin-bottom: 14px; }
.p-table { width: 100%; border-collapse: collapse; margin-top: 4px; }
.p-table th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: #6b7280; padding: 9px 8px; border-bottom: 2px solid #e5e7eb; }
.p-table td { padding: 10px 8px; border-bottom: 1px solid #f0f0f3; vertical-align: top; }
.p-table td small { display: block; color: #059669; font-size: 11px; }
.p-table td:first-child { color: #9ca3af; width: 26px; }
.p-table .r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ph { color: #c4c4cc; }
.center { text-align: center; }
.p-bottom { display: grid; grid-template-columns: 1fr 300px; gap: 30px; margin-top: 22px; }
.p-notes { display: grid; gap: 4px; align-content: start; color: #4b5563; font-size: 12px; }
.p-notes .p-label:not(:first-child) { margin-top: 10px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0.02em; color: #111827; }
.p-totals dl { margin: 0; display: grid; }
.p-totals dl div { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid #f0f0f3; font-variant-numeric: tabular-nums; }
.p-totals dt { color: #6b7280; }
.p-totals dd { margin: 0; font-weight: 600; }
.p-totals .grand { margin-top: 6px; padding: 12px 14px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; }
.p-totals .grand dt { color: rgb(255 255 255 / 0.85); font-weight: 600; }
.p-totals .grand dd { font-size: 17px; font-weight: 800; }
.words { margin-top: 8px !important; font-size: 11px; color: #6b7280; font-style: italic; text-align: right; }
.p-foot { margin-top: auto; padding-top: 40px; display: flex; justify-content: space-between; gap: 40px; }
.sign { flex: 1; max-width: 260px; display: grid; gap: 34px; font-size: 11px; color: #6b7280; }
.sign b { border-top: 1px solid #d1d5db; padding-top: 6px; font-weight: 600; color: #374151; }
.p-demo { margin-top: 18px !important; text-align: center; font-size: 10px; color: #9ca3af; }

/* ---- Drawer --------------------------------------------------------------------------- */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgb(12 10 29 / 0.4); animation: fade 0.2s; }
.scrim[hidden], .drawer[hidden] { display: none; }
.drawer {
  position: fixed; z-index: 41; top: 0; right: 0; bottom: 0; width: min(380px, 100%); overflow-y: auto;
  background: var(--card); box-shadow: -20px 0 50px rgb(0 0 0 / 0.2); padding: 18px; animation: slide 0.25s ease-out;
}
.drawer header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.drawer h2 { font-size: 1.1rem; }
.drawer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.drawer li { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.drawer li.current { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.doc-open { display: grid; gap: 2px; width: 100%; text-align: left; padding: 12px 14px; border: 0; background: none; }
.doc-open:hover { background: #fafafa; }
.d-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.d-name { font-weight: 600; }
.d-meta { color: var(--muted); font-size: 0.82rem; }
.st { font-size: 0.72rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: #f4f4f5; color: var(--ink-2); }
.st.gonderildi { background: #e0f2fe; color: #0369a1; }
.st.kabul { background: #dcfce7; color: #15803d; }
.st.red { background: #fee2e2; color: var(--bad); }
.d-actions { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--line); background: #fafafa; }
.link { border: 0; background: none; padding: 0; color: var(--brand); font-weight: 700; font-size: 0.82rem; }
.link.danger { color: var(--bad); }

.toast {
  position: fixed; z-index: 60; left: 50%; bottom: 22px; transform: translateX(-50%); max-width: calc(100% - 32px);
  padding: 11px 16px; border-radius: 12px; background: #1e1b4b; color: #fff; font-weight: 600; font-size: 0.9rem;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.25); animation: up 0.25s ease-out;
}
.toast[hidden] { display: none; }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
@keyframes up { from { opacity: 0; transform: translate(-50%, 8px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---- Responsive ------------------------------------------------------------------------- */
@media (max-width: 980px) {
  .appbar { position: static; }
  .actions { width: 100%; }
  .actions .btn { flex: 1 1 auto; }
  .tabs {
    position: sticky; top: 0; z-index: 19; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 8px 14px;
    background: #1e1b4b;
  }
  .tabs button { border: 0; border-radius: 9px; padding: 9px; font-weight: 700; background: rgb(255 255 255 / 0.08); color: #c7d2fe; }
  .tabs button[aria-selected="true"] { background: #fff; color: #1e1b4b; }
  .workspace { grid-template-columns: 1fr; padding: 14px 14px 60px; }
  .workspace[data-view="edit"] .preview { display: none; }
  .workspace[data-view="preview"] .editor { display: none; }
  .preview { position: static; }
}
@media (max-width: 520px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .line-grid { grid-template-columns: 1fr 1fr 1fr; }
  .line-grid label:nth-child(3) { grid-column: span 1; }
  .mini-total .grand { margin-left: 0; width: 100%; }
}

/* ---- Print: only the paper, at real A4 size ------------------------------------------------- */
@page { size: A4; margin: 0; }
@media print {
  body { background: #fff; }
  .demo-strip, .appbar, .tabs, .editor, .drawer, .scrim, .toast { display: none !important; }
  .workspace { display: block; padding: 0; }
  .workspace .preview { display: block !important; position: static; }
  .paper-scale { width: auto; height: auto !important; }
  .paper { width: 210mm; min-height: 297mm; transform: none; box-shadow: none; border-radius: 0; padding: 16mm 15mm 12mm; }
  .paper, .paper * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
