/* ═══════════════════════════════════════════════════════════
   PhotoPrint — Design System
   Material Design 3 · Tonal Palette · Pastel + Preto
   ═══════════════════════════════════════════════════════════ */

:root {
  /* ─── Primary: Sage Green ───────────────────── */
  --md-primary-10: #17312B;
  --md-primary-20: #295047;
  --md-primary-30: #3C6A5F;
  --md-primary-40: #4F8576;
  --md-primary-50: #68A08F;
  --md-primary-60: #84B8A8;
  --md-primary-70: #A5D0C2;
  --md-primary-80: #C8E6DA;
  --md-primary-90: #E5F5EE;
  --md-primary-95: #F2FBF7;
  --md-primary-container: var(--md-primary-90);
  --md-on-primary-container: var(--md-primary-10);

  /* ─── Secondary: Dusty Blue ─────────────────── */
  --md-secondary-10: #22303C;
  --md-secondary-20: #324657;
  --md-secondary-40: #5E7B90;
  --md-secondary-80: #D3E2EA;
  --md-secondary-90: #EDF5F8;

  /* ─── Tertiary: Soft Lavender ──────────────── */
  --md-tertiary-40: #816993;
  --md-tertiary-80: #E3DCEF;
  --md-tertiary-90: #F4EFF8;

  /* ─── Neutral ──────────────────────────────── */
  --md-neutral-0: #000000;
  --md-neutral-4: #0E0E0E;
  --md-neutral-6: #121212;
  --md-neutral-10: #1B1B1B;
  --md-neutral-20: #313131;
  --md-neutral-30: #4A4A4A;
  --md-neutral-40: #646464;
  --md-neutral-50: #808080;
  --md-neutral-60: #9E9E9E;
  --md-neutral-70: #BDBDBD;
  --md-neutral-80: #D9D9D9;
  --md-neutral-90: #EFEFEF;
  --md-neutral-92: #F3F3F3;
  --md-neutral-94: #F6F6F6;
  --md-neutral-95: #F8F8F8;
  --md-neutral-96: #FAFAFA;
  --md-neutral-98: #FCFCFC;
  --md-neutral-99: #FEFEFE;

  /* ─── Neutral Variant (bordas / divisores) ─── */
  --md-nv-80: #D8D8D5;
  --md-nv-90: #ECECE8;

  /* ─── Semantic ─────────────────────────────── */
  --md-error-40: #B55252;
  --md-error-80: #F2C7C7;
  --md-error-90: #FAE7E7;
  --md-success-40: #4C8F63;
  --md-success-80: #C9EACF;
  --md-success-90: #EAF7ED;
  --md-warning-40: #C28A32;
  --md-warning-80: #F7E3B8;
  --md-warning-90: #FCF2DD;
  --md-info-40: #5B83B7;
  --md-info-80: #D5E4F6;
  --md-info-90: #EDF4FC;

  /* ─── Preto como protagonista ──────────────── */
  --md-btn-primary-bg: #111111;
  --md-btn-primary-hover: #1F1F1F;
  --md-btn-primary-pressed: #000000;
  --md-btn-primary-text: #FFFFFF;

  /* ─── Surfaces ─────────────────────────────── */
  --md-surface-0: #FFFFFF;
  --md-surface-1: #F8F8F8;
  --md-surface-2: #F3F3F3;
  --md-surface-3: #ECECE8;

  /* ─── Text ─────────────────────────────────── */
  --md-on-surface: #1B1B1B;
  --md-on-surface-variant: #4A4A4A;
  --md-text-tertiary: #808080;
  --md-text-disabled: #BDBDBD;

  /* ─── State Layers (MD3 overlay system) ────── */
  --md-state-hover: 0.08;          /* 8%  opacity */
  --md-state-focus: 0.10;          /* 10% opacity */
  --md-state-pressed: 0.10;        /* 10% opacity */
  --md-state-dragged: 0.16;        /* 16% opacity */
  /* Overlay colors: black for light surfaces, white for dark */
  --md-state-layer-light: rgba(0, 0, 0, var(--md-state-hover));
  --md-state-layer-press: rgba(0, 0, 0, var(--md-state-pressed));
  /* Disabled: 38% opacity on content; 12% on surface */
  --md-disabled-content-opacity: 0.38;
  --md-disabled-surface-opacity: 0.12;

  /* ─── Borders ──────────────────────────────── */
  --md-outline: var(--md-nv-80);
  --md-outline-variant: #E8E8ED;   /* manter compatibilidade com bordas finas */
}

/* ═══════════════════════════════════════════════════════════
   Material Design 3 Icons
   ═══════════════════════════════════════════════════════════ */

.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variation-settings:
    'FILL' 0,
    'wght' 400,
    'GRAD' 0,
    'opsz' 24;
  vertical-align: middle;
}

/* Hero icons (welcome, export) */
.hero-icon {
  font-size: 64px;
  font-variation-settings:
    'FILL' 0,
    'wght' 300,
    'GRAD' 0,
    'opsz' 48;
}

/* Upload area icon */
.upload-icon {
  font-size: 48px;
  font-variation-settings:
    'FILL' 0,
    'wght' 300,
    'GRAD' 0,
    'opsz' 48;
}

/* Card icons (journey cards) */
.jc-icon .material-symbols-outlined {
  font-size: 36px;
  font-variation-settings:
    'FILL' 0,
    'wght' 400,
    'GRAD' 0,
    'opsz' 40;
}

/* Arrow icons in cards */
.jc-arrow .material-symbols-outlined {
  font-size: 20px;
  color: var(--md-neutral-70);
}

/* Back button icon */
.back-btn .material-symbols-outlined {
  font-size: 20px;
}

/* Navigation button icons */
.adjust-nav-btn .material-symbols-outlined {
  font-size: 22px;
}

/* Button icons */
.btn .material-symbols-outlined {
  font-size: 18px;
  vertical-align: middle;
  margin-right: 2px;
}

/* Toast icons */
.toast .material-symbols-outlined {
  font-size: 16px;
  vertical-align: middle;
  margin-right: 4px;
}

/* Cell remove icon */
.cell-remove .material-symbols-outlined {
  font-size: 16px;
}

/* Empty state icon */
.empty-state .material-symbols-outlined {
  font-size: 48px;
  font-variation-settings:
    'FILL' 0,
    'wght' 300,
    'GRAD' 0,
    'opsz' 48;
}

/* Sample kit / photo upload icon */
.sample-kit-area .icon .material-symbols-outlined,
.photo-upload-area .icon .material-symbols-outlined {
  font-size: 32px;
}

/* ═══════════════════════════════════════════════════════════
   Base
   ═══════════════════════════════════════════════════════════ */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--md-surface-1);
  min-height: 100vh; display: flex; justify-content: center;
}

.app-shell {
  width: 100%; max-width: 480px;
  background: var(--md-surface-0);
  display: flex; flex-direction: column;
  min-height: 100vh;
  position: relative;
}

/* ─── HEADER ─────────────────────────────── */
.header {
  height: 48px; display: flex; align-items: center; justify-content: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--md-outline);
  position: relative; flex-shrink: 0;
  background: var(--md-surface-0);
}
.header .back-btn {
  position: absolute; left: 8px; background: none; border: none;
  font-size: 24px; cursor: pointer; color: var(--md-primary-40); padding: 8px 12px;
  line-height: 1; border-radius: 50%;
  transition: all 0.15s;
}
.header .back-btn:hover {
  background: var(--md-primary-container);
}
.header .back-btn:active {
  background: linear-gradient(var(--md-state-layer-press), var(--md-state-layer-press)),
              var(--md-primary-container);
}
.header .title {
  font-size: 17px; font-weight: 600; color: var(--md-on-surface);
}

.screens {
  flex: 1; overflow-y: auto; position: relative;
  -webkit-overflow-scrolling: touch;
}
.screen { display: none; padding: 20px 16px; min-height: 100%; }
.screen.active { display: block; }

/* ─── BOTTOM BAR ─────────────────────────── */
.bottom-bar {
  padding: 12px 16px;
  border-top: 1px solid var(--md-outline);
  background: var(--md-surface-0); flex-shrink: 0;
}
.bottom-bar .btn { width: 100%; }

/* ═══════════════════════════════════════════════════════════
   Buttons
   ═══════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 14px 28px; border-radius: 14px; font-size: 16px;
  font-weight: 600; border: none; cursor: pointer; transition: all 0.15s;
  font-family: inherit; gap: 8px;
  position: relative;
}
.btn-block { width: 100%; }

/* Primary — Preto como protagonista (cores fixas do MD) */
.btn-primary {
  background: var(--md-btn-primary-bg);
  color: var(--md-btn-primary-text);
}
.btn-primary:hover { background: var(--md-btn-primary-hover); }
.btn-primary:active { background: var(--md-btn-primary-pressed); }
.btn-primary:disabled {
  background: var(--md-neutral-80);
  color: var(--md-neutral-50);
  cursor: not-allowed;
}

/* Secondary — overlay preto sobre surface-0 */
.btn-secondary {
  background: var(--md-surface-0);
  color: var(--md-on-surface);
  border: 1px solid var(--md-outline);
}
.btn-secondary:hover {
  background: linear-gradient(var(--md-state-layer-light), var(--md-state-layer-light)),
              var(--md-surface-0);
}
.btn-secondary:active {
  background: linear-gradient(var(--md-state-layer-press), var(--md-state-layer-press)),
              var(--md-surface-0);
}
.btn-secondary:disabled {
  opacity: var(--md-disabled-content-opacity);
  cursor: not-allowed;
}

/* Outline */
.btn-outline {
  background: var(--md-surface-0);
  color: var(--md-primary-40);
  border: 1.5px solid var(--md-primary-40);
}
.btn-outline:hover {
  background: linear-gradient(var(--md-state-layer-light), var(--md-state-layer-light)),
              var(--md-surface-0);
}
.btn-outline:active {
  background: linear-gradient(var(--md-state-layer-press), var(--md-state-layer-press)),
              var(--md-surface-0);
}
.btn-outline:disabled {
  opacity: var(--md-disabled-content-opacity);
  cursor: not-allowed;
}

.btn-sm { padding: 10px 18px; font-size: 14px; border-radius: 10px; }

/* Danger — overlay preto sobre error-40 */
.btn-danger {
  background: var(--md-error-40);
  color: #fff;
}
.btn-danger:hover {
  background: linear-gradient(var(--md-state-layer-light), var(--md-state-layer-light)),
              var(--md-error-40);
}
.btn-danger:active {
  background: linear-gradient(var(--md-state-layer-press), var(--md-state-layer-press)),
              var(--md-error-40);
}

/* ═══════════════════════════════════════════════════════════
   Welcome
   ═══════════════════════════════════════════════════════════ */

.welcome-hero { text-align: center; padding: 40px 0 28px; }
.welcome-hero .icon { font-size: 64px; margin-bottom: 16px; }
.welcome-hero h1 {
  font-size: 28px; font-weight: 700; color: var(--md-on-surface);
  line-height: 1.25; margin-bottom: 8px;
}
.welcome-hero p {
  font-size: 15px; color: var(--md-on-surface-variant);
  line-height: 1.5; max-width: 320px; margin: 0 auto;
}

.journey-cards { display: flex; flex-direction: column; gap: 12px; padding: 0 0 20px; }
.journey-card {
  border: 2px solid var(--md-outline); border-radius: 18px;
  padding: 20px 16px; cursor: pointer; transition: all 0.15s;
  display: flex; align-items: center; gap: 14px;
  background: var(--md-surface-0);
}
.journey-card:hover {
  background: linear-gradient(var(--md-state-layer-light), var(--md-state-layer-light)),
              var(--md-surface-0);
}
.journey-card:active {
  border-color: var(--md-primary-40);
  background: linear-gradient(var(--md-state-layer-press), var(--md-state-layer-press)),
              var(--md-surface-0);
  transform: scale(0.985);
}
.journey-card .jc-icon { font-size: 36px; width: 48px; text-align: center; flex-shrink: 0; }
.journey-card .jc-text h3 { font-size: 16px; font-weight: 600; color: var(--md-on-surface); }
.journey-card .jc-text p {
  font-size: 13px; color: var(--md-text-tertiary);
  margin-top: 3px; line-height: 1.35;
}
.journey-card .jc-arrow { color: var(--md-neutral-70); font-size: 20px; margin-left: auto; }

/* ─── SECTION HEAD ───────────────────────── */
.section-head { margin-bottom: 16px; }
.section-head h2 { font-size: 22px; font-weight: 700; color: var(--md-on-surface); margin-bottom: 4px; }
.section-head p { font-size: 13px; color: var(--md-on-surface-variant); }

/* ═══════════════════════════════════════════════════════════
   File Input / Photo Upload
   ═══════════════════════════════════════════════════════════ */

.photo-upload-area {
  border: 2px dashed var(--md-outline); border-radius: 18px;
  padding: 40px 20px; text-align: center; cursor: pointer;
  transition: all 0.15s; background: var(--md-surface-1); margin-bottom: 16px;
}
.photo-upload-area:hover {
  border-color: var(--md-primary-40);
  background: linear-gradient(var(--md-state-layer-light), var(--md-state-layer-light)),
              var(--md-surface-1);
}
.photo-upload-area:active {
  border-color: var(--md-primary-40);
  background: linear-gradient(var(--md-state-layer-press), var(--md-state-layer-press)),
              var(--md-surface-1);
}
.photo-upload-area .icon { font-size: 48px; margin-bottom: 10px; }
.photo-upload-area p { font-size: 15px; font-weight: 600; color: var(--md-on-surface); }
.photo-upload-area .sub { font-size: 12px; color: var(--md-text-tertiary); margin-top: 4px; }
#fileInput { display: none; }

/* Sample kit */
.sample-kit-area {
  border: 2px solid var(--md-outline); border-radius: 18px;
  padding: 18px 20px; text-align: center; cursor: pointer;
  transition: all 0.15s; background: var(--md-surface-0); margin-bottom: 16px;
  display: flex; align-items: center; justify-content: center; gap: 12px;
}
.sample-kit-area:hover {
  border-color: var(--md-success-40);
  background: linear-gradient(var(--md-state-layer-light), var(--md-state-layer-light)),
              var(--md-surface-0);
}
.sample-kit-area:active {
  border-color: var(--md-success-40);
  background: linear-gradient(var(--md-state-layer-press), var(--md-state-layer-press)),
              var(--md-surface-0);
}
.sample-kit-area .icon { font-size: 32px; }
.sample-kit-area .info { text-align: left; }
.sample-kit-area .info p { font-size: 15px; font-weight: 600; color: var(--md-on-surface); }
.sample-kit-area .info .sub { font-size: 12px; color: var(--md-text-tertiary); margin-top: 2px; }
.sample-kit-area .badge {
  background: var(--md-success-40); color: #fff; font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: 20px; white-space: nowrap;
}

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.photo-cell {
  aspect-ratio: 1; background: var(--md-neutral-80);
  border-radius: 6px; overflow: hidden;
  border: 3px solid transparent; transition: border-color 0.12s; position: relative;
}
.photo-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-cell .cell-remove {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px;
  border-radius: 50%; background: rgba(0,0,0,0.60); color: #fff; border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; cursor: pointer; line-height: 1;
}

.photo-selected-count {
  text-align: center; font-size: 13px; color: var(--md-on-surface-variant);
  margin-top: 12px; font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════
   Frame / Size Selection
   ═══════════════════════════════════════════════════════════ */

.section-divider {
  font-size: 13px; font-weight: 700; color: var(--md-on-surface-variant);
  text-transform: uppercase; letter-spacing: 0.8px;
  margin: 20px 0 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--md-outline);
}

.option-list { display: flex; flex-direction: column; gap: 10px; }
.option-card {
  border: 2px solid var(--md-outline); border-radius: 16px; padding: 14px;
  cursor: pointer; transition: all 0.15s; display: flex; align-items: center; gap: 14px;
  background: var(--md-surface-0);
}
.option-card:hover {
  background: linear-gradient(var(--md-state-layer-light), var(--md-state-layer-light)),
              var(--md-surface-0);
}
.option-card:active, .option-card.chosen {
  border-color: var(--md-primary-40);
  background: linear-gradient(var(--md-state-layer-press), var(--md-state-layer-press)),
              var(--md-surface-0);
}
.option-card .oc-preview {
  width: 72px; height: 96px; background: var(--md-surface-1);
  border-radius: 4px; flex-shrink: 0; display: flex; align-items: center;
  justify-content: center; font-size: 10px; color: var(--md-neutral-60);
  position: relative; overflow: hidden;
}
.option-card .oc-preview img { width: 100%; height: 100%; object-fit: cover; opacity: 0.7; }

/* Molduras (frames) — Instax Mini pattern from SVG */
.option-card .oc-preview.moldura-instax {
  aspect-ratio: 638/1016; height: 96px; width: auto;
  border: none; background: var(--md-surface-0);
  box-shadow: 0 0 0 1px var(--md-neutral-80);
  overflow: hidden; padding: 0;
}
.option-card .oc-preview.moldura-instax .photo-area {
  position: absolute; overflow: hidden; background: var(--md-neutral-80);
}
.option-card .oc-preview.moldura-instax .photo-area img {
  width: 100%; height: 100%; object-fit: cover; opacity: 0.85;
  border-radius: 0;
}

.option-card .oc-info { flex: 1; }
.option-card .oc-info h3 { font-size: 15px; font-weight: 600; color: var(--md-on-surface); }
.option-card .oc-info .dim { font-size: 12px; color: var(--md-on-surface-variant); margin-top: 2px; }
.option-card .oc-info .a4count {
  font-size: 12px; color: var(--md-primary-40); font-weight: 600; margin-top: 2px;
}
.option-card .oc-check {
  color: var(--md-primary-40); font-size: 20px; font-weight: 700;
  flex-shrink: 0; width: 28px; text-align: center;
}

/* ═══════════════════════════════════════════════════════════
   Adjust
   ═══════════════════════════════════════════════════════════ */

.adjust-wrap { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.adjust-viewport {
  background: var(--md-surface-1);
  border: 2px solid var(--md-neutral-30); border-radius: 8px;
  overflow: hidden; position: relative; cursor: grab; touch-action: none;
  user-select: none; -webkit-user-select: none;
}
.adjust-viewport:active { cursor: grabbing; }

/* Instax Mini card (SVG pattern) */
.adjust-viewport.instax-frame {
  width: min(240px, calc(100% - 96px));
  aspect-ratio: 240 / 382;
  padding: 0;
  background: var(--md-surface-0); border: none; border-radius: 2px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18), 0 0 0 0.5px rgba(0,0,0,0.06);
}
.adjust-viewport.instax-frame .adjust-photo-area {
  position: absolute; overflow: hidden; background: var(--md-neutral-80);
}

/* Navegação entre fotos */
.adjust-nav-row {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; width: 100%;
}
.adjust-nav-btn {
  width: 40px; height: 40px; flex-shrink: 0;
  border-radius: 50%; border: none; background: var(--md-surface-2);
  color: var(--md-on-surface); font-size: 22px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-family: inherit; transition: all 0.15s;
}
.adjust-nav-btn:hover {
  background: linear-gradient(var(--md-state-layer-light), var(--md-state-layer-light)),
              var(--md-surface-2);
}
.adjust-nav-btn:active {
  background: linear-gradient(var(--md-state-layer-press), var(--md-state-layer-press)),
              var(--md-primary-40);
  color: #fff; transform: scale(0.94);
}

.adjust-image {
  position: absolute; pointer-events: none;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
}
.adjust-controls { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 6px; }
.adjust-controls label {
  font-size: 12px; font-weight: 700; color: var(--md-on-surface-variant);
  text-transform: uppercase; letter-spacing: 0.8px;
}
.adjust-controls input[type="range"] {
  width: 100%; accent-color: var(--md-primary-40); height: 6px;
}
.adjust-row { display: flex; gap: 10px; width: 100%; }
.adjust-row .btn { flex: 1; }

.photo-dots { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 4px; }
.photo-dots .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--md-neutral-70);
  transition: all 0.2s; cursor: pointer;
}
.photo-dots .dot.current { background: var(--md-primary-40); width: 24px; border-radius: 4px; }

/* Contador de foto (ex: 3 / 12) */
.adjust-counter {
  text-align: center; font-size: 13px; font-weight: 600;
  color: var(--md-on-surface-variant); margin-bottom: 8px;
}

/* ─── LAYOUT PREVIEW ─────────────────────── */

.layout-section { text-align: center; }
.a4-sheet {
  background: var(--md-surface-0); aspect-ratio: 210 / 297; width: 100%; max-width: 280px;
  margin: 0 auto 24px; border: none;
  box-shadow: 0 0 0 1px var(--md-nv-80), 0 2px 10px rgba(0,0,0,0.06);
  position: relative; overflow: hidden;
}
.a4-sheet .placed-photo {
  position: absolute; overflow: hidden;
}
.a4-sheet .placed-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Moldura Instax */
.a4-sheet .placed-photo.moldura {
  background: var(--md-surface-0); border-radius: 1px;
}
.a4-sheet .placed-photo.moldura .photo-area {
  position: absolute; overflow: hidden; background: var(--md-neutral-80);
}
.a4-sheet .placed-photo.moldura .photo-area img {
  width: 100%; height: 100%; object-fit: cover;
}
.a4-sheet .placed-photo.tamanho {
  background: var(--md-surface-2);
}
.a4-sheet .placed-photo.tamanho img { width: 100%; height: 100%; object-fit: cover; display: block; }
.layout-meta {
  font-size: 13px; color: var(--md-on-surface-variant);
  margin-bottom: 16px; line-height: 1.4;
}

/* ═══════════════════════════════════════════════════════════
   Export
   ═══════════════════════════════════════════════════════════ */

.export-hero { text-align: center; margin-bottom: 20px; }
.export-hero .icon { font-size: 48px; margin-bottom: 10px; }
.export-hero h2 { font-size: 20px; font-weight: 700; color: var(--md-on-surface); }
.export-hero p { font-size: 13px; color: var(--md-on-surface-variant); margin-top: 4px; }

/* ═══════════════════════════════════════════════════════════
   Toast
   ═══════════════════════════════════════════════════════════ */

.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: var(--md-neutral-20); color: #fff; padding: 10px 22px;
  border-radius: 20px; font-size: 14px; font-weight: 500;
  opacity: 0; transition: opacity 0.3s;
  pointer-events: none; z-index: 100;
}
.toast.visible { opacity: 1; }

/* ═══════════════════════════════════════════════════════════
   Empty State
   ═══════════════════════════════════════════════════════════ */

.empty-state { text-align: center; padding: 40px 20px; color: var(--md-neutral-60); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ─── SCROLL ─────────────────────────────── */
.screens::-webkit-scrollbar { width: 0; }
