/* ── DigiGo public pages (form + OTP) ─────────────────────────────────────
   Design tokens aligned with the backoffice design system
   (call_center/static/css/dashboard_base.css, profile.css), scaled up for a
   public, non-technical audience: bigger type, bigger touch targets. */

:root {
    --dg-navy: #1e3a5c;
    --dg-navy-dark: #16293f;
    --dg-orange: #eb654a;       /* Flouci brand orange — buttons / accents */
    --dg-orange-dark: #cf5941;  /* darker shade for hover/active */
    --dg-ink: #333;
    --dg-body: #495057;
    --dg-muted: #868e96;
    --dg-line: #dee2e6;
    --dg-line-soft: #f0f0f0;
    --dg-bg: #f4f6f9;
    --dg-card: #fff;
    --dg-green: #2f9e44;
    --dg-green-bg: #d4edda;
    --dg-green-ink: #155724;
    --dg-red: #dc3545;
    --dg-red-bg: #f8d7da;
    --dg-red-ink: #721c24;
    --dg-blue-bg: #cce5ff;
    --dg-blue-ink: #004085;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--dg-bg);
    color: var(--dg-body);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.55;
}

.dg-page {
    max-width: 860px;
    margin: 0 auto;
    padding: 28px 16px 48px;
}
.dg-page--narrow { max-width: 600px; }
.dg-page--call { max-width: 760px; }

/* ── Brand header ── */
.dg-brand {
    text-align: center;
    margin-bottom: 22px;
}
.dg-brand img {
    max-width: 210px;
    height: auto;
}
.dg-brand-partner {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--dg-muted);
}
.dg-brand-partner strong { color: var(--dg-body); font-weight: 600; }

.dg-title {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dg-navy);
    margin: 0 0 6px;
}
.dg-subtitle {
    text-align: center;
    font-size: 0.95rem;
    color: var(--dg-body);
    margin: 0 auto 26px;
    max-width: 560px;
}

/* ── Stepper ── */
.dg-stepper {
    display: flex;
    justify-content: center;
    margin: 0 auto 30px;
    padding: 0;
    list-style: none;
    max-width: 640px;
}
.dg-step {
    flex: 1;
    text-align: center;
    position: relative;
    min-width: 0;
}
.dg-step::before {
    content: "";
    position: absolute;
    top: 15px;
    left: -50%;
    width: 100%;
    height: 2px;
    background: var(--dg-line);
}
.dg-step:first-child::before { display: none; }
.dg-step-dot {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--dg-line);
    color: var(--dg-muted);
    font-size: 0.82rem;
    font-weight: 700;
}
.dg-step-label {
    display: block;
    margin-top: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--dg-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.dg-step.is-active .dg-step-dot {
    background: var(--dg-navy);
    border-color: var(--dg-navy);
    color: #fff;
}
.dg-step.is-active .dg-step-label { color: var(--dg-navy); }
.dg-step.is-done .dg-step-dot {
    background: var(--dg-green);
    border-color: var(--dg-green);
    color: #fff;
}
.dg-step.is-done::before { background: var(--dg-green); }
.dg-step.is-done .dg-step-label { color: var(--dg-green); }

/* ── Cards ── */
.dg-card {
    background: var(--dg-card);
    border: 1px solid var(--dg-line);
    border-radius: 10px;
    padding: 22px 24px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    margin-bottom: 16px;
}
.dg-card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--dg-ink);
    margin: 0 0 4px;
}
.dg-card-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--dg-navy);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}
.dg-card-hint {
    font-size: 0.82rem;
    color: var(--dg-muted);
    margin: 0 0 16px;
}

/* ── Checklist (“avant de commencer”) ── */
.dg-checklist {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 18px;
}
.dg-checklist li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.88rem;
    color: var(--dg-body);
}
.dg-checklist li::before {
    content: "✓";
    color: var(--dg-green);
    font-weight: 700;
    flex-shrink: 0;
}
.dg-chip {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 8px;
    background: #f0f4f8;
    color: var(--dg-body);
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

/* ── Form grid & fields ── */
.dg-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 20px;
}
.dg-field { display: flex; flex-direction: column; min-width: 0; }
.dg-field--full { grid-column: 1 / -1; }
/* Bottom-align controls within a row so a taller (two-line) label — e.g. one
   carrying a <small> subtitle like "Identifiant / Matricule fiscal" — doesn't
   push its control out of line with the single-line-label field beside it.
   Grid rows stretch to equal height; `margin-top: auto` then drops each
   control to a shared baseline. `.iti` covers the intl-tel-input-wrapped phone
   field, which is no longer a direct .dg-input child once initialised. */
.dg-field > .dg-input,
.dg-field > .dg-select,
.dg-field > .iti,
.dg-field > .dg-file-box {
    margin-top: auto;
}
.dg-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--dg-body);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 5px;
}
.dg-label small {
    display: block;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    color: var(--dg-muted);
}
.dg-input,
.dg-select {
    width: 100%;
    font-size: 1rem;
    color: var(--dg-ink);
    padding: 11px 13px;
    border: 1px solid var(--dg-line);
    border-radius: 8px;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: none;
    -webkit-appearance: none;
}
.dg-select {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23868e96' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
    padding-right: 36px;
}
.dg-input:focus,
.dg-select:focus {
    outline: none;
    border-color: var(--dg-orange);
    box-shadow: 0 0 0 3px rgba(235, 101, 74, 0.15);
}
.dg-input::placeholder { color: #adb5bd; }

/* intl-tel-input wrapper must stretch */
.dg-field .iti { width: 100%; }

/* ── File inputs ── */
.dg-file input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
}
.dg-file-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 14px;
    border: 1.5px dashed var(--dg-line);
    border-radius: 8px;
    background: #fafbfc;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.dg-file-box:hover { border-color: var(--dg-orange); background: #fff; }
.dg-file.has-file .dg-file-box {
    border-style: solid;
    border-color: var(--dg-green);
    background: #f4fbf5;
}
.dg-file.has-error .dg-file-box {
    border-style: solid;
    border-color: var(--dg-red);
    background: #fdf5f5;
}
.dg-file-icon {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: #f0f4f8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}
.dg-file.has-file .dg-file-icon { background: var(--dg-green-bg); }
.dg-file-text { min-width: 0; }
.dg-file-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--dg-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dg-file-hint { font-size: 0.75rem; color: var(--dg-muted); }
.dg-file-error {
    display: none;
    font-size: 0.78rem;
    color: var(--dg-red);
    font-weight: 600;
    margin-top: 5px;
}
.dg-file.has-error .dg-file-error { display: block; }

/* ── Legal representative toggle ── */
.dg-toggle-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 16px;
    border: 1px solid var(--dg-line);
    border-radius: 8px;
    background: #fafbfc;
    cursor: pointer;
    margin-bottom: 16px;
    user-select: none;
}
.dg-toggle-row:hover { background: #f0f4f8; }
.dg-toggle-row input[type="checkbox"] {
    appearance: checkbox;
    -webkit-appearance: checkbox;
    width: 20px;
    height: 20px;
    accent-color: var(--dg-navy);
    flex-shrink: 0;
    margin: 0;
    cursor: pointer;
}
.dg-toggle-row span { font-size: 0.92rem; font-weight: 600; color: var(--dg-ink); }
.dg-toggle-row small { display: block; font-weight: 400; color: var(--dg-muted); font-size: 0.78rem; }

/* ── Consent ── */
.dg-consent-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--dg-line);
    border-radius: 8px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    user-select: none;
}
.dg-consent-row:hover { background: #fafbfc; }
.dg-consent-row.is-checked { border-color: var(--dg-green); background: #f4fbf5; }
.dg-consent-row input[type="checkbox"] {
    appearance: checkbox;
    -webkit-appearance: checkbox;
    width: 20px;
    height: 20px;
    accent-color: var(--dg-green);
    flex-shrink: 0;
    margin: 2px 0 0;
    cursor: pointer;
}
.dg-consent-row span { font-size: 0.88rem; color: var(--dg-body); }
.dg-consent-row a { color: var(--dg-navy); font-weight: 600; text-decoration: underline; }
.dg-consent-row a:hover { color: var(--dg-navy-dark); }
.dg-consent-docs {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    background: #f0f4f8;
    font-size: 0.8rem;
    color: var(--dg-body);
}
.dg-consent-docs a { color: var(--dg-navy); font-weight: 600; }

/* ── Alerts ── */
.dg-alert {
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 500;
    margin-bottom: 16px;
    text-align: center;
}
.dg-alert--danger { background: var(--dg-red-bg); color: var(--dg-red-ink); border: 1px solid #f5c6cb; }
.dg-alert--info { background: var(--dg-blue-bg); color: var(--dg-blue-ink); border: 1px solid #b8daff; }
.dg-alert--success { background: var(--dg-green-bg); color: var(--dg-green-ink); border: 1px solid #c3e6cb; }

/* ── CTA ── */
.dg-actions { text-align: center; margin-top: 6px; }
.dg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 260px;
    padding: 14px 34px;
    font-size: 1.02rem;
    font-weight: 700;
    color: #fff;
    background: var(--dg-orange);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s, opacity 0.15s;
    box-shadow: 0 3px 8px rgba(235, 101, 74, 0.3);
}
.dg-btn:hover:not(:disabled) { background: var(--dg-orange-dark); }
.dg-btn:active:not(:disabled) { transform: translateY(1px); }
.dg-btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.dg-btn .dg-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255, 255, 255, 0.45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: dg-spin 0.7s linear infinite;
}
.dg-btn.is-loading .dg-spinner { display: inline-block; }
@keyframes dg-spin { to { transform: rotate(360deg); } }
.dg-secure-note {
    margin-top: 12px;
    font-size: 0.78rem;
    color: var(--dg-muted);
}
.dg-cta-hint {
    margin: 0 0 10px;
    font-size: 0.82rem;
    color: var(--dg-muted);
}

/* ── OTP page ── */
/* Stack + centre each field explicitly: the label is a <label> (inline by
   default) carrying a display:block <small>, and the input has a max-width — a
   flex column with centred items keeps label, hint and input on one shared
   vertical axis regardless of which channel is already verified. */
.dg-otp-field {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 18px;
}
.dg-otp-field .dg-label {
    text-align: center;
    margin-bottom: 8px;
}
.dg-otp-input {
    display: block;
    width: 100%;
    max-width: 260px;
    margin: 0 auto;
    font-size: 1.5rem;
    letter-spacing: 0.45em;
    text-align: center;
    padding: 12px 8px 12px calc(8px + 0.45em);
    border: 1px solid var(--dg-line);
    border-radius: 10px;
    color: var(--dg-ink);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.dg-otp-input:focus {
    outline: none;
    border-color: var(--dg-orange);
    box-shadow: 0 0 0 3px rgba(235, 101, 74, 0.15);
}
.dg-verified-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: 10px;
    background: var(--dg-green-bg);
    color: var(--dg-green-ink);
    font-size: 0.9rem;
    font-weight: 600;
}

/* ── Success panel ── */
.dg-success-icon {
    width: 64px;
    height: 64px;
    margin: 4px auto 14px;
    border-radius: 50%;
    background: var(--dg-green-bg);
    color: var(--dg-green);
    font-size: 2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dg-next-steps {
    list-style: none;
    margin: 16px 0 0;
    padding: 0;
    text-align: left;
}
.dg-next-steps li {
    display: flex;
    gap: 12px;
    padding: 9px 0;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--dg-line-soft);
}
.dg-next-steps li:last-child { border-bottom: none; }
.dg-next-steps .dg-card-num { background: #f0f4f8; color: var(--dg-body); }

/* ── Footer ── */
.dg-footer {
    margin-top: 26px;
    text-align: center;
    font-size: 0.78rem;
    color: var(--dg-muted);
    border-top: 1px solid var(--dg-line);
    padding-top: 18px;
}
.dg-footer a { color: var(--dg-navy); font-weight: 600; text-decoration: none; }
.dg-footer a:hover { text-decoration: underline; }
.dg-footer-links { margin-top: 6px; }
.dg-footer-links a { margin: 0 8px; font-weight: 500; }

/* ── Responsive ── */
@media (max-width: 700px) {
    .dg-grid, .dg-checklist { grid-template-columns: 1fr; }
    .dg-card { padding: 18px 16px; }
    .dg-btn { width: 100%; min-width: 0; }
    .dg-step-label { font-size: 0.62rem; }
}
@media (prefers-reduced-motion: reduce) {
    .dg-btn .dg-spinner { animation-duration: 1.5s; }
    .dg-btn, .dg-input, .dg-select, .dg-file-box, .dg-consent-row { transition: none; }
}

/* ── Live video call (client join page) — the client's OWN camera is the main view;
   the conseiller shows in a small corner PiP, since the client holds up documents
   and follows along on the large view. ── */
.dg-call-stage { position: relative; }
.dg-call-main {
    width: 100%;
    min-height: 440px;
    background: #1a1e22;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}
.dg-call-pip {
    position: absolute;
    right: 12px;
    bottom: 12px;
    width: 180px;
    height: 135px;
    background: #23272b;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
    z-index: 2;
}
.dg-call-main video,
.dg-call-pip video { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
/* Client's own view: show the whole frame so documents aren't cropped, and don't
   mirror it so text reads the right way round. The agent PiP just fills its box. */
.dg-call-main video { object-fit: contain; }
.dg-call-pip video { object-fit: cover; }
.dg-call-hint { color: #adb5bd; font-size: 0.8rem; text-align: center; padding: 12px 8px; }
@media (max-width: 520px) {
    .dg-call-main { min-height: 360px; }
    .dg-call-pip { width: 120px; height: 90px; right: 8px; bottom: 8px; }
}
/* ── Resume code box (payment page + confirmation) ── */
.dg-resume-box { margin: 18px auto 0; max-width: 340px; padding: 14px 16px; border: 1px dashed #c9d4e0; border-radius: 12px; background: #f6f9fc; }
.dg-resume-label { font-size: 0.78rem; color: #5b6b7c; margin: 0 0 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.dg-resume-code { font-size: 1.6rem; font-weight: 700; letter-spacing: 4px; color: #1e3a5c; margin: 0 0 6px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.dg-resume-hint { font-size: 0.8rem; color: #5b6b7c; margin: 0; }

/* ── Amount due (payment page) ── */
.dg-amount { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: 4px; }
.dg-amount-label { font-size: 0.82rem; color: #5b6b7c; text-transform: uppercase; letter-spacing: 0.5px; }
.dg-amount-value { font-size: 2.2rem; font-weight: 700; color: #1e3a5c; letter-spacing: 1px; }
