/* =========================================================
   Gattatron Computers — Inventory System Stylesheet
   Dark theme with deep orange accent
   ========================================================= */

:root {
  --bg-base:      #111113;
  --bg-surface:   #1c1c1f;
  --bg-raised:    #242428;
  --bg-hover:     #2e2e33;
  --border:       #2f2f35;
  --accent:       #3AA6B9;
  --accent-hover: #2997AA;
  --accent-muted: rgba(58, 166, 185, 0.15);
  --text-primary: #e8e8ec;
  --text-muted:   #888896;
  --text-dim:     #555566;
  --danger:       #dc2626;
  --danger-hover: #ef4444;
  --success:      #16a34a;
  --warning:      #d97706;
  --radius:       6px;
  --radius-lg:    10px;
  --font:         'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

html, body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
}

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

/* ---- NAV ---- */
nav {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  height: 90px;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-size: 17px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.5px;
  margin-right: 24px;
  white-space: nowrap;
}

.nav-brand span { color: var(--text-primary); }

nav a.nav-link {
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
}

nav a.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

nav a.nav-link.active {
  color: var(--accent);
  background: var(--accent-muted);
}

.nav-badge {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: 5px;
  vertical-align: middle;
}

/* ---- LAYOUT ---- */
.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 32px 64px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ---- CARDS ---- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ---- GRID ---- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }

/* ---- STAT TILES ---- */
.stat-tile {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-tile .stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

.stat-tile .stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.stat-tile.accent  { border-left: 3px solid var(--accent); }
.stat-tile.danger  { border-left: 3px solid var(--danger); }
.stat-tile.success { border-left: 3px solid var(--success); }
.stat-tile.warning { border-left: 3px solid var(--warning); }
.stat-tile.muted   { border-left: 3px solid var(--text-dim); }

/* ---- SECTION SPACING ---- */
.section { margin-bottom: 32px; }
.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---- TABLES ---- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  background: var(--bg-raised);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 11px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-raised); }

tbody td {
  padding: 11px 16px;
  color: var(--text-primary);
  vertical-align: middle;
}

/* ---- STATUS BADGES ---- */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-available  { background: rgba(22,163,74,0.18);  color: #4ade80; }
.badge-in-build   { background: rgba(58,166,185,0.18);  color: #3AA6B9; }
.badge-listed     { background: rgba(99,102,241,0.18);  color: #a5b4fc; }
.badge-sold       { background: rgba(100,116,139,0.18); color: #94a3b8; }
.badge-refunded   { background: rgba(234,179,8,0.18);   color: #fbbf24; }
.badge-defective  { background: rgba(220,38,38,0.18);   color: #f87171; }
.badge-used       { background: rgba(236,72,153,0.18);  color: #f9a8d4; }
.badge-planning   { background: rgba(99,102,241,0.18);  color: #a5b4fc; }

/* Search highlighting */
mark {
  background: rgba(250,204,21,0.35);
  color: #fde047;
  border-radius: 2px;
  padding: 0 1px;
}
select.status-inline.search-match {
  outline: 2px solid rgba(250,204,21,0.6);
  outline-offset: 1px;
}
.badge-in-progress{ background: rgba(58,166,185,0.18);  color: #3AA6B9; }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); color: #fff; }

.btn-secondary {
  background: var(--bg-raised);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger {
  background: rgba(220,38,38,0.15);
  color: var(--danger-hover);
  border: 1px solid rgba(220,38,38,0.3);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm {
  padding: 4px 11px;
  font-size: 12px;
}

/* ---- FORMS ---- */
.form-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  max-width: 720px;
}

.form-grid { display: grid; gap: 20px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
select,
textarea {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  padding: 9px 12px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23888896' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

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

.form-hint { font-size: 12px; color: var(--text-dim); }

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ---- FILTER BAR ---- */
.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
}

.filter-bar .form-group { flex: 1; margin: 0; }
.filter-bar label { margin-bottom: 5px; }

/* ---- ALERT PANEL ---- */
.alert-panel {
  background: rgba(220,38,38,0.08);
  border: 1px solid rgba(220,38,38,0.25);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
}

.alert-panel .alert-title {
  font-size: 13px;
  font-weight: 700;
  color: #f87171;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(220,38,38,0.12);
  font-size: 13px;
  color: var(--text-primary);
}

.alert-row:last-child { border-bottom: none; }

/* ---- WEBHOOK ALERT PANEL (orange) ---- */
.webhook-panel {
  background: var(--accent-muted);
  border: 1px solid rgba(232,93,4,0.3);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
}

.webhook-panel .webhook-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-hover);
  margin-bottom: 12px;
}

/* ---- EMPTY STATE ---- */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
}

/* ---- DETAIL META ---- */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.meta-item { display: flex; flex-direction: column; gap: 4px; }
.meta-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
.meta-value { font-size: 15px; color: var(--text-primary); font-weight: 500; }
.meta-value.large { font-size: 22px; font-weight: 700; color: var(--accent); }

/* ---- ADD-TO-BUILD ROW ---- */
.add-component-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 16px 20px;
  background: var(--bg-raised);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.add-component-row select { max-width: 420px; }

/* ---- INLINE STATUS SELECT ---- */
select.status-inline {
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 24px 3px 10px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-repeat: no-repeat;
  background-position: right 8px center;
  border: none;
  transition: opacity 0.15s;
}
select.status-inline:hover { opacity: 0.85; }
select.status-inline option { background: #1c1c1f; color: #e8e8ec; }

select.status-inline.s-available   { background-color: rgba(22,163,74,0.18);  color: #4ade80; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%234ade80' d='M1 1l4 4 4-4'/%3E%3C/svg%3E"); }
select.status-inline.s-in-build    { background-color: rgba(58,166,185,0.18);  color: #3AA6B9; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%233AA6B9' d='M1 1l4 4 4-4'/%3E%3C/svg%3E"); }
select.status-inline.s-listed      { background-color: rgba(99,102,241,0.18); color: #a5b4fc; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23a5b4fc' d='M1 1l4 4 4-4'/%3E%3C/svg%3E"); }
select.status-inline.s-sold        { background-color: rgba(100,116,139,0.18);color: #94a3b8; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2394a3b8' d='M1 1l4 4 4-4'/%3E%3C/svg%3E"); }
select.status-inline.s-in-the-mail   { background-color: rgba(14,165,233,0.18);  color: #7dd3fc; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%237dd3fc' d='M1 1l4 4 4-4'/%3E%3C/svg%3E"); }
select.status-inline.s-needs-testing { background-color: rgba(234,179,8,0.18);   color: #fde047; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23fde047' d='M1 1l4 4 4-4'/%3E%3C/svg%3E"); }
select.status-inline.s-refunded      { background-color: rgba(234,179,8,0.18);   color: #fbbf24; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23fbbf24' d='M1 1l4 4 4-4'/%3E%3C/svg%3E"); }
select.status-inline.s-defective     { background-color: rgba(220,38,38,0.18);  color: #f87171; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2020/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23f87171' d='M1 1l4 4 4-4'/%3E%3C/svg%3E"); }
select.status-inline.s-using         { background-color: rgba(234,88,12,0.18);   color: #fb923c; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23fb923c' d='M1 1l4 4 4-4'/%3E%3C/svg%3E"); }
select.status-inline.s-used          { background-color: rgba(236,72,153,0.18);  color: #f9a8d4; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23f9a8d4' d='M1 1l4 4 4-4'/%3E%3C/svg%3E"); }
select.status-inline.s-planning      { background-color: rgba(139,92,246,0.18);  color: #c4b5fd; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23c4b5fd' d='M1 1l4 4 4-4'/%3E%3C/svg%3E"); }
select.status-inline.s-in-progress   { background-color: rgba(58,166,185,0.18);  color: #3AA6B9; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%233AA6B9' d='M1 1l4 4 4-4'/%3E%3C/svg%3E"); }

/* ---- STATUS BADGE (static pill, not a select) ---- */
.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.status-badge.s-listed      { background: rgba(99,102,241,0.18);  color: #a5b4fc; }
.status-badge.s-sold        { background: rgba(100,116,139,0.18); color: #94a3b8; }
.status-badge.s-planning    { background: rgba(139,92,246,0.18);  color: #c4b5fd; }
.status-badge.s-in-progress { background: rgba(58,166,185,0.18);  color: #3AA6B9; }
.status-badge.s-refunded    { background: rgba(234,179,8,0.18);   color: #fbbf24; }

/* ---- INLINE NAME EDIT ---- */
.inline-name-form { margin: 0; }
input.inline-name-input {
  background: transparent;
  border: none;
  border-bottom: 1px dashed transparent;
  color: inherit;
  font: inherit;
  font-weight: 600;
  padding: 2px 4px;
  width: 100%;
  min-width: 120px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
input.inline-name-input:hover { border-bottom-color: var(--border); }
input.inline-name-input:focus {
  border-bottom-color: var(--accent);
  background: rgba(58,166,185,0.07);
  border-radius: 4px 4px 0 0;
}

/* ---- TABS ---- */
.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 28px;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  font-family: var(--font);
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab-btn:hover { color: var(--text-primary); }

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-count {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 7px;
}

.tab-panel { display: block; }

/* ---- MISC ---- */
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger-hover); }
.text-success { color: #4ade80; }
.monospace { font-family: 'Consolas', 'Courier New', monospace; font-size: 12.5px; }
.info-box {
  background: rgba(58,166,185,0.10);
  border: 1px solid rgba(58,166,185,0.30);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-muted);
}
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

/* ---- MODALS ---- */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop.active { display: flex; }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 20px 24px 24px; }

/* ---- SAVING OVERLAY ---- */
#saving-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}
#saving-overlay.active { display: flex; }
#saving-box {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 48px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.saving-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--bg-hover);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#saving-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}
#saving-sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* ---- BULK ACTION BAR ---- */
.bulk-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-raised);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  z-index: 200;
  flex-wrap: wrap;
  justify-content: center;
}
.bulk-bar select {
  border-radius: 6px;
  padding: 6px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 13px;
}
