/* ReelStudio AI — Material 3 Expressive Blue Design System */

:root {
  --bg-canvas: #e9f1ff;
  --bg-canvas-accent: #dbe8ff;
  --surface-card: #f7faff;
  --surface-elevated: #ffffff;
  --surface-tint: #e1ecff;
  --surface-tint-strong: #c7dcff;
  --text-primary: #0c1b3a;
  --text-secondary: #43577d;
  --text-muted: #697ea6;
  --blue-primary: #1d4ed8;
  --blue-deep: #17368e;
  --blue-bright: #2563eb;
  --blue-pastel: #bfdbfe;
  --blue-pastel-hover: #93c5fd;
  --accent-sky: #0284c7;
  --accent-coral-blue: #0ea5e9;
  --accent-highlight: #38bdf8;
  --danger-bg: #fee2e2;
  --danger-text: #b91c1c;
  --success-bg: #dcfce7;
  --success-text: #15803d;
  --border-soft: rgba(29, 78, 216, 0.11);
  --shadow-card: 0 10px 30px -12px rgba(23, 54, 142, 0.14), 0 2px 8px -2px rgba(23, 54, 142, 0.06);
  --shadow-pill: 0 8px 20px -6px rgba(29, 78, 216, 0.28);
  --radius-card: 28px;
  --radius-inner: 20px;
}

html.dark {
  --bg-canvas: #070e1c;
  --bg-canvas-accent: #0d182e;
  --surface-card: #101c33;
  --surface-elevated: #162440;
  --surface-tint: #1b2d50;
  --surface-tint-strong: #233b69;
  --text-primary: #eef4ff;
  --text-secondary: #b4c7ea;
  --text-muted: #7f97c4;
  --blue-primary: #3b82f6;
  --blue-deep: #60a5fa;
  --blue-bright: #2563eb;
  --blue-pastel: #1e3a8a;
  --blue-pastel-hover: #1d4ed8;
  --accent-sky: #38bdf8;
  --accent-coral-blue: #0ea5e9;
  --accent-highlight: #7dd3fc;
  --danger-bg: rgba(239, 68, 68, 0.18);
  --danger-text: #fca5a5;
  --success-bg: rgba(34, 197, 94, 0.18);
  --success-text: #86efac;
  --border-soft: rgba(96, 165, 250, 0.18);
  --shadow-card: 0 14px 36px -12px rgba(0, 0, 0, 0.55);
  --shadow-pill: 0 10px 24px -8px rgba(37, 99, 235, 0.45);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 12% 10%, var(--bg-canvas-accent) 0%, var(--bg-canvas) 48%, var(--bg-canvas-accent) 100%);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
  transition: background 0.3s ease, color 0.25s ease;
}

h1, h2, h3, .font-display {
  font-family: 'Outfit', 'Plus Jakarta Sans', sans-serif;
  letter-spacing: -0.02em;
}

.material-symbols-rounded {
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
  user-select: none;
  vertical-align: middle;
}

/* Expressive Bento Cards */
.m3-card {
  background: var(--surface-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.22s ease, background 0.25s ease;
}

.m3-card-elevated {
  background: var(--surface-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

/* Expressive Navigation Rail Item */
.m3-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.93rem;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.m3-nav-item:hover {
  background: var(--surface-tint);
  color: var(--text-primary);
}

.m3-nav-item.active {
  background: var(--blue-pastel);
  color: var(--blue-deep);
  font-weight: 700;
}

html.dark .m3-nav-item.active {
  color: #ffffff;
}

/* Primary Expressive Pill CTA (ispirato a "Add friend" nell'immagine) */
.m3-cta-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 24px;
  border-radius: 22px;
  border: none;
  font-weight: 700;
  font-size: 0.96rem;
  color: #ffffff;
  background: linear-gradient(135deg, #2563eb 0%, #0284c7 100%);
  box-shadow: var(--shadow-pill);
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.2, 0.9, 0.3, 1), filter 0.18s ease, box-shadow 0.2s ease;
}

.m3-cta-pill:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.015);
  filter: brightness(1.06);
}

.m3-cta-pill:active:not(:disabled) {
  transform: scale(0.97);
}

.m3-cta-pill:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Stacked Pastel Action Pills (ispirate a Select / Add photos / Share) */
.m3-action-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--surface-tint);
  color: var(--blue-deep);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.18s ease;
}

html.dark .m3-action-pill {
  color: #dbeafe;
}

.m3-action-pill:hover {
  background: var(--surface-tint-strong);
  transform: translateY(-1px);
}

/* Connected Segmented Button Group (ispirato a Going | Not Going | Maybe) */
.m3-segmented {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
  border-radius: 999px;
  background: var(--surface-tint);
  border: 1px solid var(--border-soft);
}

.m3-seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  white-space: nowrap;
}

.m3-seg-btn.active {
  background: var(--blue-primary);
  color: #ffffff;
  box-shadow: 0 6px 16px -4px rgba(29, 78, 216, 0.45);
}

/* Floating Pill Toolbar + Contrasting Squircle (ispirato alla toolbar nell'immagine) */
.m3-floating-bar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 999px;
  background: var(--surface-elevated);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-card);
}

.m3-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.15s ease;
}

.m3-icon-btn:hover {
  background: var(--surface-tint);
  transform: scale(1.06);
}

.m3-squircle-btn {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  border: none;
  background: linear-gradient(135deg, #0ea5e9, #1d4ed8);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 16px -4px rgba(14, 165, 233, 0.5);
  transition: transform 0.18s ease;
}

.m3-squircle-btn:hover {
  transform: scale(1.06);
}

/* Form Inputs & Selects */
.m3-input, .m3-select, .m3-textarea {
  width: 100%;
  padding: 12px 16px;
  border-radius: 18px;
  border: 1.5px solid var(--border-soft);
  background: var(--surface-elevated);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.93rem;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.m3-input:focus, .m3-select:focus, .m3-textarea:focus {
  border-color: var(--blue-primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

/* Expressive Toggle Switch */
.m3-switch {
  position: relative;
  width: 52px;
  height: 30px;
  flex-shrink: 0;
}

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

.m3-switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--surface-tint-strong);
  border: 2px solid var(--border-soft);
  cursor: pointer;
  transition: all 0.22s ease;
}

.m3-switch-track::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--blue-deep);
  transition: transform 0.22s cubic-bezier(0.3, 1.3, 0.5, 1), background 0.2s ease, width 0.18s ease;
}

.m3-switch input:checked + .m3-switch-track {
  background: var(--blue-primary);
  border-color: var(--blue-primary);
}

.m3-switch input:checked + .m3-switch-track::after {
  transform: translateX(22px);
  background: #ffffff;
}

/* Wavy Expressive Progress Bar (ispirato al pannello centrale nell'immagine) */
.wavy-progress-wrap {
  position: relative;
  height: 24px;
  width: 100%;
  display: flex;
  align-items: center;
}

.wavy-track-bg {
  position: absolute;
  left: 0;
  right: 0;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-tint-strong);
}

.wavy-svg {
  position: relative;
  z-index: 2;
  height: 22px;
  overflow: visible;
}

.wavy-path {
  fill: none;
  stroke: var(--blue-primary);
  stroke-width: 5;
  stroke-linecap: round;
  animation: waveSlide 1.4s linear infinite;
}

@keyframes waveSlide {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: -40; }
}

/* Scalloped 12-petal Material Expressive Seal (ispirato al badge in basso nell'immagine) */
.m3-scallop-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}

/* Illustrazione sfumata nella barra laterale desktop sopra Motore Locale */
.m3-rail-heritage {
  position: relative;
  width: 100%;
  aspect-ratio: 687 / 390;
  max-height: 126px;
  border-radius: 20px;
  overflow: hidden;
  margin-top: auto;
  margin-bottom: -4px;
  pointer-events: none;
  user-select: none;
}

.m3-rail-heritage img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
  opacity: 0.86;
  filter: saturate(0.94) contrast(1.02);
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(0, 0, 0, 0.88) 14%,
    rgba(0, 0, 0, 0.96) 72%,
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(0, 0, 0, 0.88) 14%,
    rgba(0, 0, 0, 0.96) 72%,
    transparent 100%
  );
}

.m3-rail-heritage::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, var(--surface-card) 0%, transparent 11%, transparent 89%, var(--surface-card) 100%),
    linear-gradient(180deg, rgba(29, 78, 216, 0.05) 0%, transparent 40%, var(--surface-card) 100%);
}

html.dark .m3-rail-heritage img {
  opacity: 0.72;
  filter: saturate(0.88) brightness(0.9);
}

/* Drag & Drop Dropzone */
.m3-dropzone {
  border: 2px dashed rgba(37, 99, 235, 0.36);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(219, 234, 254, 0.45), rgba(239, 246, 255, 0.7));
  transition: all 0.2s ease;
}

html.dark .m3-dropzone {
  background: linear-gradient(180deg, rgba(30, 58, 138, 0.25), rgba(16, 28, 51, 0.6));
  border-color: rgba(96, 165, 250, 0.35);
}

.m3-dropzone.drag-over {
  border-color: var(--blue-primary);
  background: rgba(191, 219, 254, 0.55);
  transform: scale(1.008);
}

/* Modal & System Popup Backdrop (stessa grafica Material Expressive Blue) */
.m3-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(8, 19, 44, 0.46);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.m3-modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.m3-modal-card {
  width: 100%;
  max-width: 640px;
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--surface-elevated);
  border: 1.5px solid var(--border-soft);
  border-radius: 32px;
  box-shadow: 0 28px 64px -16px rgba(10, 25, 62, 0.45);
  transform: translateY(14px) scale(0.97);
  transition: transform 0.24s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.m3-modal-backdrop.open .m3-modal-card {
  transform: translateY(0) scale(1);
}

/* Mobile Bottom Nav Safe Area */
@media (max-width: 1023px) {
  .desktop-rail {
    display: none !important;
  }
  .main-scroll-area {
    padding-bottom: calc(98px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .mobile-bottom-nav {
    bottom: calc(10px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

@media (min-width: 1024px) {
  .mobile-bottom-nav {
    display: none !important;
  }
}

/* Custom subtle scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(59, 130, 246, 0.28);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(59, 130, 246, 0.48);
}
