/* ============================================================
   EPL Parts Database — Custom Styles
   ============================================================ */

:root {
  --brand-color: #1a5276;
  --brand-light: #2e86c1;
  --success: #1e8449;
  --warning: #b7950b;
  --danger: #922b21;
  --muted: #6c757d;
  --border: #dee2e6;
  --radius: 6px;
}

/* ---- NAV ---- */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--brand-color);
  padding: 0.5rem 1.5rem;
  border-bottom: 2px solid var(--brand-light);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.top-nav ul { margin: 0; padding: 0; list-style: none; display: flex; align-items: center; gap: 1rem; }
.top-nav .nav-center { flex: 1; justify-content: center; }

.brand-link { color: #fff !important; font-size: 1.1rem; font-weight: 700; text-decoration: none; }
.top-nav a { color: rgba(255,255,255,0.85); text-decoration: none; font-size: 0.9rem; }
.top-nav a:hover { color: #fff; }

/* ---- SEARCH ---- */
.search-wrapper { position: relative; display: flex; align-items: center; }
.search-wrapper input[type="search"] {
  width: 340px; margin: 0;
  padding: 0.4rem 0.75rem; font-size: 0.9rem;
  border-radius: var(--radius); border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.15); color: #fff;
}
.search-wrapper input::placeholder { color: rgba(255,255,255,0.6); }
.search-wrapper input:focus { background: rgba(255,255,255,0.25); outline: none; }

.search-spinner { color: #fff; margin-left: 0.5rem; }

.small-btn { padding: 0.25rem 0.6rem !important; font-size: 0.8rem !important; }

/* ---- LIVE SEARCH DROPDOWN ---- */
.live-results-dropdown {
  position: absolute; top: 52px; left: 0; right: 0; z-index: 200;
  pointer-events: none;
}
.live-results-inner {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  max-width: 600px; margin: 0 auto; pointer-events: all;
  overflow: hidden;
}
.live-section { border-bottom: 1px solid var(--border); }
.live-section:last-child { border-bottom: none; }
.live-section-label { padding: 0.4rem 1rem; font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted);
  background: #f8f9fa; }
.live-result {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1rem;
  text-decoration: none; color: inherit; border-bottom: 1px solid #f0f0f0;
}
.live-result:hover { background: #f0f4f8; }
.live-result-brand { font-size: 0.78rem; color: var(--muted); min-width: 80px; }
.live-result-title { font-weight: 600; }
.live-result-meta { font-size: 0.78rem; color: var(--muted); margin-left: auto; }
.live-results-footer { padding: 0.5rem 1rem; font-size: 0.85rem; }
.live-results-footer a { color: var(--brand-light); }
.live-no-results { padding: 0.75rem 1rem; color: var(--muted); }
.live-add-actions { padding: 0.5rem 1rem; display: flex; gap: 1rem; }
.live-add-actions a { font-size: 0.85rem; color: var(--brand-light); }

/* ---- HOME PAGE ---- */
.home-hero { text-align: center; padding: 3rem 0 2rem; }
.home-hero h2 { font-size: 1.8rem; margin-bottom: 0.5rem; }
.home-subtitle { color: var(--muted); margin-bottom: 1.5rem; }
.home-search { max-width: 560px; margin: 0 auto; }
.home-search-input { font-size: 1.1rem !important; padding: 0.75rem 1rem !important; }
.home-results { background: #fff; border-radius: var(--radius); box-shadow: 0 2px 8px rgba(0,0,0,0.1); }

.stats-row { text-align: center; color: var(--muted); font-size: 0.9rem; margin: 1rem 0 2rem;
  display: flex; justify-content: center; gap: 0.5rem; flex-wrap: wrap; }

.brands-section h3 { margin-bottom: 1rem; }
.brand-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.75rem; }
.brand-tile {
  display: flex; flex-direction: column; gap: 0.2rem;
  padding: 1rem; background: #f8f9fa; border: 1px solid var(--border);
  border-radius: var(--radius); text-decoration: none; color: inherit;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.brand-tile:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); border-color: var(--brand-light); }
.brand-tile small { color: var(--muted); font-size: 0.8rem; }
.brand-tile--all { background: #fff; border-style: dashed; color: var(--brand-light); }

.quick-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.75rem; margin-top: 2rem; }
.quick-link-card {
  display: flex; flex-direction: column; gap: 0.3rem;
  padding: 1.25rem; background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); text-decoration: none; color: inherit;
  transition: box-shadow 0.15s;
}
.quick-link-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.quick-link-card small { color: var(--muted); font-size: 0.8rem; }

/* ---- LOGIN ---- */
.login-container { display: flex; justify-content: center; align-items: center; min-height: 80vh; }
.login-card { max-width: 400px; width: 100%; padding: 2rem; }
.resend-link { margin-top: 1rem; text-align: center; font-size: 0.9rem; }

/* ---- DETAIL PAGES ---- */
.detail-header { display: flex; justify-content: space-between; align-items: flex-start;
  padding: 1.5rem 0 1rem; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; }
.detail-header-right { display: flex; gap: 0.5rem; flex-shrink: 0; align-items: center; }
.detail-header-right a[role=button], .detail-header-right button { width: auto; white-space: nowrap; margin: 0; }
.detail-badge { font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--brand-light); margin-bottom: 0.25rem; }
.detail-badge a { color: inherit; text-decoration: none; }
.detail-badge a:hover { text-decoration: underline; }
h1 { margin: 0; font-size: 1.8rem; }
.detail-subtitle { color: var(--muted); margin: 0.25rem 0 0; font-size: 1rem; }
.detail-category { font-size: 0.85rem; color: var(--muted); margin-top: 0.25rem; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 768px) { .detail-grid { grid-template-columns: 1fr; } }

.detail-section { background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; margin-bottom: 1rem; }
.detail-section h3 { font-size: 0.85rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); margin: 0 0 0.75rem; }

.spec-row { display: flex; justify-content: space-between; align-items: baseline;
  padding: 0.35rem 0; border-bottom: 1px solid #f0f0f0; font-size: 0.9rem; }
.spec-row:last-child { border-bottom: none; }
.spec-row span { color: var(--muted); }
.spec-row strong { text-align: right; }

.description-text { font-size: 0.9rem; color: #333; line-height: 1.5; }
.sourcing-notes { font-size: 0.85rem; color: #555; margin-top: 0.5rem; font-style: italic; }
.contact-link { margin-left: 0.4rem; font-size: 0.85rem; }

/* Competitor equivalents */
.equiv-row { padding: 0.5rem 0; border-bottom: 1px solid #f0f0f0; }
.equiv-row:last-of-type { border-bottom: none; }
.equiv-link { display: flex; gap: 0.5rem; align-items: center; text-decoration: none; color: inherit; }
.equiv-link:hover .equiv-part { text-decoration: underline; }
.equiv-brand { font-size: 0.78rem; color: var(--muted); min-width: 80px; }
.equiv-part { font-weight: 600; color: var(--brand-light); }
.equiv-models { margin-top: 0.25rem; display: flex; flex-wrap: wrap; gap: 0.25rem; }
.add-link { font-size: 0.85rem; color: var(--brand-light); display: inline-block; margin-top: 0.5rem; }

/* Model tags */
.model-tag { display: inline-block; padding: 0.15rem 0.4rem; background: #e8f4f8;
  border-radius: 3px; font-size: 0.78rem; color: var(--brand-color); }
.model-tag--link { text-decoration: none; }
.model-tag--link:hover { background: var(--brand-light); color: #fff; }
.model-tags-large { display: flex; flex-wrap: wrap; gap: 0.4rem; }

/* Used-in & BOM */
.used-in-row, .bom-row { display: flex; align-items: center; gap: 0.5rem;
  padding: 0.3rem 0; font-size: 0.9rem; }
.role-tag { font-size: 0.75rem; padding: 0.1rem 0.35rem; background: #f0f4f8;
  border-radius: 3px; color: var(--muted); }
.bom-qty { font-weight: 700; min-width: 2rem; }
.bom-add-form { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.bom-add-form input { flex: 1; margin: 0; padding: 0.3rem 0.5rem; font-size: 0.85rem; }

/* Advance equiv badge (on competitor pages) */
.advance-equiv-badge { display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.9rem; margin-top: 0.5rem; }
.advance-equiv-link { font-weight: 700; color: var(--brand-color); font-size: 1rem; }
.no-equiv { color: var(--muted); font-style: italic; }
.no-equiv-small { color: var(--muted); font-size: 0.82rem; font-style: italic; }

/* ---- FORMS ---- */
.form-header { padding: 1.5rem 0 1rem; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; }
.form-header h2 { margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
@media (max-width: 768px) { .form-grid { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.error-message { background: #fdecea; border: 1px solid #f5c6cb; border-radius: var(--radius);
  padding: 0.75rem 1rem; margin-bottom: 1rem; color: var(--danger); }
.spec-fields-section { margin-top: 1.5rem; }
.spec-fields-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
.spec-field-wide { grid-column: span 2; }
.helper-text { font-size: 0.9rem; color: var(--muted); margin-bottom: 1rem; }

/* Type-ahead */
.typeahead-wrapper { position: relative; }
.typeahead-options {
  position: absolute; z-index: 100; background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  max-height: 220px; overflow-y: auto; width: 100%;
}
.autocomplete-option { padding: 0.5rem 0.75rem; cursor: pointer; display: flex;
  justify-content: space-between; align-items: center; }
.autocomplete-option:hover { background: #f0f4f8; }
.autocomplete-sub { font-size: 0.78rem; color: var(--muted); }
.autocomplete-empty { padding: 0.5rem 0.75rem; color: var(--muted); font-size: 0.85rem; }
.autocomplete-create { padding: 0.5rem 0.75rem; color: var(--brand-light); font-size: 0.85rem;
  cursor: pointer; border-top: 1px solid var(--border); }
.autocomplete-create:hover { background: #f0f4f8; }
.typeahead-create { margin-top: 0.25rem; font-size: 0.85rem; }
.selected-models { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.5rem; }
.selected-model-tag { display: flex; align-items: center; gap: 0.3rem; padding: 0.15rem 0.4rem;
  background: #e8f4f8; border-radius: 3px; font-size: 0.82rem; }
.remove-model { background: none; border: none; cursor: pointer; color: var(--muted);
  padding: 0; font-size: 1rem; line-height: 1; }
.remove-model:hover { color: var(--danger); }

/* ---- TABLES ---- */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 2px solid var(--border);
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.data-table td { padding: 0.5rem 0.75rem; border-bottom: 1px solid #f0f0f0; vertical-align: top; }
.data-table tr:hover td { background: #f8f9fa; }
.data-table a { color: var(--brand-light); text-decoration: none; }
.data-table a:hover { text-decoration: underline; }
.data-table small { display: block; color: var(--muted); font-size: 0.78rem; }
.empty-row { text-align: center; color: var(--muted); padding: 2rem !important; }
.specs-cell { color: var(--muted); font-size: 0.82rem; }
.model-list { display: flex; flex-wrap: wrap; gap: 0.2rem; }

.results-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.results-table th { padding: 0.5rem 0.75rem; border-bottom: 2px solid var(--border); text-align: left;
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.results-table td { padding: 0.5rem 0.75rem; border-bottom: 1px solid #f0f0f0; vertical-align: top; }
.results-table a { color: var(--brand-light); text-decoration: none; }
.results-table a:hover { text-decoration: underline; }
.results-table small { display: block; color: var(--muted); font-size: 0.78rem; }

/* ---- SEARCH RESULTS ---- */
.search-header { padding: 1rem 0 0.5rem; }
.results-section { margin: 1.5rem 0; }
.results-section h3 { font-size: 0.85rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); margin-bottom: 0.75rem; }
.results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.75rem; }
.result-card {
  display: flex; flex-direction: column; gap: 0.2rem;
  padding: 1rem; background: #f8f9fa; border: 1px solid var(--border);
  border-radius: var(--radius); text-decoration: none; color: inherit;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.result-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); border-color: var(--brand-light); }
.result-card--model .result-card-brand { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; }
.result-card-title { font-weight: 700; font-size: 1rem; color: var(--brand-color); }
.result-card-meta { font-size: 0.78rem; color: var(--muted); }
.result-card-meta--empty { color: #ccc; }
.no-results { text-align: center; padding: 3rem 0; }
.no-results-actions { display: flex; justify-content: center; gap: 1rem; margin-top: 1rem; }
.add-anyway { margin-top: 1.5rem; display: flex; align-items: center; gap: 1rem;
  color: var(--muted); font-size: 0.9rem; }
.add-anyway a { color: var(--brand-light); }

/* ---- LISTS / FILTERS ---- */
.list-header { display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 0; border-bottom: 2px solid var(--border); margin-bottom: 1rem; }
.list-header h2 { margin: 0; }
.list-header div { display: flex; gap: 0.5rem; }
.filter-bar { display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.filter-bar input, .filter-bar select { margin: 0; flex: 1; min-width: 150px; }
.result-count { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.75rem; }
.category-tag { font-size: 0.75rem; padding: 0.15rem 0.4rem; background: #f0f4f8;
  border-radius: 3px; color: var(--muted); white-space: nowrap; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 1rem; margin-top: 1.5rem; }

/* ---- LAMP FINDER ---- */
.finder-form { background: #f8f9fa; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.5rem; margin-bottom: 1.5rem; }
.finder-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.finder-fields small { color: var(--muted); font-size: 0.78rem; }
.finder-fields input, .finder-fields select { margin: 0; }
.finder-fields label { font-size: 0.85rem; font-weight: 600; }

/* ---- ADMIN ---- */
.inline-form { display: flex; gap: 0.5rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form input, .inline-form select { margin: 0; flex: 1; }
.role-tag { padding: 0.15rem 0.4rem; border-radius: 3px; font-size: 0.78rem; font-weight: 600; }
.role-admin { background: #fdecea; color: var(--danger); }
.role-editor { background: #e8f5e9; color: var(--success); }
.role-viewer { background: #f0f4f8; color: var(--muted); }
.action-tag { padding: 0.15rem 0.4rem; border-radius: 3px; font-size: 0.78rem; }
.action-create { background: #e8f5e9; color: var(--success); }
.action-update { background: #fff8e1; color: var(--warning); }
.action-delete { background: #fdecea; color: var(--danger); }
.ext-link { font-size: 0.8rem; color: var(--muted); margin-left: 0.3rem; }

/* ---- MODEL PARTS TABLE ---- */
.model-parts-table .advance-link { font-weight: 700; color: var(--brand-color); }

/* ---- BULK ACTION BAR ---- */
.bulk-bar { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0; margin-bottom: 0.5rem; }
.bulk-bar span { font-size: 0.85rem; color: var(--muted); }

/* ---- ROW ACTIONS (edit/delete buttons in tables) ---- */
.row-actions { white-space: nowrap; text-align: right; width: 1%; }
.row-actions { display: flex; justify-content: flex-end; align-items: center; gap: 0.3rem; }
.action-link {
  font-size: 0.8rem;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  text-decoration: none;
  background: none;
  cursor: pointer;
  line-height: 1;
}
.action-link:hover { color: var(--brand-color); border-color: var(--brand-color); background: none; }
.danger-link { color: #c0392b !important; }
.danger-link:hover { border-color: #c0392b !important; background: none !important; }
.new-model-tag { border-style: dashed; opacity: 0.85; }

/* ---- LINK EXISTING PARTS ---- */
.link-existing-wrapper { flex: 1; min-width: 260px; }
.link-existing-wrapper input[type=text] { width: 100%; }
.unlinked-parts-list { list-style: none; padding: 0; margin: 0.25rem 0 0; border: 1px solid var(--pico-muted-border-color); border-radius: var(--pico-border-radius); overflow: hidden; }
.unlinked-part-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.4rem 0.75rem; border-bottom: 1px solid var(--pico-muted-border-color); }
.unlinked-part-row:last-child { border-bottom: none; }
.unlinked-part-name { display: flex; flex-direction: column; gap: 0.1rem; }
.unlinked-part-name small { display: block; }
.advance-ref { color: var(--pico-primary); }

/* ---- DUPLICATE NAME WARNING ---- */
.duplicate-warning { background: #fff8e1; border: 1px solid #f9a825; border-radius: var(--pico-border-radius); padding: 0.6rem 0.85rem; margin-top: 0.35rem; font-size: 0.9rem; }
.duplicate-warning ul { margin: 0.35rem 0 0.25rem 1.1rem; padding: 0; }
.duplicate-warning li { margin-bottom: 0.15rem; }

/* ---- SORTABLE TABLE HEADERS ---- */
.sort-header { text-decoration: none; color: inherit; font-weight: 700; white-space: nowrap; }
.sort-header:hover { color: var(--pico-primary); }

/* ---- BRAND DETAIL - MODEL PARTS INLINE ---- */
.model-parts-inline { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.part-chip { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.15rem 0.5rem; border: 1px solid var(--pico-muted-border-color); border-radius: 999px; font-size: 0.82rem; text-decoration: none; color: inherit; white-space: nowrap; }
.part-chip:hover { border-color: var(--pico-primary); color: var(--pico-primary); }
.part-chip .text-muted { font-size: 0.78rem; }

/* ---- MODEL IMAGE ---- */
.model-image-block { margin-bottom: 1.5rem; }
.model-image-block img { max-width: 400px; max-height: 300px; width: 100%; height: auto; border-radius: var(--pico-border-radius); border: 1px solid var(--pico-muted-border-color); object-fit: contain; background: #f9f9f9; }
.current-image-preview { margin-bottom: 0.75rem; display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.current-image-preview img { max-width: 200px; max-height: 150px; border-radius: var(--pico-border-radius); border: 1px solid var(--pico-muted-border-color); object-fit: contain; background: #f9f9f9; }
.remove-image-label { font-size: 0.85rem; display: flex; align-items: center; gap: 0.35rem; cursor: pointer; }

/* ---- MISC ---- */
.text-muted { color: var(--muted) !important; }
.danger-zone { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border); }
main { padding-top: 1.5rem; padding-bottom: 3rem; }
