/* =========================================================
   Wine Cellar Manager — Global Styles
   Color palette:
     Burgundy:  #6B2737
     Cream:     #FAF7F2
     Gold:      #C9A84C
     Dark text: #2C1A22
   ========================================================= */

:root {
  --burgundy:   #6B2737;
  --burgundy-dk:#4e1d28;
  --burgundy-lt:#9b3d52;
  --cream:      #FAF7F2;
  --bg-cream:   #F3EDE4;
  --gold:       #C9A84C;
  --gold-lt:    #e8c96c;
  --text-dark:  #2C1A22;
  --text-mid:   #5a4650;
  --text-light: #8a7080;
  --border:     #e0d4cc;
  --card-bg:    #ffffff;
  --shadow-sm:  0 2px 8px rgba(44, 26, 34, 0.08);
  --shadow-md:  0 4px 20px rgba(44, 26, 34, 0.12);
  --shadow-lg:  0 8px 40px rgba(44, 26, 34, 0.18);
  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --transition: 0.2s ease;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-cream);
  color: var(--text-dark);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── Typography ─────────────────────────────────────────── */
h1, h2, h3, h4 { line-height: 1.2; color: var(--burgundy); }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.375rem; font-weight: 700; }
h3 { font-size: 1.125rem; font-weight: 600; }

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

/* ─── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-cream); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── Top navigation bar ─────────────────────────────────── */
.navbar {
  background: var(--burgundy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}
.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.01em;
}
.navbar-brand .logo { font-size: 1.5rem; }
.navbar-actions { display: flex; gap: 0.5rem; }

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform 0.1s, box-shadow var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--burgundy);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--burgundy-lt); box-shadow: var(--shadow-sm); }

.btn-gold {
  background: var(--gold);
  color: var(--text-dark);
}
.btn-gold:hover:not(:disabled) { background: var(--gold-lt); }

.btn-outline {
  background: transparent;
  color: var(--burgundy);
  border: 1.5px solid var(--burgundy);
}
.btn-outline:hover:not(:disabled) { background: rgba(107, 39, 55, 0.06); }

.btn-ghost {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
}
.btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,0.25); }

.btn-danger {
  background: #c0392b;
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: #a93226; }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn-icon { padding: 0.5rem; border-radius: 50%; }

/* ─── Summary cards ──────────────────────────────────────── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
}
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--gold);
}
.stat-card .stat-value {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--burgundy);
  line-height: 1;
}
.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── Filter / search bar ────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  padding: 0.75rem 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}
.filter-bar input[type="search"],
.filter-bar select {
  padding: 0.45rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  background: #fff;
  color: var(--text-dark);
  outline: none;
  transition: border-color var(--transition);
}
.filter-bar input[type="search"]:focus,
.filter-bar select:focus { border-color: var(--burgundy); }
.filter-bar input[type="search"] { flex: 1; min-width: 160px; }
.filter-bar select { min-width: 140px; }

/* ─── Wine grid ──────────────────────────────────────────── */
.wine-grid-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 3rem;
}
.wine-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
}
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-light);
}
.empty-state .empty-icon { font-size: 4rem; margin-bottom: 1rem; }
.empty-state h3 { color: var(--text-mid); margin-bottom: 0.5rem; }

/* ─── Wine card ──────────────────────────────────────────── */
.wine-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
  cursor: pointer;
  position: relative;
}
.wine-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.wine-card.consumed { opacity: 0.65; }

.card-photo {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  display: block;
  background: var(--bg-cream);
}
.card-photo-placeholder {
  width: 100%;
  aspect-ratio: 3/4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
  background: linear-gradient(135deg, #f8f0e8, #efe5d8);
  color: var(--border);
}

.card-body { padding: 0.85rem 1rem 1rem; }
.card-producer {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold);
  margin-bottom: 0.1rem;
}
.card-name {
  font-size: 0.975rem;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.3;
  margin-bottom: 0.25rem;
}
.card-vintage {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-bottom: 0.5rem;
}
.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.6rem;
  gap: 0.5rem;
}
.card-price {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--burgundy);
}
.card-price small {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-light);
}

/* ─── Status badges ──────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.badge-ready    { background: #d4edda; color: #155724; }
.badge-hold     { background: #cce5ff; color: #004085; }
.badge-peak     { background: #fff3cd; color: #856404; }
.badge-consumed { background: #f8d7da; color: #721c24; }
.badge-low      { background: #f1f1f1; color: #555; }

.card-actions {
  display: flex;
  gap: 0.4rem;
  padding: 0 1rem 0.85rem;
  flex-wrap: wrap;
}

/* ─── Confidence indicator ───────────────────────────────── */
.confidence-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 3px;
}
.confidence-high   { background: #27ae60; }
.confidence-medium { background: #f39c12; }
.confidence-low    { background: #e74c3c; }

/* ─── Modal overlay ──────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 10, 15, 0.6);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  opacity: 0;
  transition: opacity 0.2s;
}
.modal-overlay.visible { opacity: 1; }
.modal-overlay.hidden { display: none; }

.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 680px;
  max-height: 92vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.25s ease;
}
.modal-overlay.visible .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}
.modal-header h2 { margin: 0; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-light);
  line-height: 1;
  padding: 0.25rem;
  border-radius: 50%;
  transition: background var(--transition);
}
.modal-close:hover { background: var(--bg-cream); color: var(--text-dark); }

.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ─── Drop zone ──────────────────────────────────────────── */
.drop-zone {
  border: 2.5px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  color: var(--text-light);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--burgundy);
  background: rgba(107, 39, 55, 0.04);
}
.drop-zone .drop-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.drop-zone p { font-size: 0.9rem; margin-bottom: 0.35rem; }
.drop-zone small { font-size: 0.75rem; color: var(--text-light); }
.drop-zone input[type="file"] { display: none; }

/* ─── Preview grid inside add modal ─────────────────────── */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}
.preview-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 3/4;
  background: var(--bg-cream);
}
.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.preview-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.65);
  color: #fff;
  border: none;
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─── Processing / spinner ───────────────────────────────── */
.processing-state {
  text-align: center;
  padding: 2.5rem 1.5rem;
}
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--burgundy);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1.25rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.status-msg {
  color: var(--text-mid);
  font-size: 0.95rem;
  font-weight: 500;
}

/* ─── Detail modal ───────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.5rem;
}
.detail-photo {
  width: 100%;
  border-radius: var(--radius-md);
  object-fit: cover;
  max-height: 320px;
  grid-column: 1 / -1;
}
.detail-field label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-light);
  display: block;
  margin-bottom: 0.2rem;
}
.detail-field span {
  color: var(--text-dark);
  font-size: 0.95rem;
}
.detail-field.full { grid-column: 1 / -1; }
.notes-editor {
  width: 100%;
  min-height: 80px;
  padding: 0.6rem 0.8rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
  outline: none;
  transition: border-color var(--transition);
}
.notes-editor:focus { border-color: var(--burgundy); }

/* ─── Toast notifications ────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  z-index: 2000;
  pointer-events: none;
}
.toast {
  background: var(--text-dark);
  color: #fff;
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  max-width: 320px;
  pointer-events: auto;
  animation: slideIn 0.25s ease, fadeOut 0.4s ease 2.8s forwards;
  border-left: 4px solid var(--gold);
}
.toast.success { border-left-color: #27ae60; }
.toast.error   { border-left-color: #e74c3c; background: #c0392b; }
.toast.info    { border-left-color: #2980b9; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(10px); } }

/* ─── Form fields ────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-mid);
  margin-bottom: 0.35rem;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.55rem 0.8rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
  background: #fff;
  color: var(--text-dark);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--burgundy); }

/* ─── Divider ────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

/* ─── Responsive tweaks ──────────────────────────────────── */
@media (max-width: 600px) {
  .navbar { padding: 0 1rem; }
  .stats-bar { padding: 1rem; gap: 0.75rem; }
  .filter-bar { padding: 0.75rem 1rem; }
  .wine-grid-container { padding: 1rem 1rem 3rem; }
  .wine-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.9rem; }
  .detail-grid { grid-template-columns: 1fr; }
  .modal { border-radius: var(--radius-md) var(--radius-md) 0 0; align-self: flex-end; max-height: 96vh; }
  .modal-overlay { align-items: flex-end; }
  .toast-container { right: 1rem; left: 1rem; }
  .toast { max-width: 100%; }
}
@media (max-width: 400px) {
  .wine-grid { grid-template-columns: 1fr 1fr; }
}
