/* =====================================================================
   CENTRAL DE DENÚNCIAS — JAIME ADMINISTRAÇÃO
   Design system institucional. Paleta baseada na marca (laranja + grafite).
   ===================================================================== */

/* ===== DESIGN TOKENS ===== */
:root {
    --brand:        #E57B23;
    --brand-dark:   #CD5700;
    --brand-soft:   #FEF3E7;   /* laranja bem claro para fundos/realces */
    --brand-ring:   rgba(229, 123, 35, 0.18);

    --ink:          #0F172A;   /* títulos */
    --text:         #1E293B;   /* corpo */
    --muted:        #64748B;   /* secundário */
    --faint:        #94A3B8;   /* rodapé / dicas */

    --line:         #E2E8F0;
    --field-bg:     #F8FAFC;
    --card:         #FFFFFF;

    --success:      #16A34A;
    --danger:       #DC2626;

    --radius:       16px;
    --radius-sm:    10px;
    --shadow:       0 18px 45px -20px rgba(15, 23, 42, 0.35);
    --shadow-btn:   0 12px 24px -8px rgba(205, 87, 0, 0.55);
}

/* ===== RESET ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text);
    background:
        radial-gradient(1200px 600px at 100% -10%, var(--brand-soft), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, #EEF2F7, transparent 55%),
        #F0F4F8;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* ===== CONTAINER ===== */
.form-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: clamp(24px, 5vw, 56px) 20px;
}

/* ===== CARD ===== */
.form-card {
    position: relative;
    background-color: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: clamp(28px, 5vw, 48px) clamp(22px, 4vw, 44px);
    max-width: 620px;
    width: 100%;
    overflow: hidden;
    animation: fadeIn 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Barra de acento no topo do card */
.form-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(90deg, var(--brand), var(--brand-dark));
}

/* ===== MARCA (logo institucional) ===== */
.brand-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    margin-bottom: 28px;
}

.brand-bar img {
    height: 34px;
    width: auto;
}

/* ===== CABEÇALHO ===== */
.form-header {
    text-align: center;
    margin-bottom: 28px;
}

.form-icon-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 76px;
    height: 76px;
    margin-bottom: 16px;
    border-radius: 50%;
    background: var(--brand-soft);
    box-shadow: 0 0 0 8px rgba(229, 123, 35, 0.06);
}

.form-header img.form-icon {
    width: 42px;
    height: auto;
}

.form-header h1 {
    font-size: clamp(1.4rem, 3.5vw, 1.85rem);
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.02em;
    color: var(--ink);
    margin: 0 0 10px;
}

.form-subtitle {
    color: var(--muted);
    font-size: 0.97rem;
    line-height: 1.5;
    margin: 0;
    max-width: 44ch;
    margin-inline: auto;
}

/* ===== AVISO DE SIGILO ===== */
.privacy-note {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--brand-soft);
    border: 1px solid rgba(229, 123, 35, 0.22);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-bottom: 30px;
    font-size: 0.88rem;
    line-height: 1.5;
    color: #7C4A12;
}

.privacy-note svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 1px;
    color: var(--brand-dark);
}

.privacy-note strong {
    color: #6B3F0E;
}

/* ===== GRUPOS DE CAMPOS ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 7px;
    font-weight: 600;
    color: #334155;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.form-group label .req {
    color: var(--danger);
    margin-left: 2px;
    font-weight: 700;
}

.form-group label .opt {
    color: var(--faint);
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.75rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    display: block;
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid #CBD5E1;
    background-color: var(--field-bg);
    color: var(--text);
    font-family: inherit;
    font-size: 0.98rem;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #A3B0C2;
}

/* ===== FOCO (na cor da marca) ===== */
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--brand);
    background-color: #fff;
    box-shadow: 0 0 0 4px var(--brand-ring);
    outline: none;
}

/* ===== SELECT com seta personalizada ===== */
.form-group select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 42px;
    cursor: pointer;
}

/* ===== TEXTAREA ===== */
.form-group textarea {
    resize: vertical;
    min-height: 130px;
    line-height: 1.55;
}

/* ===== DATA (Flatpickr) ===== */
.form-group input#data {
    cursor: pointer;
}

/* ===== CAMPOS COM ÍCONE ===== */
.input-wrap {
    position: relative;
}

.input-wrap .field-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--faint);
    pointer-events: none;
    transition: color 0.2s;
}

.input-wrap input,
.input-wrap select {
    padding-left: 44px;
}

.input-wrap:focus-within .field-icon {
    color: var(--brand);
}

/* ===== UPLOAD DE ARQUIVO (DRAG & DROP) ===== */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    padding: 26px 20px;
    cursor: pointer;
    background: var(--field-bg);
    border: 1.5px dashed #CBD5E1;
    border-radius: var(--radius-sm);
    color: var(--muted);
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.dropzone:hover {
    border-color: var(--brand);
    background: var(--brand-soft);
}

.dropzone.is-dragover {
    border-color: var(--brand);
    background: var(--brand-soft);
    transform: scale(1.01);
}

.dropzone .dz-icon {
    width: 32px;
    height: 32px;
    color: var(--brand);
}

.dropzone p {
    margin: 0;
    font-size: 0.9rem;
}

.dropzone p strong {
    color: var(--brand-dark);
    font-weight: 600;
}

.upload-hint {
    display: block;
    color: var(--faint);
    font-size: 0.78rem;
}

/* Chip do arquivo selecionado */
.file-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 10px 12px;
    background: var(--brand-soft);
    border: 1px solid rgba(229, 123, 35, 0.25);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    color: var(--text);
}

.file-chip[hidden] {
    display: none;
}

.file-chip .fc-icon {
    width: 18px;
    height: 18px;
    color: var(--brand-dark);
    flex-shrink: 0;
}

.file-chip .fc-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-chip .fc-size {
    flex-shrink: 0;
    color: var(--muted);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    background: rgba(229, 123, 35, 0.12);
    padding: 2px 8px;
    border-radius: 999px;
}

.file-chip .fc-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s, color 0.2s;
}

.file-chip .fc-remove:hover {
    background: rgba(220, 38, 38, 0.12);
    color: var(--danger);
}

.file-chip .fc-remove svg {
    width: 14px;
    height: 14px;
}

/* ===== CAMPO CONDICIONAL (e-mail / telefone) ===== */
.conditional-field[hidden] {
    display: none;
}

.conditional-field {
    animation: fieldReveal 0.28s ease-out;
}

@keyframes fieldReveal {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .conditional-field {
        animation: none;
    }
}

/* ===== MENSAGEM DE ERRO DO ANEXO ===== */
.file-error {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-top: 9px;
    color: var(--danger);
    font-size: 0.82rem;
    line-height: 1.45;
}

.file-error[hidden] {
    display: none;
}

/* ===== CONTADOR DE CARACTERES ===== */
.char-counter {
    display: block;
    text-align: right;
    margin-top: 6px;
    font-size: 0.78rem;
    color: var(--faint);
    font-variant-numeric: tabular-nums;
}

/* ===== BOTÃO DE ENVIO ===== */
.submit-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(90deg, var(--brand), var(--brand-dark));
    color: #fff;
    border: none;
    padding: 15px;
    width: 100%;
    margin-top: 6px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    box-shadow: var(--shadow-btn);
    transition: transform 0.18s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.submit-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 30px -10px rgba(205, 87, 0, 0.6);
    filter: saturate(1.05);
}

.submit-button:active {
    transform: translateY(0);
}

.submit-button svg {
    width: 18px;
    height: 18px;
}

/* Estado de envio */
.submit-button.is-loading {
    pointer-events: none;
    opacity: 0.85;
}

.submit-button .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: spin 0.7s linear infinite;
}

/* No envio: mostra o spinner e esconde o ícone (sem mexer no DOM via JS) */
.submit-button.is-loading .spinner {
    display: inline-block;
}

.submit-button.is-loading svg {
    display: none;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== FOCO VISÍVEL (acessibilidade por teclado) ===== */
.submit-button:focus-visible,
.btn-back:focus-visible,
.dropzone:focus-visible {
    outline: 3px solid var(--brand-ring);
    outline-offset: 2px;
}

/* ===== RODAPÉ ===== */
footer {
    text-align: center;
    margin-top: 26px;
    font-size: 0.82rem;
    color: var(--faint);
    line-height: 1.6;
}

footer p {
    margin: 2px 0;
}

/* ===== TELA DE RESULTADO (envio.php) ===== */
.result-card {
    text-align: center;
}

.result-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 84px;
    height: 84px;
    border-radius: 50%;
    margin-bottom: 22px;
}

.result-icon.success {
    background: #DCFCE7;
    color: var(--success);
    box-shadow: 0 0 0 8px rgba(22, 163, 74, 0.08);
}

.result-icon.error {
    background: #FEE2E2;
    color: var(--danger);
    box-shadow: 0 0 0 8px rgba(220, 38, 38, 0.08);
}

.result-icon svg {
    width: 44px;
    height: 44px;
}

.result-card h1 {
    font-size: clamp(1.4rem, 3.5vw, 1.75rem);
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 12px;
    letter-spacing: -0.02em;
}

.result-card p {
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.6;
    margin: 0 auto 28px;
    max-width: 42ch;
}

.result-error-detail {
    background: var(--field-bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 0.82rem;
    color: var(--muted);
    word-break: break-word;
    margin-bottom: 24px;
}

/* Protocolo do registro */
.result-protocol {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
    background: var(--brand-soft);
    border: 1px solid rgba(229, 123, 35, 0.25);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 28px;
}

.result-protocol .rp-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
    color: var(--brand-dark);
}

.result-protocol .rp-code {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.result-protocol .rp-date {
    font-size: 0.8rem;
    color: var(--muted);
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(90deg, var(--brand), var(--brand-dark));
    color: #fff;
    text-decoration: none;
    padding: 13px 30px;
    font-weight: 700;
    font-size: 0.92rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-btn);
    transition: transform 0.18s ease, box-shadow 0.2s ease;
}

.btn-back:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 30px -10px rgba(205, 87, 0, 0.6);
}

.btn-back svg {
    width: 16px;
    height: 16px;
}

/* ===== ANIMAÇÃO ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(14px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .form-card {
        animation: none;
    }

    .submit-button,
    .custom-file-upload,
    .btn-back {
        transition: none;
    }
}

/* ===== RESPONSIVIDADE ===== */
@media (max-width: 600px) {
    .form-subtitle {
        font-size: 0.92rem;
    }
}

/* ===== MODO ESCURO ===== */
@media (prefers-color-scheme: dark) {
    :root {
        --brand-soft:  rgba(229, 123, 35, 0.14);
        --brand-ring:  rgba(229, 123, 35, 0.30);

        --ink:    #F1F5F9;
        --text:   #E2E8F0;
        --muted:  #94A3B8;
        --faint:  #64748B;

        --line:     #2A3648;
        --field-bg: #1B2432;
        --card:     #141C29;
        --shadow:   0 22px 55px -22px rgba(0, 0, 0, 0.7);
    }

    body {
        background:
            radial-gradient(1200px 600px at 100% -10%, rgba(229, 123, 35, 0.10), transparent 60%),
            radial-gradient(900px 500px at -10% 110%, rgba(51, 65, 85, 0.35), transparent 55%),
            #0B1220;
    }

    .form-group input,
    .form-group textarea,
    .form-group select {
        border-color: #33415580;
    }

    .form-group input:focus,
    .form-group textarea:focus,
    .form-group select:focus {
        background-color: #1F2937;
    }

    .form-group select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    }

    .privacy-note {
        color: #F0C089;
    }

    .privacy-note strong {
        color: #FBD9AC;
    }

    .dropzone {
        border-color: #33415580;
    }

    .result-icon.success {
        background: rgba(22, 163, 74, 0.18);
    }

    .result-icon.error {
        background: rgba(220, 38, 38, 0.18);
    }
}
