/* ========== CSS Variables ========== */
:root {
  --cream: #fdf8f3;
  --blush: #f5d6c8;
  --rose: #e8a598;
  --wine: #8b4560;
  --plum: #5c2d45;
  --sage: #c8d8c0;
  --sage-dark: #8aab7e;
  --gold: #d4a853;
  --gold-light: #f0d9a0;
  --dark: #2a1a20;
  --mid: #6b4a57;
  --light-text: #9a7080;
  --border: rgba(139, 69, 96, 0.15);
  --shadow-soft: 0 8px 40px rgba(92, 45, 69, 0.12);
  --shadow-card: 0 4px 24px rgba(92, 45, 69, 0.1);
  --radius: 20px;
  --radius-sm: 12px;
}

/* ========== Reset & Base ========== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: 'DM Sans', sans-serif;
  background-color: var(--cream);
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(245, 214, 200, 0.6) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 90%, rgba(200, 216, 192, 0.5) 0%, transparent 50%),
    radial-gradient(ellipse at 60% 30%, rgba(212, 168, 83, 0.08) 0%, transparent 40%);
  background-attachment: fixed;
  color: var(--dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

/* ========== Toast Notifications ========== */
#toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: all;
  background: white;
  border-radius: 14px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 32px rgba(92, 45, 69, 0.2);
  border-left: 4px solid var(--rose);
  min-width: 260px;
  max-width: 340px;
  animation: toastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
}

.toast.success { border-left-color: var(--sage-dark); }
.toast.warning { border-left-color: var(--gold); }
.toast.error   { border-left-color: #e57373; }
.toast.info    { border-left-color: #81b4ea; }

.toast-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  color: var(--plum);
  font-size: 13px;
  margin-bottom: 2px;
}

.toast-message {
  color: var(--mid);
  font-size: 12px;
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--light-text);
  font-size: 16px;
  padding: 0;
  margin: 0;
  box-shadow: none;
  flex-shrink: 0;
  line-height: 1;
  transition: color 0.2s;
}

.toast-close:hover {
  transform: none;
  box-shadow: none;
  color: var(--plum);
}

.toast.hiding {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px) scale(0.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to   { opacity: 0; transform: translateX(40px) scale(0.9); }
}

/* ========== Navbar (preserved structure) ========== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(253, 248, 243, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 1px 0 var(--border), 0 4px 20px rgba(92, 45, 69, 0.06);
  padding: 10px;
  margin-bottom: 30px;
  transition: all 0.3s ease-in-out;
  width: 100%;
}

.nav-container {
  padding: 10px;
  margin: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-menu {
  list-style: none;
  display: flex;
  gap: 24px;
}

.nav-menu li a {
  text-decoration: none;
  color: var(--wine);
  font-weight: 600;
  font-size: 15px;
  padding: 8px 14px;
  border-radius: 8px;
  transition: all 0.3s ease;
  font-family: 'DM Sans', sans-serif;
}

.nav-menu li a:hover {
  background-color: var(--wine);
  color: white;
  box-shadow: 0 0 12px rgba(139, 69, 96, 0.3);
}

.menu-toggle {
  display: none;
  font-size: 26px;
  cursor: pointer;
  color: var(--wine);
}

/* ========== Page Title ========== */
.page-header {
  text-align: center;
  margin-bottom: 32px;
  padding: 0 20px;
}

.page-header h1 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(28px, 5vw, 48px);
  color: var(--plum);
  letter-spacing: -0.5px;
  line-height: 1.1;
  margin-bottom: 8px;
}

.page-header h1 span {
  color: var(--rose);
}

.page-header p {
  font-size: 14px;
  color: var(--light-text);
  font-weight: 300;
  letter-spacing: 0.3px;
}

/* ========== Main Container ========== */
#main-container {
  display: flex;
  gap: 28px;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  max-width: 1300px;
  padding: 0 20px 40px;
  flex-wrap: wrap;
}

/* ========== Left Panel ========== */
.left-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  flex: 1;
  min-width: 280px;
  max-width: 700px;
}

/* ========== Video Container ========== */
.video-wrapper {
  position: relative;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--plum);
  box-shadow: var(--shadow-soft), inset 0 0 0 1px rgba(255,255,255,0.1);
  aspect-ratio: 3/2;
}

.video-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  box-shadow: inset 0 0 60px rgba(92, 45, 69, 0.3);
  z-index: 2;
  pointer-events: none;
}

video {
  transform: scaleX(-1);
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: var(--radius);
}

/* Filter classes applied to video */
video.filter-grayscale { filter: grayscale(1) contrast(1.1); }
video.filter-sepia     { filter: sepia(0.85) contrast(1.05); }
video.filter-vivid     { filter: saturate(1.6) contrast(1.15); }
video.filter-fade      { filter: saturate(0.7) brightness(1.1) contrast(0.9); }
video.filter-warm      { filter: sepia(0.3) saturate(1.3) brightness(1.05); }
video.filter-cool      { filter: hue-rotate(180deg) saturate(0.8) brightness(1.05); }
video.filter-noir      { filter: grayscale(1) contrast(1.4) brightness(0.85); }
video.filter-film      { filter: sepia(0.2) contrast(1.1) saturate(1.15) brightness(0.95); }

#countdown {
  font-family: 'Playfair Display', serif;
  font-size: clamp(50px, 12vw, 80px);
  color: white;
  font-weight: 700;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  text-shadow: 0 4px 20px rgba(0,0,0,0.5);
  animation: countPulse 1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes countPulse {
  0%   { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  60%  { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.flash-effect {
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0;
  z-index: 9;
  transition: opacity 0.15s ease-out;
  pointer-events: none;
}

/* ========== Camera Status Badge ========== */
.camera-status {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 11px;
  color: white;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.4s;
}

.camera-status.visible { opacity: 1; }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4caf50;
  animation: dotPulse 1.5s infinite;
}

@keyframes dotPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.7; }
}

/* Photo counter */
.photo-counter {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 5;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 11px;
  color: white;
  font-weight: 600;
  display: none;
}

/* ========== Controls Card ========== */
.controls-card {
  background: white;
  border-radius: var(--radius);
  padding: 22px 24px;
  width: 100%;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
}

.controls-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--light-text);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

select {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  border: 1.5px solid var(--border);
  color: var(--plum);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 36px 10px 14px;
  border-radius: 50px;
  cursor: pointer;
  appearance: none;
  -webkit-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 d='M1 1l5 5 5-5' stroke='%238b4560' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

select:focus {
  outline: none;
  border-color: var(--rose);
  box-shadow: 0 0 0 3px rgba(232, 165, 152, 0.2);
}

/* ========== Buttons ========== */
button {
  font-family: 'DM Sans', sans-serif;
  padding: 11px 22px;
  border: none;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--wine), var(--plum));
  color: white;
  box-shadow: 0 4px 16px rgba(139, 69, 96, 0.35);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 24px rgba(139, 69, 96, 0.4);
}

.btn-secondary {
  background: white;
  color: var(--wine);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-card);
}

.btn-secondary:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--rose);
  box-shadow: 0 6px 20px rgba(139, 69, 96, 0.12);
}

.btn-success {
  background: linear-gradient(135deg, var(--sage-dark), #6a9b5e);
  color: white;
  box-shadow: 0 4px 16px rgba(138, 171, 126, 0.35);
}

.btn-success:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 24px rgba(138, 171, 126, 0.4);
}

.btn-ghost {
  background: transparent;
  color: var(--light-text);
  border: 1.5px solid var(--border);
  font-size: 13px;
  padding: 9px 18px;
}

.btn-ghost:hover {
  background: var(--cream);
  color: var(--mid);
  transform: translateY(-1px);
  box-shadow: none;
}

button:disabled {
  background: #e8e0e4;
  color: #b0a0a8;
  cursor: not-allowed;
  box-shadow: none;
  transform: none !important;
}

/* ========== Filter Panel ========== */
.filter-panel {
  background: white;
  border-radius: var(--radius);
  padding: 20px 24px;
  width: 100%;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
}

.filter-panel-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--light-text);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 10px;
}

.filter-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  background: var(--cream);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: none;
  margin: 0;
  font-size: 11px;
  color: var(--mid);
  font-weight: 500;
  transform: none;
}

.filter-btn:hover {
  background: var(--blush);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(92, 45, 69, 0.12);
}

.filter-btn.active {
  border-color: var(--wine);
  background: white;
  color: var(--wine);
  box-shadow: 0 4px 16px rgba(139, 69, 96, 0.2);
}

.filter-btn:hover { transform: translateY(-2px); }

.filter-preview {
  width: 48px;
  height: 36px;
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(135deg, #fae4d8, #d8ecd2);
  position: relative;
  flex-shrink: 0;
}

.filter-preview::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 8px;
}

/* Filter preview thumbnails */
.fp-normal::after  { background: transparent; }
.fp-grayscale { background: linear-gradient(135deg, #ccc, #888); }
.fp-sepia     { background: linear-gradient(135deg, #c9a87c, #8b6e4e); }
.fp-vivid     { background: linear-gradient(135deg, #ff8fa3, #7fc6a4); }
.fp-fade      { background: linear-gradient(135deg, #e0d0c8, #c0d8bc); }
.fp-warm      { background: linear-gradient(135deg, #f5c58a, #e8a090); }
.fp-cool      { background: linear-gradient(135deg, #8ab0d8, #a0c8c0); }
.fp-noir      { background: linear-gradient(135deg, #111, #555); }
.fp-film      { background: linear-gradient(135deg, #c8b08a, #a0b898); }

/* ========== Right Panel — Preview ========== */
.right-panel {
  width: 100%;
  max-width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.preview-title {
  font-family: 'Playfair Display', serif;
  font-size: 18px;
  color: var(--plum);
}

.photo-count-badge {
  background: var(--blush);
  color: var(--wine);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
}

.preview-container {
  background: white;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.preview-item {
  position: relative;
  cursor: pointer;
  border-radius: var(--radius-sm);
  overflow: hidden;
  group: '';
}

.preview-live-img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-sm);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 2px solid var(--border);
}

.preview-item:hover .preview-live-img {
  transform: scale(1.03);
  border-color: var(--rose);
}

.preview-overlay {
  position: absolute;
  inset: 0;
  background: rgba(92, 45, 69, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: white;
  font-weight: 600;
  gap: 6px;
  backdrop-filter: blur(2px);
}

.preview-item:hover .preview-overlay { opacity: 1; }

.preview-slot-empty {
  width: 100%;
  aspect-ratio: 3/2;
  border-radius: var(--radius-sm);
  border: 2px dashed var(--border);
  background: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
  color: var(--light-text);
  font-size: 12px;
  transition: all 0.3s;
}

.preview-slot-empty.capturing {
  border-color: var(--rose);
  background: rgba(245, 214, 200, 0.3);
  animation: slotPulse 1s infinite;
}

@keyframes slotPulse {
  0%, 100% { border-color: var(--rose); }
  50% { border-color: var(--wine); box-shadow: 0 0 16px rgba(232, 165, 152, 0.4); }
}

.slot-number {
  width: 28px;
  height: 28px;
  background: var(--blush);
  color: var(--wine);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

/* ========== Progress Bar ========== */
.progress-bar-wrap {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  display: none;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--rose), var(--wine));
  border-radius: 2px;
  transition: width 0.4s ease;
  width: 0%;
}

/* ========== Tip Banner ========== */
.tip-banner {
  background: linear-gradient(135deg, var(--gold-light), rgba(253,248,243,0.8));
  border: 1px solid var(--gold);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 12px;
  color: #6b4e1a;
  line-height: 1.5;
}

.tip-banner .tip-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ========== Media Query: Tablet ========== */
@media (max-width: 768px) {
  .nav-menu {
    position: absolute;
    top: 70px;
    right: 20px;
    background: rgba(253, 248, 243, 0.97);
    border-radius: 16px;
    padding: 12px 20px;
    box-shadow: 0 8px 30px rgba(92, 45, 69, 0.15);
    flex-direction: column;
    gap: 10px;
    display: none;
    border: 1px solid var(--border);
  }
  .nav-menu.show { display: flex; }
  .menu-toggle { display: block; }

  #main-container {
    flex-direction: column;
    align-items: center;
    padding: 0 16px 40px;
  }

  .left-panel, .right-panel {
    max-width: 100%;
    width: 100%;
  }

  .right-panel {
    max-width: 480px;
  }

  .filter-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .controls-row {
    gap: 8px;
  }

  #toast-container {
    top: auto;
    bottom: 20px;
    right: 16px;
    left: 16px;
  }

  .toast {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .filter-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .filter-btn {
    padding: 8px 4px;
    font-size: 10px;
  }

  .filter-preview {
    width: 40px;
    height: 28px;
  }

  button {
    font-size: 13px;
    padding: 10px 16px;
  }

  .controls-row {
    gap: 6px;
  }
}

/* ========== Footer (preserved) ========== */
.footer {
  width: 100%;
  padding: 24px 16px;
  background: white;
  text-align: center;
  border-top: 1px solid var(--border);
  margin-top: auto;
  box-shadow: 0 -4px 20px rgba(92, 45, 69, 0.05);
}

.footer-text {
  margin: 0;
  font-size: 13px;
  color: var(--light-text);
}

.footer-icons {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-icons img {
  width: 22px;
  height: 22px;
  transition: transform 0.2s ease;
  filter: invert(30%) sepia(60%) saturate(500%) hue-rotate(290deg) brightness(80%) contrast(100%);
}

.footer-icons img:hover { transform: scale(1.2); }

.footer-links {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--wine);
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
  transition: color 0.3s ease;
}

.footer-links a:hover { color: var(--plum); }

/* ========== Misc ========== */
canvas { display: none; }

.divider {
  width: 100%;
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}