/* app.css — GWP.RMC v2 Shared Components */

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

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--ff-body);
  background: var(--bg);
  color: var(--text-2);
  line-height: 1.55;
  min-height: 100vh;
}

/* ── Layout ───────────────────────────────────────── */
.app-wrap { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--sb-bg);
  border-right: 1px solid var(--sb-border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.main-col {
  margin-left: 220px;
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 100vh;
}

.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  backdrop-filter: blur(10px);
  height: 52px;
  display: flex; align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
}

.topbar-title {
  font-family: var(--ff-head);
  font-size: 1.1rem; font-weight: 600;
  color: var(--text-1);
  letter-spacing: .02em;
  flex: 1;
}

.page-body { padding: 1.75rem 1.5rem; flex: 1; }

/* ── Sidebar internals ────────────────────────────── */
.sb-logo {
  display: flex; align-items: center; gap: .6rem;
  padding: 1.1rem 1.1rem .8rem;
  border-bottom: 1px solid var(--sb-border);
  text-decoration: none;
}

.sb-logo-mark {
  font-family: var(--ff-head);
  font-size: 1.35rem; font-weight: 700;
  color: var(--sb-logo);
  letter-spacing: .03em;
}

.sb-logo-dot { color: var(--sb-logo-dot); }

.sb-logo-sub {
  font-size: .65rem; color: var(--sb-text);
  letter-spacing: .06em; text-transform: uppercase;
}

.sb-nav { flex: 1; padding: .6rem 0; overflow-y: auto; }

.sb-section {
  font-size: .6rem; font-weight: 700;
  color: var(--text-4); letter-spacing: .12em;
  text-transform: uppercase;
  padding: .9rem 1.1rem .3rem;
}

.sb-link {
  display: flex; align-items: center; gap: .6rem;
  padding: .52rem 1.1rem;
  color: var(--sb-text);
  text-decoration: none;
  font-size: .82rem;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s;
}

.sb-link:hover {
  background: var(--sb-act-bg);
  color: var(--text-1);
}

.sb-link.active {
  color: var(--sb-active);
  border-left-color: var(--sb-active);
  background: var(--sb-act-bg);
  font-weight: 600;
}

.sb-link i { font-size: 1rem; opacity: .85; }

.sb-footer {
  padding: .75rem 1rem;
  border-top: 1px solid var(--sb-border);
  font-size: .75rem; color: var(--sb-text);
}

.sb-avatar {
  display: flex; align-items: center; gap: .55rem;
  text-decoration: none;
  padding: .35rem .5rem; border-radius: 6px;
}

.sb-avatar:hover { background: var(--sb-act-bg); }

.avatar-circle {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: .75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sb-user-name { color: var(--text-1); font-weight: 600; font-size: .8rem; }
.sb-user-role { font-size: .68rem; color: var(--text-3); }
.admin-badge {
  font-size: .58rem; font-weight: 700; letter-spacing: .07em;
  background: var(--amber); color: #000;
  padding: .1rem .35rem; border-radius: 3px;
  text-transform: uppercase;
}

/* ── Cards ────────────────────────────────────────── */
.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}

.card-title {
  font-family: var(--ff-head);
  font-size: 1rem; font-weight: 600;
  color: var(--text-1); letter-spacing: .02em;
}

.stat-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
}

.stat-label {
  font-size: .7rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-3);
  margin-bottom: .3rem;
}

.stat-value {
  font-family: var(--ff-mono);
  font-size: 1.6rem; font-weight: 600;
  color: var(--text-1);
}

.stat-sub { font-size: .72rem; color: var(--text-3); margin-top: .15rem; }

/* ── Grid helpers ─────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }

@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main-col { margin-left: 0; }
}

/* ── Buttons ──────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .46rem .95rem;
  border-radius: 6px; border: none;
  font-family: var(--ff-body); font-size: .82rem; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: background .15s, opacity .15s, box-shadow .15s;
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent); color: var(--accent-text);
}
.btn-primary:hover { background: var(--accent-d); }

.btn-ghost {
  background: transparent; color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-1); }

.btn-danger {
  background: var(--red-bg); color: var(--red);
  border: 1px solid var(--red);
}
.btn-danger:hover { background: var(--red); color: #fff; }

.btn-sm { padding: .3rem .65rem; font-size: .76rem; }
.btn-lg { padding: .65rem 1.4rem; font-size: .9rem; }

.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ── Forms ────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }

label, .form-label {
  display: block;
  font-size: .75rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: .35rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select, textarea {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 6px;
  color: var(--input-text);
  font-family: var(--ff-body); font-size: .85rem;
  padding: .52rem .75rem;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}

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

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238aaec6' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  padding-right: 2rem;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-hint { font-size: .72rem; color: var(--text-3); margin-top: .25rem; }
.form-error { font-size: .78rem; color: var(--red); margin-top: .25rem; }

/* ── Tables ───────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; border-radius: 8px; border: 1px solid var(--border); }

table { width: 100%; border-collapse: collapse; }

thead th {
  background: var(--bg-alt);
  font-size: .68rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-3);
  padding: .6rem .85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }

tbody td {
  padding: .65rem .85rem;
  font-size: .82rem; color: var(--text-2);
}

.td-mono { font-family: var(--ff-mono); }
.td-hl { color: var(--text-1); font-weight: 600; }
.td-dim { color: var(--text-3); font-size: .76rem; }

/* ── Badges / Pills ───────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: .15rem .5rem; border-radius: 20px;
  font-size: .68rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase;
}

.badge-accent { background: var(--accent-bg); color: var(--accent); }
.badge-amber  { background: rgba(245,166,35,.12); color: var(--amber); }
.badge-red    { background: var(--red-bg); color: var(--red); }
.badge-blue   { background: rgba(96,165,250,.12); color: var(--blue); }
.badge-dim    { background: var(--bg-alt); color: var(--text-3); }

/* ── GWP Rating bar ───────────────────────────────── */
.gwp-bar-wrap {
  display: flex; align-items: center; gap: .75rem;
}

.gwp-bar-track {
  flex: 1; height: 6px;
  background: var(--bg-alt); border-radius: 3px;
  overflow: hidden;
}

.gwp-bar-fill {
  height: 100%; border-radius: 3px;
  background: var(--accent);
  transition: width .4s ease;
}

.gwp-val {
  font-family: var(--ff-mono);
  font-size: .8rem; color: var(--amber);
  white-space: nowrap;
}

/* ── Alert / Toast ────────────────────────────────── */
.alert {
  padding: .75rem 1rem; border-radius: 8px;
  font-size: .83rem; margin-bottom: 1rem;
  display: flex; align-items: flex-start; gap: .6rem;
}
.alert-err  { background: var(--red-bg); color: var(--red); border: 1px solid var(--red); }
.alert-ok   { background: var(--accent-bg); color: var(--accent); border: 1px solid var(--accent); }
.alert-warn { background: rgba(245,166,35,.1); color: var(--amber); border: 1px solid var(--amber); }

.toast-stack {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  z-index: 9999; display: flex; flex-direction: column; gap: .5rem;
}

.toast {
  padding: .7rem 1rem; border-radius: 8px;
  font-size: .82rem; font-weight: 600;
  box-shadow: 0 4px 24px rgba(0,0,0,.4);
  animation: slideIn .2s ease;
  max-width: 300px;
}
.toast-ok  { background: var(--accent); color: var(--accent-text); }
.toast-err { background: var(--red); color: #fff; }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Modals ───────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: var(--modal-overlay);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
  padding: 1.5rem;
  transform: translateY(12px);
  transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem;
}
.modal-title {
  font-family: var(--ff-head);
  font-size: 1.1rem; font-weight: 700;
  color: var(--text-1); letter-spacing: .02em;
}
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-3); font-size: 1.3rem;
  padding: .2rem; line-height: 1;
  transition: color .15s;
}
.modal-close:hover { color: var(--text-1); }

/* ── Theme picker ─────────────────────────────────── */
.theme-picker-wrap { position: relative; }

.theme-picker-btn {
  display: flex; align-items: center; gap: .45rem;
  background: var(--bg-alt); border: 1px solid var(--border);
  border-radius: 6px; padding: .32rem .65rem;
  cursor: pointer; color: var(--text-2);
  font-family: var(--ff-body); font-size: .78rem;
  transition: background .15s;
}
.theme-picker-btn:hover { background: var(--bg-hover); color: var(--text-1); }

.swatch-dot {
  width: 14px; height: 14px; border-radius: 50%;
  flex-shrink: 0;
}

.theme-panel {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px; padding: .75rem;
  width: 180px; z-index: 300;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
  display: none;
}
.theme-panel.open { display: block; }

.theme-panel-title {
  font-size: .65rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: .5rem;
}

.theme-options { display: flex; flex-direction: column; gap: .3rem; }

.theme-option {
  display: flex; align-items: center; gap: .6rem;
  background: none; border: 1px solid transparent;
  border-radius: 6px; padding: .35rem .5rem;
  cursor: pointer; width: 100%;
  color: var(--text-2); font-size: .8rem;
  transition: background .12s;
}
.theme-option:hover { background: var(--bg-hover); color: var(--text-1); }
.theme-option.active { border-color: var(--accent); color: var(--accent); }
.t-swatch { width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; }

/* ── Empty state ──────────────────────────────────── */
.empty-state {
  text-align: center; padding: 3rem 1rem;
  color: var(--text-3);
}
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: .75rem; opacity: .5; }
.empty-state p { font-size: .88rem; margin-bottom: 1rem; }

/* ── Utility ──────────────────────────────────────── */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-accent { color: var(--accent); }
.text-red { color: var(--red); }
.text-amber { color: var(--amber); }
.text-dim { color: var(--text-3); }
.text-mono { font-family: var(--ff-mono); }
.text-sm { font-size: .8rem; }
.fw-600 { font-weight: 600; }
.w-100 { width: 100%; }
