/* ============================================================================
   failbuono — stili front-end (scoped sotto .fb-app per non toccare Astra)
   ============================================================================ */

.fb-app {
  --espresso: #2c1810;
  --espresso-2: #3a2419;
  --gold: #c08b6e;
  --gold-light: #d4a98f;
  --cream: #f5f0e8;
  --parchment: #ede8df;
  --linen: #e8e0d4;
  --text-muted: #9e8070;

  font-family: 'Jost', sans-serif;
  font-weight: 300;
  color: var(--espresso);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
  max-width: 1200px;
  margin: 0 auto;
}

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

.fb-app h1, .fb-app h2, .fb-app h3, .fb-app h4 {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 400;
  color: var(--espresso);
  margin: 0 0 .4em;
  line-height: 1.15;
}
.fb-app h1 { font-size: 2.4rem; }
.fb-app h2 { font-size: 1.8rem; }
.fb-app h3 { font-size: 1.3rem; }

.fb-eyebrow {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .18em;
  color: var(--gold); font-weight: 500;
}

/* ---- Form controls ---- */
.fb-field { margin-bottom: 1.1rem; }
.fb-label {
  display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-muted); margin-bottom: .35rem; font-weight: 500;
}
.fb-input, .fb-select, .fb-textarea {
  width: 100%; padding: .65rem .8rem; font-family: 'Jost', sans-serif; font-size: .92rem;
  background: #fff; border: 1px solid var(--linen); border-radius: 8px; color: var(--espresso);
  transition: border-color .15s ease;
  line-height: 1.5; height: auto; min-height: 0;
}
/* Astra comprime i select: forziamo altezza e line-height per non tagliare il testo */
.fb-app select.fb-select {
  height: auto !important;
  min-height: 2.9rem;
  line-height: 1.5 !important;
  padding: .55rem 2rem .55rem .8rem !important;
  background-position: right .7rem center;
  vertical-align: middle;
  -webkit-appearance: none; -moz-appearance: none; 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='%239e8070' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
}
.fb-app .fb-input, .fb-app .fb-textarea {
  height: auto !important; line-height: 1.5 !important;
}
.fb-input:focus, .fb-select:focus, .fb-textarea:focus {
  outline: none; border-color: var(--gold);
}
.fb-textarea { resize: vertical; min-height: 70px; }
.fb-row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }

/* ---- Buttons ---- */
.fb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .7rem 1.4rem; font-family: 'Jost', sans-serif; font-size: .82rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: .08em; border: none; border-radius: 8px;
  background: var(--espresso); color: var(--gold); cursor: pointer;
  transition: transform .15s ease, opacity .15s ease;
}
.fb-btn:hover { opacity: .92; }
.fb-btn:active { transform: scale(.97); }
.fb-btn:disabled { opacity: .45; cursor: not-allowed; }
.fb-btn-ghost {
  background: transparent; color: var(--espresso); border: 1px solid var(--linen);
}

/* ---- Template occasioni (Premium) ---- */
.fb-templates { display: flex; flex-wrap: wrap; gap: .5rem; }
.fb-tpl {
  padding: .45rem .8rem; font-family: 'Jost', sans-serif; font-size: .8rem;
  border: 1.5px solid var(--linen); border-radius: 99px; background: #fff;
  cursor: pointer; transition: border-color .15s ease, background .15s ease;
}
.fb-tpl:hover { border-color: var(--gold); }
.fb-tpl-active { border-color: var(--gold); background: var(--cream); }

/* ---- Theme selector ---- */
.fb-themes { display: flex; gap: .6rem; }
.fb-theme-dot {
  flex: 1; padding: .6rem; border: 1.5px solid var(--linen); border-radius: 10px;
  background: #fff; cursor: pointer; text-align: center; font-size: .78rem;
  transition: border-color .15s ease;
}
.fb-theme-dot[aria-pressed="true"] { border-color: var(--gold); background: var(--cream); }
.fb-theme-swatch { width: 100%; height: 22px; border-radius: 6px; margin-bottom: .3rem; }

/* ---- Split panel ---- */
.fb-split { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; align-items: start; }
.fb-panel {
  background: #fff; border: 1px solid var(--linen); border-radius: 14px; padding: 1.6rem;
}
.fb-preview-wrap { position: sticky; top: 1.5rem; }
@media (max-width: 860px) {
  .fb-split { grid-template-columns: 1fr; }
  .fb-preview-wrap { position: static; }
  .fb-row { grid-template-columns: 1fr; }
}

/* ============================================================================
   Anteprima coupon — 3 temi
   ============================================================================ */
.fb-coupon {
  max-width: 480px; margin: 0 auto; border-radius: 16px; overflow: hidden;
  box-shadow: 0 18px 50px -20px rgba(44,24,16,.45); background: var(--t-bodyBg);
  border: 1px solid var(--t-border);
}
.fb-coupon-head {
  background: var(--t-headerBg); color: var(--t-headerText); padding: 1.6rem 1.6rem 1.3rem;
  text-align: center;
}
.fb-coupon-head .fb-shop { font-family: 'Cormorant Garamond', serif; font-size: 1.6rem; }
.fb-coupon-head .fb-tag { font-size: .68rem; text-transform: uppercase; letter-spacing: .22em; opacity: .85; }
.fb-coupon-logo { width: 54px; height: 54px; object-fit: contain; border-radius: 8px; margin: 0 auto .6rem; display: block; background: rgba(255,255,255,.12); }
.fb-coupon-body { padding: 1.5rem 1.6rem 1.7rem; color: var(--t-textDark); }
.fb-coupon-value {
  font-family: 'Cormorant Garamond', serif; font-size: 2.2rem; text-align: center;
  color: var(--t-accent); margin: .2rem 0 .1rem;
}
.fb-coupon-service { text-align: center; font-size: .95rem; }
.fb-coupon-msg { text-align: center; font-style: italic; font-size: .88rem; margin: 1rem 0; color: var(--t-textDark); opacity: .85; }
.fb-coupon-meta { display: flex; justify-content: space-between; font-size: .72rem; color: var(--t-textDark); opacity: .7; border-top: 1px dashed var(--t-border); padding-top: .9rem; margin-top: 1rem; }
.fb-coupon-code {
  text-align: center; margin-top: 1rem; font-family: 'Courier New', monospace; letter-spacing: .18em;
  font-size: 1.05rem; font-weight: 700; color: var(--t-headerBg);
  background: var(--t-bodyBg); border: 1.5px dashed var(--t-accent); border-radius: 8px; padding: .55rem;
}
.fb-coupon-recipient { text-align: center; font-size: .82rem; color: var(--t-textDark); opacity: .8; margin-bottom: .3rem; }

/* Codice + QR affiancati (QR solo sui coupon Premium con codice reale) */
.fb-coupon-codeline { display: flex; align-items: stretch; gap: .7rem; margin-top: 1rem; }
.fb-coupon-codeline .fb-coupon-code { margin-top: 0; flex: 1; display: flex; align-items: center; justify-content: center; }
.fb-coupon-qr {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #fff; border: 1.5px dashed var(--t-accent); border-radius: 8px; padding: .4rem .4rem .25rem;
}
.fb-coupon-qr svg { display: block; width: 74px; height: 74px; }
.fb-coupon-qr-label { font-size: .55rem; text-transform: uppercase; letter-spacing: .12em; color: var(--t-textDark); opacity: .65; margin-top: .15rem; }

.fb-app .theme-naturale { --t-headerBg:#2c1a14; --t-headerText:#c08b6e; --t-accent:#c08b6e; --t-bodyBg:#f5ede4; --t-textDark:#3d2b23; --t-border:#d4bfad; }
.fb-app .theme-salvia   { --t-headerBg:#131c15; --t-headerText:#82a882; --t-accent:#82a882; --t-bodyBg:#eaf3ea; --t-textDark:#131c15; --t-border:#d4e8d4; }
.fb-app .theme-rosa     { --t-headerBg:#1e1218; --t-headerText:#b47890; --t-accent:#b47890; --t-bodyBg:#f4e8ee; --t-textDark:#1e1218; --t-border:#e8d4dc; }

/* ============================================================================
   PREMIUM — trattamento grafico arricchito (automatico per piano Premium)
   ============================================================================ */
.fb-coupon-premium {
  box-shadow: 0 28px 70px -20px rgba(44,24,16,.6);
  border: 1px solid var(--t-accent);
  position: relative;
}
/* doppia cornice oro interna */
.fb-coupon-premium::before {
  content: ""; position: absolute; inset: 7px; border: 1px solid var(--t-accent);
  border-radius: 12px; pointer-events: none; opacity: .45; z-index: 3;
}
/* header con accento dorato superiore e ornamento */
.fb-coupon-premium .fb-coupon-head {
  position: relative;
  background-image: linear-gradient(180deg, rgba(255,255,255,.06), transparent 40%);
}
.fb-coupon-premium .fb-coupon-head::after {
  content: "✦"; position: absolute; left: 50%; transform: translateX(-50%);
  bottom: .55rem; font-size: .7rem; color: var(--t-headerText); opacity: .8;
}
/* badge PREMIUM discreto */
.fb-coupon-premium .fb-tag::before { content: "✦ "; }
/* texture sottilissima sul corpo + filigrana occasione */
.fb-coupon-premium .fb-coupon-body {
  position: relative; overflow: hidden;
  background-image: radial-gradient(var(--t-border) .6px, transparent .6px);
  background-size: 16px 16px;
}
.fb-coupon-premium .fb-coupon-body > * { position: relative; z-index: 2; }
/* valore con cornice decorativa */
.fb-coupon-premium .fb-coupon-value {
  position: relative; display: inline-block; left: 50%; transform: translateX(-50%);
  padding: 0 1.4rem;
}
.fb-coupon-premium .fb-coupon-value::before,
.fb-coupon-premium .fb-coupon-value::after {
  content: "❧"; position: absolute; top: 50%; transform: translateY(-50%);
  font-size: .9rem; color: var(--t-accent); opacity: .6;
}
.fb-coupon-premium .fb-coupon-value::before { left: -.2rem; }
.fb-coupon-premium .fb-coupon-value::after { right: -.2rem; transform: translateY(-50%) scaleX(-1); }

/* Filigrana grafica a tema per occasione (solo Premium) */
.fb-coupon-premium[class*="fb-occ-"] .fb-coupon-body::after {
  position: absolute; right: -14px; bottom: -28px; font-size: 130px; line-height: 1;
  opacity: .08; pointer-events: none; z-index: 1; transform: rotate(-8deg);
}
.fb-occ-compleanno   .fb-coupon-body::after { content: "🎂"; }
.fb-occ-natale       .fb-coupon-body::after { content: "🎄"; }
.fb-occ-sanvalentino .fb-coupon-body::after { content: "❤"; }
.fb-occ-mamma        .fb-coupon-body::after { content: "💐"; }
.fb-occ-papa         .fb-coupon-body::after { content: "👔"; }
.fb-occ-anniversario .fb-coupon-body::after { content: "🥂"; }
.fb-occ-lauretta     .fb-coupon-body::after { content: "🎓"; }
.fb-occ-grazie       .fb-coupon-body::after { content: "🙏"; }

/* ---- Banner / stati ---- */
.fb-banner { border-radius: 12px; padding: 1rem 1.2rem; margin-bottom: 1.5rem; font-size: .9rem; }
.fb-banner-pending { background: #fff8e1; border: 1px solid #f0c040; color: #7a5c00; }
.fb-banner-ok { background: #eafaf0; border: 1px solid #8fd6a8; color: #1d6b3a; }

/* ---- Coupon list ---- */
.fb-list { width: 100%; border-collapse: collapse; font-size: .85rem; }
.fb-list th { text-align: left; padding: .6rem; font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); border-bottom: 1px solid var(--linen); }
.fb-list td { padding: .65rem .6rem; border-bottom: 1px solid var(--linen); }
.fb-list-wrap { overflow-x: auto; }
.fb-code-pill { font-family: 'Courier New', monospace; letter-spacing: .1em; background: var(--parchment); padding: .2rem .5rem; border-radius: 5px; font-size: .8rem; }
.fb-badge { font-size: .7rem; padding: .15rem .55rem; border-radius: 99px; }
.fb-badge-active { background: #dcfce7; color: #16a34a; }
.fb-badge-used { background: #f3f4f6; color: #6b7280; }

.fb-spinner { display: inline-block; width: 22px; height: 22px; border: 2px solid var(--linen); border-top-color: var(--gold); border-radius: 50%; animation: fb-spin .7s linear infinite; }
@keyframes fb-spin { to { transform: rotate(360deg); } }
.fb-center { text-align: center; padding: 3rem 1rem; }

/* ---- Stampa: solo il coupon, colori forzati, una pagina ---- */
.fb-print-portal { display: none; }
@media print {
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }
  /* quando stampiamo, mostriamo solo il portale col coupon clonato */
  body.fb-printing > *:not(.fb-print-portal) { display: none !important; }
  body.fb-printing { background: #fff !important; }
  .fb-print-portal {
    display: flex !important; justify-content: center !important; align-items: flex-start !important;
    width: 100% !important; margin: 0 !important; padding: 0 !important;
  }
  .fb-print-portal .fb-coupon {
    box-shadow: none !important;
    width: 150mm !important; max-width: 150mm !important;
    page-break-inside: avoid !important; break-inside: avoid !important;
  }
  .fb-print-portal .fb-coupon-qr { background: #fff !important; }
  .fb-print-portal .fb-coupon-qr svg { width: 22mm !important; height: 22mm !important; }
  @page { size: A4 portrait; margin: 14mm; }
}

/* ============================================================================
   DASHBOARD negoziante
   ============================================================================ */
.fb-dash { max-width: 1000px; margin: 0 auto; }
.fb-dash-title { font-family: 'Cormorant Garamond', serif; font-weight: 400; color: var(--espresso, #2c1810); font-size: 1.8rem; margin: 0 0 1.2rem; }
.fb-prem-tag { display: inline-block; font-family: 'Jost', sans-serif; font-size: .6rem; letter-spacing: .12em; text-transform: uppercase; background: #2c1810; color: #c08b6e; padding: .25rem .6rem; border-radius: 99px; vertical-align: middle; }

.fb-stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.fb-stat { background: #fff; border: 1px solid #e8e0d4; border-radius: 14px; padding: 1.3rem 1.1rem; text-align: center; }
.fb-stat-value { font-family: 'Cormorant Garamond', serif; font-size: 2.4rem; line-height: 1; color: #2c1810; }
.fb-stat-label { font-family: 'Jost', sans-serif; font-size: .85rem; font-weight: 500; color: #2c1810; margin-top: .5rem; }
.fb-stat-hint { font-size: .72rem; color: #9e8070; margin-top: .2rem; }

.fb-dash-plan { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: #f5f0e8; border: 1px solid #e8e0d4; border-radius: 14px; padding: 1.1rem 1.4rem; margin-top: 1rem; }
.fb-plan-name { font-family: 'Cormorant Garamond', serif; font-size: 1.6rem; color: #c08b6e; line-height: 1.1; }
.fb-plan-hint { font-size: .85rem; color: #2c1810; text-align: right; }

.fb-dash-upsell { background: #f5f0e8; border: 1.5px dashed #c08b6e; border-radius: 16px; padding: 1.8rem; margin-top: 2rem; text-align: center; }
.fb-dash-upsell h3 { font-family: 'Cormorant Garamond', serif; font-weight: 400; font-size: 1.6rem; color: #2c1810; margin: .8rem 0 .5rem; }
.fb-dash-upsell p { font-size: .92rem; color: #9e8070; max-width: 520px; margin: 0 auto 1.2rem; line-height: 1.6; }

@media (max-width: 760px) {
  .fb-stat-grid { grid-template-columns: repeat(2, 1fr); }
  .fb-dash-plan { flex-direction: column; align-items: flex-start; }
  .fb-plan-hint { text-align: left; }
}
