/* Générateur de signature Joya - bleu marine charte #131D30 */

:root {
  --navy: #131d30;
  --navy-light: #1f2d47;
  --bg: #f4f5f7;
  --card: #ffffff;
  --border: #e2e5ea;
  --text: #1a1a1a;
  --muted: #6b7280;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---------- En-tête ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 28px;
  background: var(--navy);
  color: #fff;
}
.topbar-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  background: #fff;
  border-radius: 10px;
  padding: 5px;
}
.topbar h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
}
.topbar p {
  margin: 2px 0 0;
  font-size: 13px;
  opacity: 0.75;
}
.logout {
  margin-left: auto;
  color: #fff;
  opacity: 0.7;
  font-size: 13px;
  text-decoration: none;
}
.logout:hover {
  opacity: 1;
}

/* ---------- Mise en page ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(320px, 460px) minmax(400px, 620px);
  gap: 24px;
  padding: 28px;
  max-width: 1180px;
  margin: 0 auto;
  align-items: start;
}
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(19, 29, 48, 0.06);
}
.card h2 {
  margin: 0 0 18px;
  font-size: 16px;
  color: var(--navy);
}

/* ---------- Formulaire ---------- */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 520px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.field label,
.field .label {
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
}
.req {
  color: #c0392b;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
select,
textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--navy);
  outline-offset: -1px;
}

input[type="file"] {
  display: none;
}
.file-label {
  display: inline-block;
  padding: 9px 12px;
  border: 1px dashed var(--navy);
  border-radius: 8px;
  color: var(--navy);
  font-size: 14px;
  cursor: pointer;
  text-align: center;
}
.file-label:hover {
  background: #eef1f6;
}

.hint {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0 0;
}

.agences {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.agence {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.agence input {
  display: none;
}
.agence.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ---------- Boutons ---------- */
.btn {
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover {
  background: var(--navy-light);
}
.btn-ghost {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: #eef1f6;
}
.btn-copy {
  margin-top: 16px;
}

/* ---------- Aperçu ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab {
  padding: 8px 16px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab.active {
  color: var(--navy);
  border-bottom-color: var(--navy);
}

.pane {
  display: none;
}
.pane.active {
  display: block;
}

.sig-wrap {
  overflow-x: auto;
  padding: 8px 0;
}

#html-output {
  width: 100%;
  font-family: monospace;
  font-size: 12px;
  resize: vertical;
}

/* ---------- Modal recadrage ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(19, 29, 48, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal[hidden] {
  display: none;
}
.modal-content {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  max-width: 640px;
  width: calc(100% - 32px);
}
.img-container {
  position: relative;
  height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  border-radius: 8px;
  overflow: hidden;
}
#img-full {
  max-width: 100%;
  max-height: 100%;
  display: block;
}
.cadre {
  position: absolute;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
  cursor: move;
  touch-action: none;
}
.zoom-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
}
.zoom-row input[type="range"] {
  flex: 1;
  accent-color: var(--navy);
}
.modal-footer {
  display: flex;
  justify-content: space-between;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  z-index: 60;
}

/* ---------- Page de connexion ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--navy);
}
.login-card {
  background: #fff;
  border-radius: 14px;
  padding: 36px;
  width: 360px;
  text-align: center;
}
.login-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
}
.login-card h1 {
  font-size: 20px;
  color: var(--navy);
  margin: 14px 0 6px;
}
.login-sub {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 20px;
}
.login-card input {
  width: 100%;
  margin-bottom: 12px;
}
.login-card button {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.login-error {
  color: #c0392b;
  font-size: 13px;
  margin: 0 0 10px;
}
