/* FRANKI WOW Design — SPA Shell v2 (tokens via design_tokens.css in project frontend) */

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

/* ── App shell — viewport lock ── */
html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;
}

.sidebar-brand {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-brand .brand-name {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.5px;
}

.sidebar-brand .brand-sub {
  font-size: .7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-section-label {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-subtle);
  padding: 10px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  font-size: .82rem;
  font-weight: 500;
  transition: var(--transition);
  margin-bottom: 2px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  user-select: none;
}
.nav-item:hover {
  background: var(--card);
  color: var(--text);
}
.nav-item.active {
  background: var(--accent-light);
  color: var(--accent2);
  font-weight: 600;
}
.nav-item .nav-icon {
  width: 16px;
  height: 16px;
  opacity: .7;
  flex-shrink: 0;
}
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── Main viewport ── */
.main-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  position: relative;
}

/* ── Topbar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  height: 52px;
}

.topbar-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Content area ── */
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.content-area::-webkit-scrollbar { width: 4px; }
.content-area::-webkit-scrollbar-track { background: transparent; }
.content-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Views (SPA panels) ── */
.view {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.view.active {
  display: flex;
}

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color .18s;
  margin-bottom: 16px;
}
.card:hover { border-color: var(--border-hover); }
.card-title,
.module-title {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 16px;
  margin-top: 0;
}
.module-block:last-child { margin-bottom: 0; }

/* ── Structured module widgets (P0.2) ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: var(--radius-md);
}
.stat-label { font-size: .72rem; color: var(--text-muted); }
.stat-value { font-size: 1.4rem; font-weight: 800; color: var(--accent2); }
.data-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.data-table th,
.data-table td {
  border-bottom: 1px solid var(--border);
  padding: 8px;
  text-align: left;
}
.data-table th { color: var(--text-muted); font-size: .7rem; text-transform: uppercase; }
.stacked-form label { display: block; margin: 8px 0; font-size: .82rem; color: var(--text-muted); }
.stacked-form input,
.stacked-form select,
.stacked-form textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  margin-top: 4px;
}
.stacked-form button {
  margin-top: 10px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.board-columns-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pl-col { background: var(--surface); padding: 8px; border-radius: var(--radius-md); border: 1px solid var(--border); }
.pl-col h3 { font-size: .75rem; color: var(--text-muted); margin-bottom: 8px; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.calendar-strip .cal-row { padding: 8px; background: var(--surface); border-radius: var(--radius-sm); }
.cart-summary { padding: 8px; }
.wide { width: 100%; }
.muted { color: var(--text-muted); font-size: .9rem; }
.msg { color: var(--green); font-size: .85rem; }

/* ── KPI grid ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px,1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 16px;
}
.kpi-value {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
  color: var(--accent);
}
.kpi-value.green  { color: var(--green); }
.kpi-value.red    { color: var(--red); }
.kpi-value.yellow { color: var(--yellow); }
.kpi-label {
  font-size: .72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.kpi-sub {
  font-size: .68rem;
  color: var(--text-subtle);
  margin-top: 3px;
}

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}
thead th {
  background: var(--surface);
  padding: 10px 14px;
  text-align: left;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--card-hover); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .04em;
  white-space: nowrap;
}
.badge-green  { background: var(--green-light);  color: var(--green); }
.badge-red    { background: var(--red-light);    color: var(--red); }
.badge-yellow { background: var(--yellow-light); color: var(--yellow); }
.badge-blue   { background: var(--blue-light);   color: var(--blue); }
.badge-accent { background: var(--accent-light); color: var(--accent2); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: var(--transition);
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: .88; }
.btn-secondary {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent2); }
.btn-danger { background: var(--red-light); color: var(--red); }
.btn-sm { padding: 5px 11px; font-size: .75rem; }

/* ── Forms ── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 5px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-family: var(--font);
  outline: none;
  transition: border-color .18s;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text-subtle); }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(8px);
  transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}
.modal-close:hover { background: var(--surface); color: var(--text); }

/* ── Side panel ── */
.side-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 420px;
  background: var(--card);
  border-left: 1px solid var(--border);
  z-index: 100;
  transform: translateX(100%);
  transition: transform .25s ease;
  overflow-y: auto;
  padding: 24px;
  box-shadow: var(--shadow-lg);
}
.side-panel.open { transform: translateX(0); }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 2rem; margin-bottom: 12px; opacity: .4; }
.empty-state-title { font-size: .95rem; font-weight: 600; margin-bottom: 6px; }
.empty-state-sub { font-size: .82rem; }

/* ── Utilities ── */
.grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.grid-3 { display:grid; grid-template-columns:repeat(3,1fr); gap:16px; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-muted  { color: var(--text-muted); }
.text-accent { color: var(--accent2); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-sm     { font-size: .78rem; }
.font-bold   { font-weight: 700; }
.flex        { display: flex; }
.flex-center { display:flex; align-items:center; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }

/* ── Scrollbar global ── */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 4px; height: 4px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { width: 0; min-width: 0; overflow: hidden; }
  .sidebar.open { width: var(--sidebar-w); min-width: var(--sidebar-w); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2,1fr); }
  .board-columns-grid { grid-template-columns: 1fr; }
}
