/* ── V18 Forms Frontend Styles ───────────────────────────
   Uses CSS variables from Theme v18 for native look.
   Falls back to hardcoded values if theme vars not present. */

:root {
    --v18f-navy:   var(--navy,   #0f1b2d);
    --v18f-amber:  var(--amber,  #f59e0b);
    --v18f-gray:   var(--gray-100, #f8fafc);
    --v18f-border: var(--gray-200, #e2e8f0);
    --v18f-text:   var(--gray-800, #1e293b);
    --v18f-muted:  var(--gray-500, #64748b);
    --v18f-font:   var(--font, 'Plus Jakarta Sans', sans-serif);
    --v18f-radius: 8px;
}

.v18f-wrap { max-width: 680px; }

/* ── Notices ── */
.v18f-notice {
    padding: 14px 18px;
    border-radius: var(--v18f-radius);
    margin-bottom: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.5;
}
.v18f-notice--success {
    background: #f0fdf4;
    border: 1.5px solid #bbf7d0;
    color: #166534;
}
.v18f-notice--error {
    background: #fef2f2;
    border: 1.5px solid #fecaca;
    color: #991b1b;
}

/* ── Fields ── */
.v18f-field { margin-bottom: 20px; }

.v18f-label {
    display: block;
    font-family: var(--v18f-font);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--v18f-navy);
    margin-bottom: 6px;
}
.v18f-required { color: #dc2626; margin-left: 2px; }

.v18f-input {
    display: block;
    width: 100%;
    padding: 10px 14px;
    font-family: var(--v18f-font);
    font-size: 0.93rem;
    color: var(--v18f-text);
    background: #fff;
    border: 1.5px solid var(--v18f-border);
    border-radius: var(--v18f-radius);
    outline: none;
    transition: border-color .18s, box-shadow .18s;
    box-sizing: border-box;
    -webkit-appearance: none;
}
.v18f-input:focus {
    border-color: var(--v18f-navy);
    box-shadow: 0 0 0 3px rgba(15,27,45,.1);
}
.v18f-input.v18f-invalid {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220,38,38,.1);
}
textarea.v18f-input { resize: vertical; min-height: 100px; }
select.v18f-input { 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 d='M1 1l5 5 5-5' stroke='%230f1b2d' stroke-width='1.5' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; cursor: pointer; }

/* ── Radio & Checkbox ── */
.v18f-radio-group { display: flex; flex-direction: column; gap: 8px; }
.v18f-radio-label,
.v18f-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.93rem;
    color: var(--v18f-text);
    cursor: pointer;
}
.v18f-radio-label input,
.v18f-checkbox-label input { width: 16px; height: 16px; accent-color: var(--v18f-navy); cursor: pointer; }

/* ── File upload ── */
.v18f-file-wrap { position: relative; }
.v18f-file-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}
.v18f-file-ui {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 1.5px dashed var(--v18f-border);
    border-radius: var(--v18f-radius);
    background: var(--v18f-gray);
    cursor: pointer;
    transition: border-color .18s, background .18s;
}
.v18f-file-wrap:hover .v18f-file-ui {
    border-color: var(--v18f-navy);
    background: #f0f4f8;
}
.v18f-file-icon  { font-size: 1.3rem; }
.v18f-file-text  { font-size: 0.9rem; font-weight: 600; color: var(--v18f-navy); }
.v18f-file-hint  { font-size: 0.78rem; color: var(--v18f-muted); margin-left: auto; }
.v18f-file-name  { display: block; margin-top: 6px; font-size: 0.82rem; color: var(--v18f-muted); word-break: break-all; }

/* ── Submit button ── */
.v18f-submit-row { margin-top: 24px; }
.v18f-btn--submit {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    background: var(--v18f-navy);
    color: #fff;
    font-family: var(--v18f-font);
    font-size: 0.93rem;
    font-weight: 700;
    border: none;
    border-radius: var(--v18f-radius);
    cursor: pointer;
    transition: background .18s, transform .12s;
}
.v18f-btn--submit:hover   { background: #1a3a5c; }
.v18f-btn--submit:active  { transform: scale(.98); }
.v18f-btn--submit:disabled { opacity: .6; cursor: not-allowed; }

@media (max-width: 600px) {
    .v18f-btn--submit { width: 100%; justify-content: center; }
}


/* ══════════════════════════════════════════════════
   Modal overlay
   ══════════════════════════════════════════════════ */
body.v18f-no-scroll { overflow: hidden; }

.v18f-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.v18f-modal {
    background: #fff;
    border-radius: 14px;
    padding: 32px 28px 24px;
    max-width: 480px;
    width: 100%;
    text-align: center;
    box-shadow: 0 24px 64px rgba(0,0,0,.22);
    animation: v18f-modal-in .2s ease;
}

@keyframes v18f-modal-in {
    from { opacity: 0; transform: scale(.92) translateY(-12px); }
    to   { opacity: 1; transform: scale(1)  translateY(0); }
}

.v18f-modal-icon {
    font-size: 2.8rem;
    line-height: 1;
    margin-bottom: 14px;
}

.v18f-modal-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--v18f-navy, #0f1b2d);
    margin: 0 0 12px;
}

.v18f-modal-body {
    font-size: 0.9rem;
    color: #475569;
    line-height: 1.65;
    margin-bottom: 24px;
    text-align: left;
}

/* Success modal accent */
.v18f-modal--success .v18f-modal-title { color: #166534; }
.v18f-modal--success .v18f-modal-close {
    background: #0f1b2d;
    color: #fff;
}
.v18f-modal--success .v18f-modal-close:hover { background: #1a3a5c; }

/* Error modal accent */
.v18f-modal--error .v18f-modal-title { color: #991b1b; }
.v18f-modal--error .v18f-modal-close {
    background: #dc2626;
    color: #fff;
}
.v18f-modal--error .v18f-modal-close:hover { background: #b91c1c; }

/* Warning modal accent */
.v18f-modal--warning .v18f-modal-title { color: #92400e; }
.v18f-modal--warning .v18f-modal-close,
.v18f-close--warning {
    background: var(--v18f-amber, #f59e0b);
    color: #0f1b2d;
}
.v18f-close--success { background: #0f1b2d; color: #fff; }
.v18f-close--success:hover { background: #1a3a5c; }
.v18f-close--error   { background: #dc2626; color: #fff; }
.v18f-close--error:hover   { background: #b91c1c; }
.v18f-close--warning:hover { background: #d97706; }

.v18f-modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 28px;
    border-radius: 8px;
    font-family: var(--v18f-font);
    font-size: 0.9rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: background .18s;
    min-width: 120px;
}

/* Error list inside modal */
.v18f-error-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.v18f-error-list li {
    padding: 7px 0 7px 20px;
    border-bottom: 1px solid #fee2e2;
    position: relative;
    font-size: 0.88rem;
    color: #7f1d1d;
}
.v18f-error-list li:last-child { border-bottom: none; }
.v18f-error-list li::before {
    content: "•";
    position: absolute;
    left: 6px;
    color: #dc2626;
    font-weight: 700;
}

/* ══════════════════════════════════════════════════
   Character counter
   ══════════════════════════════════════════════════ */
.v18f-char-counter {
    text-align: right;
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
    transition: color .18s;
}
.v18f-counter--warn { color: #d97706; font-weight: 600; }
.v18f-counter--over { color: #dc2626; font-weight: 700; }
.v18f-counter--over + input,
.v18f-counter--over + textarea,
input:has(+ .v18f-counter--over),
textarea:has(+ .v18f-counter--over) {
    border-color: #dc2626;
}

@media (max-width: 480px) {
    .v18f-modal { padding: 24px 18px 20px; border-radius: 10px; }
}
