/* ============================================
   HATLOCK HOLMES - Fitted Hat Deal Aggregator
   Detective-themed design system
   ============================================ */

:root {
  --brown-900: #1a0f09;
  --brown-800: #2c1810;
  --brown-700: #3d2317;
  --brown-600: #5a3825;
  --gold-500: #d4a853;
  --gold-400: #e4bf6a;
  --gold-300: #f0d48a;
  --cream-100: #faf6ee;
  --cream-200: #f5f0e8;
  --cream-300: #ebe4d4;
  --white: #ffffff;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --red-600: #dc2626;
  --red-700: #b91c1c;
  --green-600: #16a34a;
  --green-700: #15803d;
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--cream-100);
  color: var(--gray-700);
  line-height: 1.6;
}

/* ---- HEADER ---- */
.site-header {
  background: linear-gradient(135deg, var(--brown-800), var(--brown-700));
  color: var(--cream-100);
  padding: 0;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.logo-icon {
  font-size: 2.8em;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.logo-text h1 {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.6em;
  color: var(--gold-400);
  letter-spacing: 1px;
  line-height: 1.1;
}

.logo-text .tagline {
  font-size: 0.75em;
  color: var(--cream-300);
  font-style: italic;
  opacity: 0.85;
}

.header-nav {
  display: flex;
  gap: 16px;
  align-items: center;
}

.header-nav a {
  color: var(--cream-300);
  text-decoration: none;
  font-size: 0.9em;
  padding: 6px 14px;
  border-radius: 6px;
  transition: all 0.2s;
}

.header-nav a:hover {
  background: rgba(255,255,255,0.1);
  color: var(--gold-400);
}

.header-nav a.active {
  background: var(--gold-500);
  color: var(--brown-900);
  font-weight: 600;
}

/* ---- STATS BAR ---- */
.stats-bar {
  background: var(--brown-900);
  padding: 8px 24px;
  text-align: center;
  font-size: 0.85em;
  color: var(--gold-300);
}

.stats-bar span {
  margin: 0 12px;
}

.stats-bar .count {
  font-weight: 700;
  color: var(--gold-400);
}

/* ---- PRICE DISCLAIMER ---- */
.price-disclaimer {
  background: #fef3c7;
  border-bottom: 1px solid #f59e0b;
  padding: 8px 24px;
  text-align: center;
  font-size: 0.78em;
  color: #92400e;
  line-height: 1.4;
}

/* ---- FILTER BAR ---- */
.filter-section {
  background: var(--white);
  border-bottom: 2px solid var(--cream-300);
  padding: 16px 24px;
  position: sticky;
  top: 64px;
  z-index: 90;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.filter-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group label {
  font-size: 0.8em;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--gray-500);
  letter-spacing: 0.5px;
}

.league-filters {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.league-btn {
  padding: 6px 14px;
  border: 2px solid var(--cream-300);
  background: var(--white);
  border-radius: 20px;
  font-size: 0.82em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--gray-700);
}

.league-btn:hover {
  border-color: var(--gold-500);
  color: var(--brown-700);
}

.league-btn.active {
  background: var(--brown-700);
  color: var(--gold-400);
  border-color: var(--brown-700);
}

.size-select,
.store-select {
  padding: 8px 14px;
  border: 2px solid var(--cream-300);
  border-radius: 8px;
  font-size: 0.85em;
  background: var(--white);
  color: var(--gray-700);
  cursor: pointer;
  min-width: 120px;
}

.store-select {
  min-width: 180px;
}

.size-select:focus,
.store-select:focus {
  outline: none;
  border-color: var(--gold-500);
}

.price-range {
  display: flex;
  align-items: center;
  gap: 4px;
}

.price-range-symbol {
  font-size: 0.85em;
  color: var(--gray-500);
  font-weight: 600;
}

.price-range-input {
  width: 60px;
  padding: 8px 8px;
  border: 2px solid var(--cream-300);
  border-radius: 8px;
  font-size: 0.85em;
  background: var(--white);
  color: var(--gray-700);
  text-align: center;
}

.price-range-input:focus {
  outline: none;
  border-color: var(--gold-500);
}

.price-range-input::placeholder {
  color: var(--gray-500);
}

.price-range-dash {
  font-size: 0.9em;
  color: var(--gray-500);
}

.price-range-go {
  padding: 8px 12px;
  border: 2px solid var(--brown-700);
  background: var(--brown-700);
  color: var(--gold-400);
  border-radius: 8px;
  font-size: 0.82em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.price-range-go:hover {
  background: var(--brown-800);
  border-color: var(--brown-800);
}

.search-box {
  padding: 8px 14px;
  border: 2px solid var(--cream-300);
  border-radius: 8px;
  font-size: 0.85em;
  background: var(--white);
  color: var(--gray-700);
  min-width: 200px;
  flex-grow: 1;
  max-width: 320px;
}

.search-box:focus {
  outline: none;
  border-color: var(--gold-500);
}

.search-box::placeholder {
  color: var(--gray-500);
}

.results-count {
  font-size: 0.85em;
  color: var(--gray-500);
  margin-left: auto;
}

.results-count .count {
  font-weight: 700;
  color: var(--brown-700);
}

/* ---- MAIN CONTENT ---- */
.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

/* ---- HAT GRID ---- */
.hat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

/* ---- HAT CARD ---- */
.hat-card {
  background: var(--white);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--cream-300);
}

.hat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.hat-card-image {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--cream-200);
}

.hat-card-image a {
  display: block;
  width: 100%;
  height: 100%;
}

.hat-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.hat-card:hover .hat-card-image img {
  transform: scale(1.05);
}

.hat-card-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--brown-700);
  color: var(--gold-400);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.72em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hat-card-league {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,0.7);
  color: var(--white);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.7em;
  font-weight: 700;
}

.hat-card-sale-tag {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: var(--red-600);
  color: var(--white);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75em;
  font-weight: 700;
}

.hat-card-body {
  padding: 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.hat-card-name {
  font-size: 0.9em;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 8px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hat-card-name a {
  color: inherit;
  text-decoration: none;
}

.hat-card-name a:hover {
  color: var(--brown-600);
}

.hat-card-sizes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}

.size-tag {
  background: var(--cream-200);
  color: var(--gray-700);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.7em;
  font-weight: 600;
}

.hat-card-pricing {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--cream-200);
  padding: 10px 14px;
  margin: 10px -14px -14px -14px;
  border-top: 2px solid var(--cream-300);
}

.sale-price {
  font-size: 1.4em;
  font-weight: 800;
  color: var(--red-700);
}

.original-price {
  font-size: 0.95em;
  color: var(--gray-500);
  text-decoration: line-through;
}

.savings-pct {
  font-size: 0.8em;
  font-weight: 700;
  color: var(--green-600);
  background: #dcfce7;
  padding: 3px 8px;
  border-radius: 4px;
}

/* ---- NO RESULTS ---- */
.no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-500);
}

.no-results .icon {
  font-size: 3em;
  margin-bottom: 16px;
}

.no-results h3 {
  font-size: 1.2em;
  margin-bottom: 8px;
  color: var(--gray-700);
}

/* ---- LOADING / SENTINEL ---- */
.sentinel {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-500);
  font-size: 0.9em;
}

.sentinel .spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 3px solid var(--cream-300);
  border-top-color: var(--gold-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 8px;
}

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

/* ---- FOOTER ---- */
.site-footer {
  background: var(--brown-800);
  color: var(--cream-300);
  padding: 30px 24px;
  margin-top: 40px;
}

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

.footer-brand {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.1em;
  color: var(--gold-400);
}

.footer-links a {
  color: var(--cream-300);
  text-decoration: none;
  margin-left: 20px;
  font-size: 0.85em;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--gold-400);
}

.footer-disclaimer {
  width: 100%;
  text-align: center;
  font-size: 0.8em;
  opacity: 0.7;
  margin-top: 12px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

/* ---- ADMIN PAGE ---- */
.admin-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px;
}

.admin-section {
  background: var(--white);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  border: 1px solid var(--cream-300);
}

.admin-section h2 {
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--brown-700);
  margin-bottom: 16px;
  font-size: 1.3em;
}

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

.store-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--cream-200);
  font-size: 0.8em;
  text-transform: uppercase;
  color: var(--gray-500);
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--cream-300);
}

.store-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--cream-300);
  font-size: 0.9em;
}

.store-table tr:hover {
  background: var(--cream-100);
}

.store-table .url-cell {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.store-table .url-cell a {
  color: var(--brown-600);
  text-decoration: none;
}

.store-table .url-cell a:hover {
  text-decoration: underline;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  display: inline-block;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--cream-300);
  border-radius: 24px;
  transition: 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: var(--white);
  border-radius: 50%;
  transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--green-600);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.admin-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.9em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.admin-btn-primary {
  background: var(--brown-700);
  color: var(--gold-400);
}

.admin-btn-primary:hover {
  background: var(--brown-800);
}

.admin-btn-danger {
  background: var(--red-600);
  color: var(--white);
  font-size: 0.8em;
  padding: 6px 12px;
}

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

.admin-btn-success {
  background: var(--green-600);
  color: var(--white);
}

.admin-btn-success:hover {
  background: var(--green-700);
}

.admin-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.add-store-form {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 12px;
  align-items: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 2px solid var(--cream-300);
}

.add-store-form label {
  font-weight: 600;
  font-size: 0.85em;
  color: var(--gray-700);
}

.add-store-form input {
  padding: 8px 12px;
  border: 2px solid var(--cream-300);
  border-radius: 8px;
  font-size: 0.9em;
}

.add-store-form input:focus {
  outline: none;
  border-color: var(--gold-500);
}

.json-output {
  background: var(--brown-900);
  color: var(--gold-300);
  padding: 16px;
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 0.82em;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--green-600);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9em;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 200;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    text-align: center;
    gap: 8px;
    padding: 12px 16px;
  }

  .logo-text h1 {
    font-size: 1.3em;
  }

  .filter-section {
    top: auto;
    position: relative;
  }

  .filter-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .league-filters {
    justify-content: center;
  }

  .size-select,
  .store-select,
  .search-box {
    width: 100%;
    max-width: 100%;
  }

  .price-range {
    width: 100%;
    justify-content: center;
  }

  .price-range-input {
    flex: 1;
    max-width: 100px;
  }

  .results-count {
    margin-left: 0;
    text-align: center;
  }

  .hat-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
  }

  .footer-links a {
    margin: 0 10px;
  }

  .add-store-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .hat-grid {
    grid-template-columns: 1fr;
  }

  .league-btn {
    padding: 5px 10px;
    font-size: 0.75em;
  }
}
