:root{
  --bg:#ffffff;
  --panel:#FBFBFB;
  --text:#213856;
  --muted:#5B6B7D;
  --border:#E6E6E6;
  --accent:#316bff;
  --grad-start:#316BFF;
  --grad-end:#134CDD;
}

*{ box-sizing:border-box }
html,body{ height:100% }
html,body{ margin:0; padding:0; overflow:hidden }
body{
  font-family: 'Inter', sans-serif;
  color: var(--text);
  background-color: #fdfdfd;
  opacity: 0.95;
  background-image: radial-gradient(#f1f1f1 1px, #fdfdfd 1px);
  background-size: 12px 12px;
}

/* Header */
.app-header{
  height:56px; padding:0 14px;
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  border-bottom:1px solid var(--border); background:#fff;
}
.app-header h1{ font-size:15px; margin:0; font-weight:700; letter-spacing:.2px; color:#213856 }
.actions{ display:flex; gap:8px; flex-wrap:nowrap }
.btn{
  appearance:none; cursor:pointer; white-space:nowrap;
  border:1px solid var(--border); background:#fff; color:#17161B;
  padding:8px 12px; border-radius:10px; font-size:14px; line-height:24px;
  transition: background .2s ease, border-color .2s ease, color .2s ease;
}
.btn:hover{ border-color:#cbcbcb }
.btn.ghost{ background:linear-gradient(0deg, #FBFBFB -10%, #FFF 100%); }

/* Primary gradient button */
.btnprim {
  padding:8px 12px; border-radius:10px; font-size:14px; line-height:24px;
  color: white;
  border: 1px solid var(--Primary-300, #316BFF);
  background: linear-gradient(0deg, var(--Button-button-primary-300, #316BFF) -10%, var(--Button-button-primary-275, #477BFF) 100%);
  box-shadow: 0 0 6px 0 rgba(0, 0, 0, 0.02), 0 2px 4px 0 rgba(0, 0, 0, 0.08);
  transition: background .2s ease, border-color .2s ease, color .2s ease;
}
.btnprim:hover {
  cursor: pointer;
  border: 1px solid var(--primary-color);
  background: linear-gradient(0deg, var(--Colors-Button-button-primary-300, #316BFF) 0%, var(--Colors-Button-button-primary-325, #1F5EFF) 100%);
  box-shadow: 0 0 6px 0 var(--shadow-2), 0 2px 4px 0 var(--shadow-8);
}

/* Layout */
.wrap{
  display:grid;
  grid-template-columns: 740px 420px;
  gap:14px;
  place-content:center;
  width:fit-content;
  margin:24px auto;
  padding:0 14px;
  min-height: calc(100vh - 56px - 48px);
}

/* Cards */
.panel{
  background: var(--panel);
  border:1px solid var(--border);
  border-radius:16px;
  box-shadow: 0 4px 16px rgba(0,0,0,.08);
  padding:40px;
  overflow: hidden; /* garde tout dans la carte */
}
.panel form{ padding: 20px; }

/* Preview */
.preview{
  background: linear-gradient(135deg, var(--grad-start) 0%, var(--grad-end) 100%);
  border-color: transparent;
  min-height: 520px;
  padding:0;
}
.preview-inner{
  width:100%; height:100%;
  display:flex; align-items:center; justify-content:center;
  overflow:hidden;
}
.signature-base{ display:inline-block; transform-origin: top left; }
.preview-card{
  display:inline-block;
  background:#fff;
  border-radius:14px;
  box-shadow: 0 18px 60px rgba(0,0,0,.15);
  overflow:hidden;
  padding: 28px;
}
#signaturePreview{ display:block; line-height:0; }

/* Form */
.form{ padding:12px 0 0 0; }
.form-scrollguard{ display:grid; align-items:start; }
.grid-1{ display:grid; gap:12px; }
.grid-2{
  display:grid; grid-template-columns: 1fr 1fr; gap:12px; align-items: start;
}
.grid-2 > div{ min-width: 0; }

/* Align top Photo & Banner */
.grid-2 > div {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.row{ margin:0; }
label{ display:block; font-size:12px; color:#566F8F; margin:4px 0 6px }
input[type="text"], input[type="email"], input[type="url"], input[type="tel"], input[type="number"]{
  width:100%; height:40px; padding:8px 12px;
  border-radius:10px; border:1px solid var(--border);
  background:#fff; color:#17161B;
  outline:none; font-size:15px;
}

/* Social row */
.social-row{ display:grid; grid-template-columns: 1fr 1fr; gap:12px; }
.social-item{ display:flex; flex-direction:column; gap:8px; }
.social-head{
  display:flex; align-items:center; justify-content:space-between;
  min-height: 24px;
}
.social-head label{ margin:0; }

/* Placeholder for Photo (same height as toggle) */
.switch-placeholder {
  width: 28px;
  height: 14px;
  display: inline-block;
}

/* Toggle 32x16 */
.switch{
  --w: 28px; --h: 14px; --pad: 2px; --travel: calc(var(--w) - var(--h));
  position: relative; display: inline-block; width: var(--w); height: var(--h);
}
.switch input{ display:none; }
.slider{
  position: absolute; inset:0; cursor: pointer; border-radius: 100px;
  background: linear-gradient(45deg,#eaf0f6,#adadad);
  box-shadow: inset 0 1px 1px rgba(255,255,255,.80), inset 0 -1.5px 2px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.10);
  transition: background .2s ease, box-shadow .2s ease;
}
.switch input:checked + .slider{
  background: linear-gradient(45deg,#2f7dff,#1a56f5);
  box-shadow: inset 0 1px 1px rgba(255,255,255,.55), inset 0 -2px 3px rgba(0,0,0,.25), 0 2px 4px rgba(31,102,255,.30);
}
.slider::before{
  content:""; position:absolute; left: var(--pad); top: var(--pad);
  width: calc(var(--h) - var(--pad) * 2); height: calc(var(--h) - var(--pad) * 2);
  border-radius: 100px;
  background: radial-gradient(120% 120% at 30% 25%,#ffffff 0%,#eaf0f6 70%,#d3dbe6 100%);
  box-shadow: 0 1px 2px rgba(0,0,0,.20), inset 0 1px 0 rgba(255,255,255,.85), inset 0 -2px 4px rgba(0,0,0,.10);
  transition: transform .22s ease, background .2s ease, box-shadow .2s ease;
}
.switch:not(:has(input:checked)) .slider::before{ background: #585858; }
.switch input:checked + .slider::before{ transform: translateX(var(--travel)); }
.switch input:focus-visible + .slider{ outline: 2px solid #5b9dff; outline-offset: 2px; }

/* ===== Upload full-width + truncation + clear button ===== */
.file-input{
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 100%;
  margin-top: 6px; /* uniform margin top for both photo & banner */
}
.file-input input[type="file"]{ position:absolute; left:-9999px; }

.file-btn{
  flex: 1 1 auto;
  width: 100%;
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding-right: 44px;
  height:40px; line-height:24px;
  overflow: hidden;
}
.file-btn .file-label{
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: left;
}

.file-btn.used{
  background: #F2F7FF;
  border-color: var(--accent);
  color: #316bff;
}

.clear-btn{
  position:absolute; right:6px; top:50%; transform:translateY(-50%);
  width:14px; height:14px;
  display:none; align-items:center; justify-content:center;
  border:none; border-radius:999px;
  background:#566F8F;
  color:#fff;
  font-size:16px;
  line-height:1;
  cursor:pointer;
}

.file-input.has-file .clear-btn{ display: inline-flex; }

.clear-btn svg{
  width: 16px; height: 16px;
  stroke-linecap: round; stroke-linejoin: round;
  pointer-events: none;
}

.clear-btn:hover{ border-color: #d0d0d0; background-color: #213856; }

/* Error under input */
.input-error{
  margin:6px 0 0;
  font-size:12px;
  color:#D92D20;
}
.input-error[hidden] {
  display: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* ===== Spotlight (preview only) ===== */
.preview .preview-card { position: relative; }
.spotlight { position: absolute; border-radius: 10px; pointer-events: none; z-index: 5;
  box-shadow: 0 0 0 0 rgba(49,107,255,.20), 0 0 0 2px rgba(49,107,255,.85) inset; animation: haloPulse 900ms ease-out forwards; }
@keyframes haloPulse { 0%{ box-shadow: 0 0 0 0 rgba(49,107,255,.25), 0 0 0 2px rgba(49,107,255,.90) inset; opacity:1;}
  60%{ box-shadow: 0 0 0 12px rgba(49,107,255,.18), 0 0 0 2px rgba(49,107,255,.65) inset;}
  100%{ box-shadow:0 0 0 22px rgba(49,107,255,0), 0 0 0 2px rgba(49,107,255,0) inset; opacity:0;}}
.spotlight-tip{ position:absolute; top:-8px; left:0; transform:translateY(-100%); background:#111; color:#fff; font-size:12px; line-height:1; padding:6px 8px; border-radius:8px; white-space:nowrap; opacity:0; z-index:6; animation: tipFade 900ms ease-out forwards; }
.spotlight-tip::after{ content:""; position:absolute; left:10px; top:100%; border:6px solid transparent; border-top-color:#111; }
.spotlight-tip.below{ top:auto; bottom:-8px; transform:translateY(100%); }
.spotlight-tip.below::after{ top:auto; bottom:100%; border-top-color:transparent; border-bottom-color:#111; }

/* Copied animation */
#copyGmail { will-change: transform; }
.btn.is-copied, .btnprim.is-copied { border-color: var(--accent); background: #134CDD; color: #f2f7ff; }
.copied-anim { display: inline-flex; align-items: center; gap: 8px; line-height: 24px; animation: popIn 120ms ease-out forwards; }
.copied-anim svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 22; stroke-dashoffset: 22; animation: drawCheck 500ms ease forwards 60ms; }
@keyframes popIn { from { transform: scale(.96); opacity: .0; } to { transform: scale(1); opacity: 1; } }
@keyframes drawCheck { to { stroke-dashoffset: 0; } }

.site-badge { position: absolute; bottom: 20px; left: 20px; height: 70px; pointer-events: none; opacity: 1; }

/* Brand switch */
.brand-switch { position: fixed; bottom: 20px; right: 20px; z-index: 1000; background:#fff; border:1px solid var(--border); border-radius:14px; padding:4px; display:flex; gap:2px; align-items:center; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.brand-switch .seg{ appearance:none; border:0; background:#ffffff; cursor:pointer; width:36px; height:36px; border-radius:10px; display:grid; place-items:center; transition: box-shadow .2s ease, background .2s ease, transform .08s ease; }
.brand-switch .seg img{ display:block; width:24px; height:24px; }
.brand-switch .seg:is(:hover,:focus-visible){ outline:none; box-shadow:0 0 0 1px rgba(49,107,255,.22) inset; }
.brand-switch .seg.is-active{ background:#e3edfe; box-shadow: 0 0 0 1px rgba(212, 224, 255, 0.75) inset, 0 1px 4px rgba(0,0,0,.05); }
.brand-switch .seg:not(.is-active){ opacity: .3; }

/* Hide LinkedIn toggle (kept for structure) */
#linkedinToggle,
#linkedinToggle + .slider { display: none !important; }

/* Spacing between Banner title and button */
.grid-2 .social-head + .file-input { margin-top: 6px; }

/* ===== Gmail Tutorial Modal ===== */
.modal { position: fixed; inset: 0; display: none; z-index: 1000; }
.modal.is-open { display: block; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.modal__dialog {
  position: relative;
  max-width: 720px; width: calc(100% - 2rem);
  margin: 4vh auto; background: #fff; border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
  display: flex; flex-direction: column; max-height: 92vh;
}
.modal__header, .modal__footer { padding: 16px 20px; }
.modal__header { border-bottom: 1px solid var(--border); display:flex; align-items:center; gap:12px; }
.modal__header h2 { margin:0; font-size:18px; line-height:1.2; font-weight:700; flex:1; }
.modal__footer { border-top: 1px solid var(--border); }
.modal__body { padding: 16px 20px; overflow: auto; }
.modal__close {
  border: 0; background: transparent; font-size: 24px; line-height: 1;
  cursor: pointer; margin-left: auto; padding: 2px 6px;
}
.steps { display: grid; gap: 12px; padding-left: 1.2rem; }
.steps li { line-height: 1.5; }
.tip { margin-top: 12px; border: 1px solid #eee; border-radius: 10px; padding: 10px 12px; background: #fafafa; }
@media (max-width: 520px) { .modal__dialog { margin: 2vh auto; } }
.step-figure { margin: 10px 0 0; border: 1px solid var(--border); border-radius: 10px; padding: 8px; background: #fff; }
.step-figure img { display: block; width: 100%; height: auto; border-radius: 8px; }
.step-figure figcaption { font-size: 12px; color: #566F8F; margin-top: 6px; }
.specs { margin-top: 16px; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: #FAFAFA; }
.specs h3 { margin: 0 0 8px; font-size: 14px; }
.specs ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; }

/* ===== Image Cropper Modal (compact, clean z-index) ===== */
.cropper-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: none;
  align-items: center; justify-content: center;
  z-index: 9999; padding: 16px;
}
.cropper-modal[aria-hidden="false"] { display: flex; }

.cropper-dialog {
  background: #fff; color: #111;
  width: min(720px, 100%); max-height: 88vh;
  display: grid;
  /* header, preview, zoombar, toolbar */
  grid-template-rows: auto 1fr auto auto;
  border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
  overflow: hidden;
}

/* Header */
.cropper-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid #eee;
  position: relative; z-index: 3; /* au-dessus de l’overlay */
}
.cropper-header h2 { font-size: 14px; margin: 0; font-weight: 700; color:#213856; }
.cropper-close { border: 0; background: transparent; font-size: 20px; line-height: 1; cursor: pointer; }

/* Canvas area (square) — overlay confinée ici */
.cropper-canvas-wrap{
  position: relative;
  aspect-ratio: 1 / 1;
  width: 100%;
  background: #fff;
  overflow: hidden;              /* garde tout dans la zone blanche */
  z-index: 1;                    /* base */
}
.cropper-canvas-wrap canvas {
  width: 100%; height: 100%;
  display: block; background: #f0f0f0;
  position: relative; z-index: 1;
}

/* Overlay dans la zone blanche seulement */
.cropper-overlay{
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 2;                    /* au-dessus du canvas, sous header/toolbar */
}
.crop-box{
  position: absolute;
  border: 2px solid #fff;
  border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.65);
}

/* ===== Zoom bar (visible) ===== */
.cropper-zoombar{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-top: 1px solid #eee;
  background: #fff;
  position: relative;
  z-index: 3; /* au-dessus de l’overlay */
}
.cropper-zoombar label{
  font-size: 13px;
  color:#213856;
  white-space: nowrap;
}
.cropper-zoombar input[type="range"]{
  -webkit-appearance:none; appearance:none;
  width: 220px; height: 6px;
  padding:0; border-radius: 100px; border:0; background:#e9edf3;
}
.cropper-zoombar input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance:none; appearance:none;
  width:16px; height:16px; border-radius:50%;
  background:#316BFF; border:2px solid #fff; box-shadow:0 1px 2px rgba(0,0,0,.2);
}
.cropper-zoombar input[type="range"]::-moz-range-thumb{
  width:16px; height:16px; border-radius:50%;
  background:#316BFF; border:2px solid #fff;
}

/* Toolbar */
.cropper-toolbar {
  display: grid; gap: 10px;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  padding: 10px; border-top: 1px solid #eee; background:#fff;
  position: relative; z-index: 3; /* au-dessus de l’overlay */
}
.cropper-toolbar .group { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cropper-toolbar .inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color:#213856; }

.cropper-toolbar input[type="number"],
.cropper-toolbar select,
.cropper-toolbar input[type="range"]{
  height: 34px; border-radius: 8px; border: 1px solid #ddd;
  padding: 0 8px; background:#fff; color:#17161B;
}
.cropper-toolbar input[type="range"]{
  -webkit-appearance:none; appearance:none; width:180px; height: 6px;
  padding:0; border-radius: 100px; border:0; background:#e9edf3;
}
.cropper-toolbar input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance:none; appearance:none; width:16px; height:16px; border-radius:50%;
  background:#316BFF; border:2px solid #fff;
  box-shadow:0 1px 2px rgba(0,0,0,.2);
}

.cropper-zoombar input[type="range"]{
  width: 100% !important; /* override l'ancien 220px */
  min-width: 0;
  flex: 1 1 auto;
  -webkit-appearance: none;
  appearance: none;
}

.cropper-toolbar :is(button,select,input):focus {
  outline: 3px solid #00A2FF33; outline-offset: 2px;
}

