
/* =============================================================
   Pro Styles — Stocks & Repas
   Enterprise-grade UI: neutral palette, high contrast,
   crisp typography, accessible controls, and subtle motion.
   Supports light/dark via :root[data-theme].
   ============================================================= */

/* ---------- Typography & Rhythm ---------- */
:root {
  --font-sans: Inter, "SF Pro Text", -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Noto Sans", sans-serif;

  /* Layout */
  --container: 1200px;
  --radius: 12px;
  --radius-sm: 8px;
  --gap: 16px;
  --gap-lg: 24px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .08);
  --shadow-elev: 0 14px 38px rgba(0,0,0,.12);

  /* Light (default) */
  --bg: #f7f8fc;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f2f4fb;

  --text: #1f2430;
  --muted: #5c6475;
  --border: #e3e7f1;
  --divider: #e9edf6;

  --primary: #2e5bff;
  --primary-600: #2548cc;
  --primary-50: #eef2ff;

  --success: #0ea66d;
  --success-50: #e8fbf3;
  --warning: #b48300;
  --warning-50: #fff6e4;
  --danger: #c03535;
  --danger-50: #ffecec;

  /* Inputs: professional contrast */
  --input-bg: #ffffff;
  --input-text: #0b1020;
  --input-placeholder: #7c8598;
  --input-border: #cfd6e6;
  --input-focus: #2e5bff;

  --chip: #eef2ff;
}

:root[data-theme="dark"] {
  --bg: #0f1217;
  --bg-elev: #11151c;
  --surface: #151a22;
  --surface-2: #1a202a;

  --text: #e9ecf4;
  --muted: #aab2c3;
  --border: #283041;
  --divider: #222b3a;

  --primary: #79a1ff;
  --primary-600: #6285dd;
  --primary-50: #1d2432;

  --success: #44d18d;
  --success-50: #142019;
  --warning: #ffd166;
  --warning-50: #2a2413;
  --danger: #ff6b6b;
  --danger-50: #281616;

  --input-bg: #ffffff;        /* Always light inputs for legibility */
  --input-text: #0b1020;
  --input-placeholder: #6d7689;
  --input-border: #cfd6e6;
  --input-focus: #79a1ff;

  --chip: #20283a;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Containers ---------- */
header, main, footer { max-width: var(--container); margin: 0 auto; padding: 0 var(--gap); }
main { padding-top: var(--gap-lg); padding-bottom: calc(var(--gap-lg) + 20px); }

/* ---------- Header / Top Nav ---------- */
header {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--divider);
  box-shadow: var(--shadow);
  border-radius: 0 0 var(--radius) var(--radius);
}
.brand { font-weight: 700; letter-spacing: .2px; }
nav a {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px; margin-right: 6px;
  border-radius: var(--radius-sm);
  color: var(--text);
}
nav a:hover { background: var(--surface-2); text-decoration: none; }

/* Theme toggle alignment */
.theme-toggle { margin-left: 12px; }
#theme-switch { height: 36px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gap-lg);
  box-shadow: var(--shadow);
  margin-bottom: var(--gap-lg);
}
.card h1, .card h2, .card h3 { margin: 0 0 8px; }
.card h2 { font-size: 1.125rem; letter-spacing: .15px; }
.card h3 { font-size: 1rem; color: var(--muted); }

/* ---------- Grid ---------- */
.row { display: flex; flex-wrap: wrap; gap: var(--gap); }
.col { flex: 1 1 320px; min-width: 260px; }

/* ---------- Forms ---------- */
label { display: block; margin: 10px 0 6px; color: var(--muted); font-weight: 600; font-size: .92rem; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--input-text);
  border: 1px solid var(--input-border);
  outline: none;
  transition: box-shadow .15s ease, border-color .15s ease, transform .05s ease;
  box-shadow: inset 0 1px 1px rgba(0,0,0,.03);
  font-size: 15px;
}

textarea { min-height: 120px; resize: vertical; }

input::placeholder, textarea::placeholder { color: var(--input-placeholder); opacity: 1; }

input:focus, select:focus, textarea:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--input-focus) 30%, transparent);
}

/* Inline help */
.form-help { margin-top: 6px; color: var(--muted); font-size: .86rem; }

/* ---------- Buttons ---------- */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 700;
  letter-spacing: .2px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: transform .06s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
}
button:hover, .btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-elev);
}
button:active, .btn:active { transform: translateY(0); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #222; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%; border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.table th, .table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { background: var(--surface-2); text-align: left; color: var(--muted); font-weight: 700; letter-spacing: .2px; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.table tr:last-child td { border-bottom: none; }

/* Numeric alignment */
.table td[data-num] { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700;
  background: var(--chip); color: var(--text);
  border: 1px solid var(--border);
}

.tag-red    { background: var(--danger-50); color: var(--danger); }
.tag-yellow { background: var(--warning-50); color: #7a5b00; }
.tag-green  { background: var(--success-50); color: #0b6d45; }

/* ---------- Alerts ---------- */
.alert {
  padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border);
  margin: 10px 0; background: var(--surface-2);
}
.alert.error   { background: var(--danger-50);  color: var(--danger);  border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.alert.success { background: var(--success-50); color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, var(--border)); }

/* ---------- Utilities ---------- */
.hr { height: 1px; background: var(--divider); border: 0; margin: 16px 0; }
.no-print { /* hidden on print */ }
.mono { font-family: ui-monospace, Menlo, Monaco, Consolas, "Liberation Mono", monospace; }

/* ---------- Focus visible ---------- */
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 8px; }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .card, header, footer { animation: fade-slide .18s ease-out; }
  @keyframes fade-slide { from { opacity: .0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
}

/* ---------- Print ---------- */
@media print {
  header, nav, .no-print { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .card { border: 1px solid #ccc; box-shadow: none; }
  .table th, .table td { border-color: #ccc; }
}
