/* ============================================================
   Sipper - Premium Dark Theme
   ============================================================ */

/* --- Custom Properties --- */
:root {
  --color-bg: #1a0a00;
  --color-gold: #c8a96e;
  --color-gold-muted: #a08050;
  --color-gold-dim: rgba(200, 169, 110, 0.15);
  --color-text: #f5e6c8;
  --color-text-muted: #a08050;
  --color-card-start: #2d1500;
  --color-card-end: #1a0a00;
  --color-card-border: rgba(200, 169, 110, 0.35);
  --color-surface: rgba(200, 169, 110, 0.08);
  --color-input-bg: #2d1500;
  --color-green: #4caf50;
  --color-amber: #ff9800;
  --color-blue: #42a5f5;
  --color-red: #c0392b;
  --color-white: #ffffff;
  --color-black: #000000;
  --radius-card: 16px;
  --radius-btn: 8px;
  --radius-badge: 12px;
  --radius-input: 8px;
  --font-heading: 'Playfair Display', Georgia, serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --bottom-nav-height: 64px;
  --transition-fast: 0.2s ease;
  --transition-med: 0.4s ease;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100dvh;
  overflow-x: hidden;
}

a {
  color: var(--color-gold);
  text-decoration: none;
  transition: opacity var(--transition-fast);
}

a:hover {
  opacity: 0.8;
}

img {
  display: block;
  max-width: 100%;
}

/* --- Typography --- */
h1, h2, h3 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--color-gold);
  letter-spacing: 0.02em;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }

.heading-display {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--color-gold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.text-muted {
  color: var(--color-text-muted);
}

.text-gold {
  color: var(--color-gold);
}

/* --- Layout --- */
.content {
  padding: 16px 16px calc(var(--bottom-nav-height) + var(--safe-area-bottom) + 24px);
  max-width: 600px;
  margin: 0 auto;
  min-height: 100dvh;
}

.content--no-nav {
  padding-bottom: 24px;
}

.content--wide {
  max-width: 960px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  line-height: 1;
}

.btn:active {
  transform: scale(0.97);
}

.btn--gold {
  background-color: var(--color-gold);
  color: var(--color-bg);
}

.btn--gold:hover {
  background-color: #d4b87a;
  opacity: 1;
}

.btn--outline {
  background: transparent;
  border: 1px solid var(--color-card-border);
  color: var(--color-gold);
}

.btn--outline:hover {
  background: var(--color-gold-dim);
  opacity: 1;
}

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

.btn--danger:hover {
  background-color: #a93226;
  opacity: 1;
}

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

.btn--black {
  background-color: var(--color-black);
  color: var(--color-white);
  border: 1px solid #333;
}

.btn--block {
  width: 100%;
}

.btn--lg {
  padding: 14px 28px;
  font-size: 16px;
  letter-spacing: 0.04em;
}

.btn--sm {
  padding: 8px 16px;
  font-size: 13px;
}

/* --- Inputs --- */
.input {
  width: 100%;
  padding: 12px 16px;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--color-text);
  background-color: var(--color-input-bg);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-input);
  outline: none;
  transition: border-color var(--transition-fast);
}

.input:focus {
  border-color: var(--color-gold);
  box-shadow: 0 0 0 2px var(--color-gold-dim);
}

.input::placeholder {
  color: var(--color-text-muted);
}

select.input {
  appearance: none;
  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='%23a08050' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

textarea.input {
  resize: vertical;
  min-height: 80px;
}

.label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group {
  margin-bottom: 16px;
}

/* --- Cards (generic) --- */
.card {
  background: linear-gradient(145deg, var(--color-card-start), var(--color-card-end));
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.card-padded {
  padding: 20px;
}

/* --- Flashcard (3D flip) --- */
.flashcard-container {
  perspective: 1200px;
  width: 100%;
  margin: 20px 0;
}

.flashcard {
  position: relative;
  width: 100%;
  aspect-ratio: 2.5 / 3.5;
  max-height: 520px;
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.68, -0.55, 0.265, 1.55), box-shadow 0.7s ease;
  cursor: pointer;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), 0 0 1px rgba(200, 169, 110, 0.3);
  border-radius: var(--radius-card);
}

.flashcard:hover {
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.5), 0 0 2px rgba(200, 169, 110, 0.5);
}

.flashcard.flipped {
  transform: rotateY(180deg);
}

.flashcard-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-card);
  overflow: hidden;
  background: linear-gradient(145deg, var(--color-card-start), var(--color-card-end));
  border: 1px solid var(--color-card-border);
  display: flex;
  flex-direction: column;
}

.flashcard-front {
  transform: rotateY(0deg);
}

.flashcard-back {
  transform: rotateY(180deg);
}

.flashcard-image {
  width: 100%;
  height: 240px;
  object-fit: contain;
  background-color: var(--color-surface);
  padding: 16px 12px 12px;
  flex-shrink: 0;
}

.flashcard-body {
  padding: 16px 20px 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 0;
  overflow: hidden;
}

.flashcard-name {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-gold);
  margin-bottom: 4px;
  line-height: 1.3;
}

.flashcard-distillery {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-bottom: 16px;
}

.flashcard-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.flashcard-meta-item {
  background: var(--color-surface);
  border-radius: 8px;
  padding: 10px 12px;
  text-align: center;
}

.flashcard-meta-label {
  font-size: 11px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}

.flashcard-meta-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}

.flashcard-hint {
  text-align: center;
  margin-top: 12px;
  font-size: 12px;
  color: var(--color-text-muted);
  opacity: 0.6;
}

/* Flashcard back */
.flashcard-back-content {
  padding: 20px;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.flashcard.flipped .flashcard-back-content {
  animation: fadeInScale 0.4s ease 0.35s forwards;
  opacity: 0;
}

.flashcard-section {
  margin-bottom: 16px;
}

.flashcard-section-title {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 700;
  color: var(--color-gold);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.flashcard-section-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text);
}

.flashcard-fact {
  background: var(--color-surface);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--color-text);
}

.flashcard-fact strong {
  color: var(--color-gold);
}

.flashcard-pairings {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.flashcard-pairing-tag {
  background: var(--color-gold-dim);
  color: var(--color-gold);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius-badge);
}

.flashcard-similar {
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* --- Scanner --- */
.scanner-upload {
  position: relative;
  border: 2px dashed var(--color-card-border);
  border-radius: var(--radius-card);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--color-surface);
}

.scanner-upload:hover,
.scanner-upload.dragover {
  border-color: var(--color-gold);
  background: var(--color-gold-dim);
}

.scanner-upload-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  color: var(--color-gold-muted);
}

.scanner-upload-text {
  font-size: 15px;
  color: var(--color-text-muted);
}

.scanner-upload-text strong {
  color: var(--color-gold);
}

.scanner-upload input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.scanner-preview {
  margin-top: 16px;
  border-radius: var(--radius-card);
  overflow: hidden;
  display: none;
}

.scanner-preview.visible {
  display: block;
}

.scanner-preview img {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  background: var(--color-surface);
}

/* --- Shimmer Loading --- */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.shimmer-card {
  border-radius: var(--radius-card);
  border: 1px solid var(--color-card-border);
  padding: 20px;
  display: none;
}

.shimmer-card.visible {
  display: block;
  animation: fadeInUp 0.3s ease;
}

.shimmer-block {
  background: linear-gradient(90deg, var(--color-card-start) 25%, var(--color-surface) 50%, var(--color-card-start) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}

.shimmer-image {
  width: 100%;
  height: 160px;
  margin-bottom: 16px;
}

.shimmer-title {
  width: 65%;
  height: 22px;
  margin-bottom: 8px;
}

.shimmer-subtitle {
  width: 45%;
  height: 16px;
  margin-bottom: 16px;
}

.shimmer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.shimmer-grid-item {
  height: 52px;
}

.shimmer-text {
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
  color: var(--color-text-muted);
  font-style: italic;
}

/* --- Status Banner --- */
.status-banner {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  animation: fadeInUp 0.4s ease;
}

.status-banner--new {
  border: 1px solid var(--color-green);
  background: rgba(76, 175, 80, 0.1);
}

.status-banner--duplicate {
  border: 1px solid var(--color-amber);
  background: rgba(255, 152, 0, 0.1);
}

.status-banner--signin {
  border: 1px solid var(--color-blue);
  background: rgba(66, 165, 245, 0.1);
}

.status-banner--error {
  border: 1px solid var(--color-red);
  background: rgba(192, 57, 43, 0.1);
}

.status-banner-text {
  font-size: 14px;
  flex: 1;
}

/* --- Collection Grid --- */
.collection-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.collection-count {
  background: var(--color-gold-dim);
  color: var(--color-gold);
  font-size: 13px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: var(--radius-badge);
}

.collection-search {
  margin-bottom: 20px;
}

.collection-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.collection-empty {
  text-align: center;
  padding: 60px 20px;
}

.collection-empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.collection-empty-text {
  font-size: 16px;
  color: var(--color-text-muted);
  margin-bottom: 20px;
}

/* Collection thumbnail card */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.thumb {
  background: linear-gradient(145deg, var(--color-card-start), var(--color-card-end));
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-card);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  animation: fadeInUp 0.4s ease forwards;
  opacity: 0;
}

.thumb:nth-child(1) { animation-delay: 0.05s; }
.thumb:nth-child(2) { animation-delay: 0.1s; }
.thumb:nth-child(3) { animation-delay: 0.15s; }
.thumb:nth-child(4) { animation-delay: 0.2s; }
.thumb:nth-child(5) { animation-delay: 0.25s; }
.thumb:nth-child(6) { animation-delay: 0.3s; }
.thumb:nth-child(7) { animation-delay: 0.35s; }
.thumb:nth-child(8) { animation-delay: 0.4s; }
.thumb:nth-child(9) { animation-delay: 0.45s; }
.thumb:nth-child(10) { animation-delay: 0.5s; }
.thumb:nth-child(11) { animation-delay: 0.55s; }
.thumb:nth-child(12) { animation-delay: 0.6s; }
.thumb:nth-child(n+13) { animation-delay: 0; opacity: 1; }

.thumb:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.thumb-image {
  width: 100%;
  height: 140px;
  object-fit: contain;
  background: var(--color-surface);
  padding: 8px;
}

.thumb-body {
  padding: 10px 12px 14px;
}

.thumb-type {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-gold);
  background: var(--color-gold-dim);
  padding: 2px 8px;
  border-radius: var(--radius-badge);
  margin-bottom: 6px;
}

.thumb-name {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}

.thumb-sub {
  font-size: 12px;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Bottom Navigation --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
  padding-bottom: var(--safe-area-bottom);
  background: linear-gradient(to top, var(--color-bg) 80%, transparent);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  transition: transform 0.3s ease;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--color-card-border);
}

.bottom-nav.nav-hidden {
  transform: translateY(100%);
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 12px;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
  min-width: 56px;
}

.nav-tab:hover {
  opacity: 1;
  color: var(--color-gold);
}

.nav-tab.active {
  color: var(--color-gold);
}

.nav-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* --- Login Screen --- */
.login-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
  text-align: center;
}

.login-brand {
  font-family: var(--font-heading);
  font-size: 3rem;
  font-weight: 700;
  color: var(--color-gold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.login-tagline {
  font-size: 15px;
  color: var(--color-text-muted);
  margin-bottom: 48px;
}

.login-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}

.login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 20px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-btn);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.login-btn:active {
  transform: scale(0.97);
}

.login-btn--google {
  background: var(--color-white);
  color: #333;
}

.login-btn--google:hover {
  background: #f0f0f0;
  opacity: 1;
}

.login-btn--apple {
  background: var(--color-black);
  color: var(--color-white);
  border: 1px solid #333;
}

.login-btn--apple:hover {
  background: #1a1a1a;
  opacity: 1;
}

.login-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.login-footer {
  margin-top: 32px;
  font-size: 12px;
  color: var(--color-text-muted);
  opacity: 0.6;
}

.login-back {
  margin-top: 24px;
  font-size: 14px;
}

/* --- CMS Table --- */
.cms-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.cms-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.cms-filters .input {
  flex: 1;
  min-width: 120px;
}

.cms-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-card);
  border: 1px solid var(--color-card-border);
}

.cms-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.cms-table th {
  background: var(--color-card-start);
  color: var(--color-gold);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 14px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--color-card-border);
}

.cms-table td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(200, 169, 110, 0.1);
  color: var(--color-text);
  vertical-align: middle;
}

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

.cms-table tr:hover td {
  background: var(--color-surface);
}

.cms-table-img {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--color-surface);
}

.cms-table-actions {
  display: flex;
  gap: 6px;
}

/* CMS Edit Form */
.cms-edit-header {
  margin-bottom: 24px;
}

.cms-edit-image {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  background: var(--color-surface);
  border-radius: var(--radius-card);
  margin-bottom: 20px;
}

.cms-edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.cms-success {
  padding: 12px 16px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--color-green);
  background: rgba(76, 175, 80, 0.1);
  color: var(--color-green);
  font-size: 14px;
  margin-bottom: 20px;
}

.cms-edit-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

/* --- Utility --- */
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-center { text-align: center; }
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Responsive --- */
@media (min-width: 768px) {
  .content {
    padding: 24px 24px calc(var(--bottom-nav-height) + var(--safe-area-bottom) + 32px);
  }

  h1 { font-size: 2.25rem; }

  .flashcard-image { height: 280px; }

  .collection-grid {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
  }

  .thumb-image {
    height: 180px;
  }
}
