/* ======================================================
   NCC Health Compounding Quote Tool — Styles
   ====================================================== */

:root {
  --primary: #1a5276;
  --primary-light: #2471a3;
  --primary-dark: #0e3650;
  --accent: #2ecc71;
  --accent-hover: #27ae60;
  --danger: #e74c3c;
  --danger-hover: #c0392b;
  --bg: #f0f3f6;
  --card-bg: #ffffff;
  --text: #2c3e50;
  --text-muted: #7f8c8d;
  --border: #dce1e6;
  --border-light: #ecf0f1;
  --hover-row: #f7f9fb;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --radius: 8px;
  --radius-sm: 4px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

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

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  background: var(--primary);
  color: white;
  padding: 0.8rem 1.2rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  font-size: 2rem;
  line-height: 1;
}

.logo h1 {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.logo .subtitle {
  font-size: 0.8rem;
  opacity: 0.8;
  font-weight: 400;
}

/* Navigation */
nav {
  background: var(--primary-dark);
  padding: 0;
  position: sticky;
  top: 52px;
  z-index: 99;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.nav-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  gap: 0;
}

.nav-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  padding: 0.75rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  border-bottom: 3px solid transparent;
  font-family: var(--font);
}

.nav-btn:hover {
  color: white;
  background: rgba(255,255,255,0.08);
}

.nav-btn.active {
  color: white;
  border-bottom-color: var(--accent);
  background: rgba(255,255,255,0.05);
}

/* Main */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.2rem;
  width: 100%;
  flex: 1;
}

/* Tab content */
.tab-content {
  display: none;
  animation: fadeIn 0.2s ease;
}
.tab-content.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.card h2 {
  font-size: 1.15rem;
  color: var(--primary);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border-light);
}

.card h3 {
  font-size: 0.95rem;
  color: var(--primary-light);
  margin-bottom: 0.75rem;
}

/* Search Bar */
.search-bar {
  position: relative;
  margin-bottom: 1rem;
}

.search-bar input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.8rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: var(--font);
  transition: border-color 0.2s;
  background: var(--card-bg);
}

.search-bar input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(36,113,163,0.1);
}

.search-icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  pointer-events: none;
}

.result-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--card-bg);
}

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

th {
  background: var(--primary);
  color: white;
  padding: 0.7rem 0.8rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  position: sticky;
  top: 0;
}

th.num { text-align: right; }

td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.9rem;
}

td.num { text-align: right; font-variant-numeric: tabular-nums; }

tr:hover td { background: var(--hover-row); }

tr:last-child td { border-bottom: none; }

.price-cell {
  font-weight: 600;
  color: var(--primary);
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-yes { background: #eafaf1; color: #27ae60; }
.badge-no { background: #fef5e7; color: #f39c12; }

/* Quote Builder */
.quote-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1.2rem;
  align-items: start;
}

.form-row {
  margin-bottom: 0.9rem;
  position: relative;
}

.form-row label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 0.3rem;
}

.form-row input,
.form-row select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: var(--font);
  transition: border-color 0.2s;
}

.form-row input:focus,
.form-row select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(36,113,163,0.1);
}

.separator {
  border-top: 2px solid var(--border-light);
  margin: 1.2rem 0;
}

/* Dropdown */
.dropdown-list {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 250px;
  overflow-y: auto;
  background: var(--card-bg);
  border: 2px solid var(--primary-light);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  z-index: 50;
  box-shadow: var(--shadow-lg);
}

.dropdown-list.open { display: block; }

.dropdown-item {
  padding: 0.5rem 0.7rem;
  cursor: pointer;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.1s;
}

.dropdown-item:hover,
.dropdown-item.highlighted {
  background: #eaf2f8;
  color: var(--primary);
}

.dropdown-item .cost-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  float: right;
  margin-top: 2px;
}

/* Buttons */
.btn {
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
}

.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
}

.btn-primary:hover { background: var(--primary-light); }

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover { background: var(--danger-hover); }

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.78rem;
}

/* Quote Items */
.quote-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.8rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  border-left: 3px solid var(--primary-light);
}

.quote-item-info {
  flex: 1;
  min-width: 0;
}

.quote-item-name {
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quote-item-detail {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.quote-item-cost {
  font-weight: 700;
  color: var(--primary);
  margin: 0 0.8rem;
  white-space: nowrap;
  font-size: 0.9rem;
}

.quote-item .btn-remove {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.2rem;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.quote-item .btn-remove:hover { opacity: 1; }

/* Quote Summary */
.quote-summary {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 2px solid var(--border-light);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  font-size: 0.9rem;
}

.summary-row.total {
  border-top: 2px solid var(--primary);
  margin-top: 0.5rem;
  padding-top: 0.7rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
}

.quote-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
}

.empty-state p.muted {
  font-size: 0.85rem;
  margin-top: 0.3rem;
}

.hidden { display: none !important; }

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.3s;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay p {
  margin-top: 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Footer */
footer {
  text-align: center;
  padding: 1rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border-light);
  margin-top: auto;
}

/* ======================================================
   Responsive
   ====================================================== */

@media (max-width: 900px) {
  .quote-layout {
    grid-template-columns: 1fr;
  }
  
  html { font-size: 14px; }
}

@media (max-width: 600px) {
  header { padding: 0.6rem 0.8rem; }
  .logo h1 { font-size: 1.1rem; }
  .logo .subtitle { font-size: 0.7rem; }
  .logo-icon { font-size: 1.5rem; }
  
  .nav-btn {
    padding: 0.6rem 0.8rem;
    font-size: 0.8rem;
  }
  
  main { padding: 0.8rem; }
  
  th, td { padding: 0.4rem 0.5rem; font-size: 0.8rem; }
  
  .card { padding: 1rem; }
  
  /* Make tables scroll horizontally on mobile */
  .table-wrap {
    font-size: 0.85rem;
  }
}

/* Highlight matching text */
.highlight {
  background: #fef9c3;
  border-radius: 2px;
  padding: 0 1px;
}

/* Status indicator */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}

.status-dot.green { background: var(--accent); }
.status-dot.red { background: var(--danger); }

/* Sub-tabs */
.sub-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--border);
}

.sub-tab {
  background: none;
  border: none;
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
  font-family: var(--font);
}

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

.sub-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.sub-count {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted);
}

/* Filter row */
.filter-row {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 0.8rem;
  flex-wrap: wrap;
}

.filter-check {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.filter-check input[type="checkbox"] {
  accent-color: var(--primary);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.filter-row select {
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--card-bg);
  cursor: pointer;
}

.filter-row select:focus {
  outline: none;
  border-color: var(--primary-light);
}

/* Inactive row */
.row-inactive td {
  opacity: 0.5;
}

.badge-inactive {
  background: #f5f5f5;
  color: #999;
}
