/**
 * Wedding Photo Sharing Site - Camila & Diego
 * Elegant wedding theme with gold accents
 */

/* ===========================
   CSS Variables / Design Tokens
   =========================== */

:root {
  /* Wedding Color Palette */
  --color-primary: #C9A86C;
  --color-primary-light: #D4BC8A;
  --color-primary-dark: #B8956A;
  --color-background: #FDFBF7;
  --color-surface: #FFFFFF;
  --color-text: #2C2C2C;
  --color-text-light: #666666;
  --color-text-muted: #999999;
  --color-border: #E8E4DC;
  --color-border-light: #F0EDE6;
  --color-success: #6B8E6B;
  --color-error: #C75B5B;
  --color-warning: #D4A84B;
  --color-info: #6B8EA8;

  /* Typography */
  --font-heading: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Touch targets */
  --touch-min: 48px;

  /* Borders */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.05), 0 4px 6px rgba(0, 0, 0, 0.05);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 300ms ease;
  --transition-slow: 500ms ease;

  /* Z-index layers */
  --z-dropdown: 100;
  --z-modal: 1000;
  --z-toast: 1100;
}

/* ===========================
   Reset & Base Styles
   =========================== */

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

* {
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background-color: var(--color-background);
  color: var(--color-text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* Prevent body scroll when modal is open */
body.viewer-open {
  overflow: hidden;
}

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

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

[hidden] {
  display: none !important;
}

/* Screen reader only */
.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;
}

/* ===========================
   Typography
   =========================== */

.couple-names {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 10vw, 3.5rem);
  font-weight: 400;
  text-align: center;
  color: var(--color-text);
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.wedding-date {
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--color-text-light);
  text-align: center;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-top: var(--space-sm);
}

.section-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--color-text);
  margin-bottom: var(--space-sm);
}

.section-subtitle {
  font-size: 0.9375rem;
  color: var(--color-text-light);
}

/* ===========================
   Header
   =========================== */

.wedding-header {
  padding: var(--space-xl) var(--space-md) var(--space-lg);
  text-align: center;
  background: linear-gradient(
    180deg,
    rgba(201, 168, 108, 0.08) 0%,
    transparent 100%
  );
}

/* ===========================
   Connection Status
   =========================== */

.connection-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-warning);
  color: white;
  font-size: 0.875rem;
}

.connection-status[hidden] {
  display: none;
}

.connection-status.offline {
  background: var(--color-error);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.queue-count {
  margin-left: var(--space-sm);
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
}

/* ===========================
   Upload Section
   =========================== */

.upload-section {
  padding: var(--space-md);
  text-align: center;
}

.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 30vh;
  margin: var(--space-md) 0;
  padding: var(--space-lg);
  border: 3px dashed var(--color-border);
  border-radius: var(--radius-xl);
  background: linear-gradient(
    135deg,
    rgba(201, 168, 108, 0.03) 0%,
    rgba(201, 168, 108, 0.08) 100%
  );
  cursor: pointer;
  transition: all var(--transition-normal);
}

.upload-zone:hover,
.upload-zone:focus-within {
  border-color: var(--color-primary-light);
  background: linear-gradient(
    135deg,
    rgba(201, 168, 108, 0.05) 0%,
    rgba(201, 168, 108, 0.12) 100%
  );
}

.upload-zone:active,
.upload-zone.drag-over {
  transform: scale(0.98);
  border-color: var(--color-primary);
  border-style: solid;
}

.upload-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
}

.upload-icon {
  width: 64px;
  height: 64px;
  color: var(--color-primary);
}

.upload-text {
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--color-text);
}

.upload-hint {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

/* Upload Actions */
.upload-actions {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  margin-top: var(--space-md);
}

/* ===========================
   Buttons
   =========================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  min-height: var(--touch-min);
  padding: var(--space-md) var(--space-xl);
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
}

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

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

.btn-primary:hover {
  background: var(--color-primary-dark);
}

.btn-primary:active {
  transform: scale(0.95);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 2px solid var(--color-border);
}

.btn-secondary:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* ===========================
   Upload Progress List
   =========================== */

.upload-list {
  margin-top: var(--space-lg);
  padding: var(--space-md);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.upload-item {
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-border-light);
}

.upload-item:last-child {
  border-bottom: none;
}

.upload-item-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
}

.upload-item-name {
  font-size: 0.875rem;
  color: var(--color-text);
  font-weight: 500;
}

.upload-item-status {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.upload-item.complete .upload-item-status {
  color: var(--color-success);
}

.upload-item.error .upload-item-status {
  color: var(--color-error);
}

.upload-item.queued .upload-item-status {
  color: var(--color-info);
}

/* Progress Bar */
.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--color-border-light);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(
    90deg,
    var(--color-primary) 0%,
    var(--color-primary-light) 100%
  );
  transition: width var(--transition-normal);
}

.upload-item.complete .progress-fill {
  background: var(--color-success);
}

.upload-item.error .progress-fill {
  background: var(--color-error);
}

/* ===========================
   Gallery Section
   =========================== */

.gallery-section {
  padding: var(--space-md);
  padding-bottom: var(--space-2xl);
}

.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--space-md);
}

.photo-count {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

/* Gallery Grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 4px;
}

@media (min-width: 640px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 6px;
  }
}

.gallery-item {
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--color-border-light);
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.gallery-item:hover {
  transform: scale(1.02);
}

.gallery-item:active {
  transform: scale(0.98);
}

.gallery-item:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.gallery-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity var(--transition-normal);
}

.gallery-image[data-src] {
  opacity: 0.5;
}

/* Empty State */
.gallery-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  text-align: center;
}

.empty-icon {
  width: 64px;
  height: 64px;
  color: var(--color-border);
  margin-bottom: var(--space-md);
}

.empty-text {
  font-size: 1.125rem;
  color: var(--color-text-light);
  margin-bottom: var(--space-xs);
}

.empty-hint {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

/* Loading State */
.gallery-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  color: var(--color-text-muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: var(--space-md);
}

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

/* ===========================
   Modals
   =========================== */

.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: rgba(0, 0, 0, 0.9);
}

.modal[hidden] {
  display: none;
}

/* ===========================
   Camera Modal
   =========================== */

.camera-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.camera-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: black;
}

.camera-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-xl);
  padding: var(--space-xl);
  padding-bottom: calc(var(--space-xl) + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
}

.camera-control-btn {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  transition: background var(--transition-fast);
}

.camera-control-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.camera-control-btn svg {
  width: 24px;
  height: 24px;
}

.capture-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: white;
  border: 4px solid var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast);
}

.capture-btn:active,
.capture-btn.capturing {
  transform: scale(0.9);
}

.capture-btn-inner {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--color-primary);
}

.camera-error {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  background: rgba(0, 0, 0, 0.95);
  color: white;
  text-align: center;
}

.camera-error p {
  margin-bottom: var(--space-lg);
  font-size: 1rem;
  line-height: 1.6;
}

/* ===========================
   Photo Viewer Modal
   =========================== */

.viewer-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewer-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  top: calc(var(--space-md) + env(safe-area-inset-top));
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  z-index: 10;
  transition: background var(--transition-fast);
}

.viewer-close:hover {
  background: rgba(0, 0, 0, 0.7);
}

.viewer-close svg {
  width: 24px;
  height: 24px;
}

.viewer-image-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}

.viewer-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: opacity var(--transition-normal);
}

.viewer-image.loading {
  opacity: 0.5;
}

.viewer-nav {
  position: absolute;
  bottom: var(--space-xl);
  bottom: calc(var(--space-xl) + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: var(--space-lg);
}

.viewer-nav-btn {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  transition: all var(--transition-fast);
}

.viewer-nav-btn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.7);
}

.viewer-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.viewer-nav-btn svg {
  width: 24px;
  height: 24px;
}

/* ===========================
   Toast Notifications
   =========================== */

.toast-container {
  position: fixed;
  bottom: var(--space-lg);
  bottom: calc(var(--space-lg) + env(safe-area-inset-bottom));
  left: var(--space-md);
  right: var(--space-md);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(20px);
  transition: all var(--transition-normal);
}

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

.toast-hide {
  opacity: 0;
  transform: translateY(-20px);
}

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.toast-icon svg {
  width: 100%;
  height: 100%;
}

.toast-success .toast-icon {
  color: var(--color-success);
}

.toast-error .toast-icon {
  color: var(--color-error);
}

.toast-warning .toast-icon {
  color: var(--color-warning);
}

.toast-info .toast-icon {
  color: var(--color-info);
}

.toast-message {
  flex: 1;
  font-size: 0.9375rem;
  color: var(--color-text);
}

.toast-close {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  transition: color var(--transition-fast);
}

.toast-close:hover {
  color: var(--color-text);
}

.toast-close svg {
  width: 16px;
  height: 16px;
}

/* ===========================
   Responsive Adjustments
   =========================== */

@media (min-width: 640px) {
  .upload-zone {
    min-height: 40vh;
    margin: var(--space-lg) 0;
    padding: var(--space-xl);
  }

  .toast-container {
    max-width: 400px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
  }
}

@media (min-width: 1024px) {
  .upload-section,
  .gallery-section {
    max-width: 1200px;
    margin: 0 auto;
  }

  .viewer-nav-btn {
    width: 56px;
    height: 56px;
  }

  .viewer-nav-btn svg {
    width: 28px;
    height: 28px;
  }
}

/* ===========================
   Print Styles
   =========================== */

@media print {
  .upload-section,
  .connection-status,
  .modal,
  .toast-container {
    display: none !important;
  }

  .gallery-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
