/* ============================================================
   style.css  –  App-specific overlay on top of mika_common_styles.css
   Owns:  layout column, panel + title bar, compact table tweaks,
          modal, editable cell affordances, toasts.
   ============================================================ */

/* ------------------------------------------------------------
   1. LAYOUT COLUMN — flex stack filling the Mika shell's .content
   ------------------------------------------------------------ */
html, body { height: 100%; }
body.v2 {
  overflow: hidden;
  padding: 0;
}

.layout-column {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 120rem;
  padding: 0 1rem;
  box-sizing: border-box;
}

.layout-column > .content-wrapper {
  padding: 0;
  max-width: none;
}

.layout-column > .content-wrapper.page-top {
  padding-top: 1.5rem;
  padding-bottom: 0.5rem;
  flex-shrink: 0;
}

.layout-column > .content-wrapper.panel-wrapper {
  flex: 1 1 auto;
  min-height: 0;
  padding-bottom: 2rem;   /* leaves clearance for the fixed footer */
  display: flex;
  flex-direction: column;
}

/* ------------------------------------------------------------
   2. PANEL — single unified card built with mika tokens
   ------------------------------------------------------------ */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1 1 auto;
  min-height: 0;
}

/* ---- Title bar ---- */
.panel-header {
  background: var(--bg-table-header);
  border-bottom: 1px solid var(--color-border);
  padding: 0.625rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.panel-title-group {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  min-width: 0;
}

.panel-title {
  font-family: var(--font-family);
  font-size: var(--font-size-body);
  font-weight: var(--font-weight-semi);
  color: var(--color-primary);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.panel-counts {
  font-size: var(--font-size-small);
  color: var(--color-secondary);
  display: flex;
  gap: 0.375rem;
  align-items: baseline;
  white-space: nowrap;
}
.panel-counts strong { color: var(--color-primary); font-weight: var(--font-weight-semi); }
.panel-counts .ok  strong { color: #1a7a1a; }
.panel-counts .err strong { color: #c43434; }
.panel-counts .dot { opacity: .5; }

.panel-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-wrap: wrap;
}

/* Icons inside compact buttons */
.btn .material-symbols-outlined {
  font-size: 1rem;
  line-height: 1;
}

/* ------------------------------------------------------------
   3. COMPACT TABLE — overrides on top of .data-table
   ------------------------------------------------------------ */
.lanes-scroll {
  flex: 1 1 auto;
  min-height: 12rem;
  border: none;                     /* panel already provides the border */
  border-radius: 0;
  overflow: auto;
}

/* Fixed layout: columns keep their declared widths; browser doesn't
   recalculate on every keystroke — critical for 1000+ row performance. */
.data-table { table-layout: fixed; width: 100%; }

/* Sticky header inside the scroller: rely on mika's rules, add a shadow */
.data-table thead th {
  box-shadow: inset 0 -1px 0 var(--color-border);
  font-variant-numeric: tabular-nums;
}

/* Extra-tight row padding + single-line headers for the dense table */
.data-table--compact thead th {
  padding: 0.375rem 0.375rem;
  font-size: var(--font-size-label);
  white-space: nowrap;
}
.data-table--compact tbody td {
  padding: 0.1875rem 0.375rem;
  font-size: var(--font-size-small);
  vertical-align: middle;
  line-height: 1.35;
}

/* Column-header copy icon */
.col-copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-secondary);
  padding: 0 0 0 0.2rem;
  opacity: 0.45;
  vertical-align: middle;
  display: inline-flex;
  align-items: center;
  line-height: 1;
}
.col-copy-btn:hover { opacity: 1; color: var(--color-dark); }
.col-copy-btn .material-symbols-outlined { font-size: 0.8rem; }

/* Rating in progress row tint */
.data-table tbody tr.row-rating { background: #fff8e0 !important; }

/* ── Edit Lane Modal ──────────────────────────────────────────────────── */
.modal--wide { max-width: 68rem; }

.edit-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.edit-section-label {
  font-size: var(--font-size-label);
  font-weight: var(--font-weight-semi);
  color: var(--color-secondary);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.25rem;
  margin-bottom: 0.25rem;
}

.edit-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.edit-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}
.edit-field--grow  { flex: 1 1 10rem; }
.edit-field--state { flex: 0 0 4rem; }
.edit-field--zip   { flex: 0 0 6rem; }
.edit-field--num   { flex: 0 0 8rem; }

.edit-field label {
  font-size: var(--font-size-label);
  font-weight: var(--font-weight-semi);
  color: var(--color-secondary);
}

.edit-field input,
.edit-field select {
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  font-family: var(--font-family);
  font-size: var(--font-size-body);
  color: var(--color-primary);
  background: var(--bg-card);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
  box-sizing: border-box;
}
.edit-field input:focus,
.edit-field select:focus {
  border-color: var(--color-dark);
  box-shadow: 0 0 0 2px rgba(0,0,0,0.07);
}
.edit-field select { cursor: pointer; }

/* Row checkbox size */
.data-table input[type="checkbox"] {
  width: 0.875rem;
  height: 0.875rem;
  cursor: pointer;
  accent-color: var(--color-dark);
}

/* Status pill — compact override for use inside the dense table */
.status-tag {
  min-width: 0;
  padding: 0.0625rem 0.4375rem;
  font-size: var(--font-size-label);
  border-radius: 999px;
  line-height: 1.3;
}
.status-tag--pending { background: #efeeed; color: var(--color-secondary); }
.status-tag--warning { background: #fff4ce; color: #8a6d00; }
.status-tag--error   { background: #fde7e9; color: #c43434; }

/* Empty state inside panel */
.empty-state {
  text-align: center;
  padding: 4rem 1.25rem;
  color: var(--color-secondary);
  font-size: var(--font-size-body);
}
.empty-state .material-symbols-outlined {
  font-size: 3rem;
  color: #c8c6c4;
  display: block;
  margin: 0 auto 0.5rem;
}
.empty-state p { margin: 0; }
.empty-state strong { color: var(--color-primary); font-weight: var(--font-weight-semi); }

/* ------------------------------------------------------------
   4. MODAL
   ------------------------------------------------------------ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1100;   /* above the Mika shell header (1000) */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  animation: fadeIn 0.15s ease both;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 36rem;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fadeInUp 0.18s ease both;
}

.modal-header {
  background: var(--bg-table-header);
  border-bottom: 1px solid var(--color-border);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.modal-title {
  font-weight: var(--font-weight-semi);
  font-size: var(--font-size-body);
  color: var(--color-primary);
  letter-spacing: 0.02em;
  flex: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.modal-title .material-symbols-outlined { font-size: 1.25rem; color: var(--color-secondary); }

.modal-close {
  background: transparent;
  border: none;
  color: var(--color-secondary);
  cursor: pointer;
  padding: 0.25rem 0.375rem;
  border-radius: var(--border-radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: #e5e5e5; color: var(--color-primary); }
.modal-close .material-symbols-outlined { font-size: 1.125rem; }

.modal-body { padding: 1.25rem; overflow: auto; }

/* ------------------------------------------------------------
   5. TOAST
   ------------------------------------------------------------ */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  padding: 0.625rem 1rem;
  border-radius: var(--border-radius-sm);
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-semi);
  color: #fff;
  background: var(--color-dark);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transform: translateY(0.5rem);
  transition: opacity 0.25s, transform 0.25s;
  max-width: 22rem;
}
.toast.show    { opacity: 1; transform: translateY(0); }
.toast.success { background: #1a7a1a; }
.toast.error   { background: #c43434; }
/* .toast.info uses the default background (var(--color-dark)). */

/* ------------------------------------------------------------
   6. FOOTER (mika override – smaller, tighter bottom)
   ------------------------------------------------------------ */
.footer {
  position: fixed;
  bottom: 0.5rem;
  right: 1.5rem;
  font-size: var(--font-size-small);
  color: var(--color-secondary);
  z-index: 2;
}

/* ------------------------------------------------------------
   7. UTIL
   ------------------------------------------------------------ */
.hidden { display: none !important; }

/* Responsive */
@media (max-width: 960px) {
  .panel-actions { width: 100%; margin-left: 0; }
  .layout-column { padding: 0 0.75rem; }
}
