/* VistaSculpt-branded styles for the PHP dashboard (light theme; dark theme comes in phase 2). */
:root {
  --orange: #f9a61e;
  --coral: #dd513d;
  --ink: #111111;
  --bg: #f2f2f2;
  --card: #ffffff;
  --border: #e3e3e3;
  --muted: #6b6b6b;
  --green: #4caf50;
  --red: #c0392b;
  --input-bg: #ffffff;
}

:root[data-theme="dark"] {
  --ink: #f4f2ee; --bg: #14120f; --card: #201d18; --border: #34302a; --muted: #b3ada3; --input-bg: #1a1712;
}
:root[data-theme="dark"] .table thead th { background: #26201a; }
:root[data-theme="dark"] input, :root[data-theme="dark"] select, :root[data-theme="dark"] textarea { background: #1a1712; border-color: #3a352d; color: var(--ink); }
:root[data-theme="dark"] code { background: rgba(255,255,255,.08); }
:root[data-theme="dark"] .adv-row td { background: #1a1712; }
:root[data-theme="dark"] .alert-error { background: #3a1c17; border-color: #6b2f26; color: #f0a99f; }
:root[data-theme="dark"] .alert-ok { background: #16301f; border-color: #2f5c3f; color: #9fe0b8; }
:root[data-theme="dark"] .btn-ghost:hover { background: rgba(255,255,255,.06); }
:root[data-theme="dark"] .lang-btn.active { background: rgba(255,255,255,.12); }

/* Language + theme switches */
.switches { display: inline-flex; align-items: center; gap: 6px; }
.icon-btn { border: 1px solid var(--border); background: transparent; color: var(--ink); border-radius: 6px; padding: 4px 9px; cursor: pointer; font-size: 14px; line-height: 1; }
.lang-seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.lang-btn { border: 0; background: transparent; padding: 4px 8px; cursor: pointer; font-size: 14px; opacity: .5; }
.lang-btn.active { opacity: 1; background: rgba(0,0,0,.06); }
.switches-float { position: fixed; top: 12px; right: 12px; z-index: 10; }
a.who { text-decoration: none; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Poppins", "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}
a { color: inherit; }
h1 { font-size: 1.6rem; margin: 0 0 .3rem; }
h2 { font-size: 1.15rem; margin: 0 0 .6rem; }
.muted { color: var(--muted); }

/* Topbar */
.topbar { background: var(--card); border-bottom: 1px solid var(--border); }
.topbar-inner {
  max-width: 1100px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 20px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; text-decoration: none; }
.brand-logo { height: 28px; width: auto; }
.nav { display: flex; gap: 16px; flex: 1; }
.nav a { color: var(--muted); text-decoration: none; }
.nav a:hover { color: var(--ink); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-right form { margin: 0; }
.who { color: var(--muted); font-size: 13px; }

/* Layout */
.main { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }

/* Card */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 16px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 14px; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-weight: 500; cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--coral); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--ink); }
.btn-ghost:hover { background: rgba(0,0,0,.04); }
.btn-danger { background: transparent; border-color: #e6b3ac; color: var(--red); }
.btn-danger:hover { background: rgba(192,57,43,.06); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-weight: 500; }
input, select, textarea {
  font: inherit; padding: 9px 11px; border: 1px solid #cfcfcf; border-radius: 8px;
  background: var(--input-bg); color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--orange); }
/* Kill the browser autofill styling (yellow background + different font) */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--ink);
  caret-color: var(--ink);
  -webkit-box-shadow: 0 0 0 1000px var(--input-bg) inset;
  box-shadow: 0 0 0 1000px var(--input-bg) inset;
  transition: background-color 99999s ease-in-out 0s;
  font: inherit !important;
}
.pw { position: relative; display: block; }
.pw input { padding-right: 84px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--muted); cursor: pointer; font: inherit; padding: 4px 8px;
}

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { border-bottom: 1px solid var(--border); padding: 10px; text-align: left; }
.table thead th { background: #fafafa; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table td.num, .table th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }

/* Alerts */
.alert { padding: 10px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 12px; }
.alert-error { background: #fdecea; color: var(--red); border: 1px solid #f3c3bd; }
.alert-ok { background: #eafaf0; color: #1e7d43; border: 1px solid #bce7cd; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat { padding: 16px; }
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.stat-value { font-size: 1.6rem; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
@media (max-width: 720px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }

/* Section heading with a control on the right */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 22px 0 8px; }
.section-head h2 { margin: 0; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); cursor: pointer; }
.toggle input { width: auto; }
.warn { color: var(--coral); }
code { background: rgba(0,0,0,.05); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

/* Grid-based editable table (coupons) — keeps controls aligned under the headers */
.editgrid { min-width: 820px; }
.eg-head, .eg-row { display: grid; grid-template-columns: 1.3fr .8fr 2.2fr 1.1fr .9fr .8fr; gap: 12px; align-items: center; padding: 10px 14px; margin: 0; }
.eg-head { background: rgba(0,0,0,.03); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
:root[data-theme="dark"] .eg-head { background: rgba(255,255,255,.05); }
.eg-row { border-top: 1px solid var(--border); }
.eg-row select, .eg-row input[type="number"] { width: 100%; }
.eg-head .right, .eg-row .right { text-align: right; }

/* Confirmation modal */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(0,0,0,.45); backdrop-filter: blur(2px);
  animation: modal-fade .15s ease;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 22px 24px; width: 100%; max-width: 420px;
  box-shadow: 0 18px 50px rgba(0,0,0,.28); animation: modal-pop .16s ease;
}
.modal-title { margin: 0 0 8px; font-size: 1.15rem; }
.modal-msg { margin: 0 0 16px; color: var(--muted); line-height: 1.55; }
.modal-msg[hidden] { display: none; }
.modal-input { margin: 0 0 18px; }
.modal-input[hidden] { display: none; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-pop { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }

/* Sortable table / grid headers */
.sort-th { cursor: pointer; user-select: none; white-space: nowrap; }
.sort-th::after { content: "\2195"; opacity: .3; margin-left: 6px; font-size: 11px; }
.sort-th[data-sort-dir="asc"]::after { content: "\2191"; opacity: 1; }
.sort-th[data-sort-dir="desc"]::after { content: "\2193"; opacity: 1; }

/* Inline row forms (editable table rows) — bottom-align so labelled and unlabelled fields line up */
.row-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.row-form > label { display: inline-flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 2px; }
.row-form input, .row-form select { width: auto; }
.inline-check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.inline-check input { width: auto; }
.adv-row td { background: #fafafa; }
small.muted { font-size: 12px; }

/* Invoices */
.inv-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.inv-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; width: 260px; max-width: 100%; }
.inv-actions form { margin: 0; }
.inv-actions .row-form { flex-direction: column; align-items: stretch; gap: 8px; }
.inv-actions .btn { width: 100%; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 6px; font-weight: 500; }
.badge-pending { background: #fdf3d7; color: #8a5a00; }
.badge-approved { background: #e7f6ec; color: #1e7d43; }
.badge-rejected { background: #fdecea; color: #c0392b; }
.badge-paid { background: rgba(0,0,0,.08); color: var(--muted); }
:root[data-theme="dark"] .badge-pending { background: #3a2c12; color: #f6c67a; }
:root[data-theme="dark"] .badge-approved { background: #16301f; color: #9fe0b8; }
:root[data-theme="dark"] .badge-rejected { background: #3a1c17; color: #f0a99f; }
:root[data-theme="dark"] .badge-paid { background: rgba(255,255,255,.1); }

/* Login */
.login-wrap { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; }
.login-card { width: 100%; max-width: 380px; }
.login-card.wide { max-width: 460px; }
.login-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.login-logo { height: 34px; }
.login-alt { text-align: center; font-size: 14px; margin: 0; }
.info-h { font-size: 1.05rem; margin: 18px 0 6px; }
.info-list { margin: 6px 0 2px; padding-left: 20px; line-height: 1.6; }
.info-list li { margin: 4px 0; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.btn-row .btn { flex: 1; min-width: 130px; }
