/* ==========================================================================
   RESET & VARIÁVEIS GLOBAIS
   ========================================================================== */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --primary-border: #bfdbfe;
    
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --bg-subtle: #f1f5f9;
    --bg-box: #f8fafc;
    
    --text-main: #0f172a;
    --text-muted: #475569;
    --text-subtle: #64748b;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    
    --success: #16a34a;
    --success-light: #dcfce7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    
    --input-filled-border: #10b981;
    --input-filled-bg: #f0fdf4;
    
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.07), 0 1px 2px -1px rgb(0 0 0 / 0.07);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.08);
}

/* Modo Escuro (Dark Mode por Padrão) */
html.dark, body.dark {
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-light: #1e293b;
    --primary-border: #2563eb;
    
    --bg-page: #0b1120;
    --bg-card: #151f32;
    --bg-subtle: #1e293b;
    --bg-box: #0f172a;
    
    --text-main: #f1f5f9;
    --text-muted: #cbd5e1;
    --text-subtle: #94a3b8;
    --border: #283548;
    --border-hover: #3b4d66;
    
    --input-filled-border: #10b981;
    --input-filled-bg: #064e3b33;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.5;
    padding-bottom: 60px;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.app-header {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(8px);
}

body.dark .app-header {
    background-color: rgba(21, 31, 50, 0.95);
    border-bottom-color: var(--border);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.theme-toggle-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

body.dark .theme-toggle-btn {
    background: #1e293b;
    border-color: var(--border);
    color: #cbd5e1;
}

body.dark .theme-toggle-btn:hover {
    border-color: var(--primary-hover);
    color: #ffffff;
}

.header-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.header-brand .badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--primary);
    background: var(--primary-light);
    padding: 3px 8px;
    border-radius: 4px;
    margin-bottom: 4px;
}

.header-brand h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
}

.header-brand .subtitle {
    font-size: 12px;
    color: var(--text-subtle);
}

.lead-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-subtle);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.7);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(22, 163, 74, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

/* ==========================================================================
   CONTAINER PRINCIPAL & CARDS
   ========================================================================== */
.main-container {
    max-width: 960px;
    margin: 24px auto;
    padding: 0 20px;
}

.notice-card {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 4px solid var(--warning);
    padding: 10px 16px;
    border-radius: var(--radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.notice-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.notice-icon {
    font-size: 16px;
    line-height: 1;
}

.notice-text {
    font-size: 13px;
    color: #78350f;
}

.notice-text code {
    background: #fde68a;
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 600;
}

.notice-close {
    background: transparent;
    border: none;
    font-size: 14px;
    color: #92400e;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 1;
    font-weight: 700;
    transition: background-color 0.15s;
}

.notice-close:hover {
    background: #fde68a;
}

/* ==========================================================================
   SEÇÕES DO FORMULÁRIO
   ========================================================================== */
.form-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 32px 36px;
    margin-bottom: 32px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.section-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
}

.section-num {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
    font-size: 15px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.section-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
}

.section-hint {
    display: block;
    font-size: 12.5px;
    color: var(--text-subtle);
    font-weight: 400;
    margin-top: 3px;
}

.subsection-title {
    font-size: 13.5px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.address-box, .contact-box, .body-parts-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 20px 22px;
    margin: 18px 0;
}

.address-box:last-child, .contact-box:last-child, .body-parts-box:last-child {
    margin-bottom: 0;
}

/* ==========================================================================
   GRIDS & CAMPOS
   ========================================================================== */
.grid {
    display: grid;
    gap: 16px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }

/* Grid específica de Endereço */
.address-grid-1 {
    display: grid;
    grid-template-columns: 140px 1fr 110px;
    gap: 14px;
    margin-bottom: 14px;
}

.address-grid-2 {
    display: grid;
    grid-template-columns: 1.2fr 1.2fr 1.5fr 80px;
    gap: 14px;
}

/* Quando um field-group está dentro de qualquer grid, a grid cuida do espaçamento */
.grid > .field-group,
.address-grid-1 > .field-group,
.address-grid-2 > .field-group {
    margin-bottom: 0;
}

@media (max-width: 768px) {
    .form-section {
        padding: 22px 18px;
        margin-bottom: 22px;
    }
    .grid-2, .grid-3, .address-grid-1, .address-grid-2 {
        grid-template-columns: 1fr;
    }
    .col-span-2, .col-span-3 {
        grid-column: span 1;
    }
    .header-container {
        flex-direction: column;
        align-items: flex-start;
    }
}

.field-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 18px;
}

.field-group:last-child {
    margin-bottom: 0;
}

.field-group label {
    font-size: 13.5px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 8px;
}

.req {
    color: var(--danger);
    font-weight: 700;
}

input[type="text"],
input[type="date"],
input[type="time"],
input[type="tel"],
input[type="email"],
select {
    width: 100%;
    height: 42px;
    box-sizing: border-box;
    padding: 0 14px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-main);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-main);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.sub-input {
    margin-top: 8px;
}

.field-tip {
    font-size: 12px;
    color: var(--text-subtle);
    margin-top: 6px;
    display: block;
}

/* ==========================================================================
   CONTROLES CUSTOMIZADOS (SEGMENTED, PILLS, CHIPS)
   ========================================================================== */
.segmented-control {
    display: inline-flex;
    align-items: center;
    height: 42px;
    box-sizing: border-box;
    width: fit-content;
    align-self: flex-start;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    padding: 3px;
    border-radius: var(--radius-sm);
    gap: 3px;
}

.segmented-control label {
    margin-bottom: 0;
    height: 100%;
    display: flex;
    align-items: center;
    cursor: pointer;
}

.segmented-control input[type="radio"] {
    display: none;
}

.segmented-control span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-width: 60px;
    padding: 0 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    border-radius: 4px;
    transition: all 0.15s ease;
    user-select: none;
    text-align: center;
}

.segmented-control input[type="radio"]:checked + span {
    background: #ffffff;
    color: var(--primary);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

/* Pill Group */
.pill-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pill-option {
    margin-bottom: 0 !important;
    cursor: pointer;
}

.pill-option input[type="radio"] {
    display: none;
}

.pill-option span {
    display: inline-block;
    padding: 7px 14px;
    font-size: 13px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-muted);
    transition: all 0.15s;
    user-select: none;
}

.pill-option input[type="radio"]:checked + span {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
    font-weight: 600;
}

/* Checkbox Chips (Membros do corpo e sequelas) */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
}

.check-chip {
    margin-bottom: 0 !important;
    cursor: pointer;
}

.check-chip input[type="checkbox"] {
    display: none;
}

.check-chip span {
    display: block;
    text-align: center;
    padding: 8px 10px;
    font-size: 13px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: all 0.15s;
    user-select: none;
}

.check-chip input[type="checkbox"]:checked + span {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

/* Radio Cards Verticais */
.radio-vertical-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.radio-card:hover {
    border-color: var(--border-hover);
}

.radio-card input[type="radio"] {
    accent-color: var(--primary);
}

.radio-card span {
    font-size: 13px;
    color: var(--text-main);
}

/* Checkbox LGPD */
.lgpd-group {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    padding: 14px;
    border-radius: var(--radius-sm);
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    color: #166534;
}

.checkbox-label input[type="checkbox"] {
    margin-top: 3px;
    accent-color: var(--success);
}

/* ==========================================================================
   BARRA DE AÇÃO & BOTÕES
   ========================================================================== */
.form-actions {
    margin-top: 28px;
    margin-bottom: 40px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
    border: none;
    padding: 12px 28px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: background-color 0.15s, transform 0.05s;
    min-width: 220px;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    transform: none;
}

.btn-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #ffffff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Utilitários */
.hidden { display: none !important; }

/* ==========================================================================
   MODAL DE FEEDBACK
   ========================================================================== */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.modal-card {
    background: #ffffff;
    padding: 32px 28px;
    border-radius: 12px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-icon {
    width: 56px;
    height: 56px;
    background: var(--success-light);
    color: var(--success);
    font-size: 28px;
    font-weight: bold;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.modal-card h3 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-main);
}

.modal-card p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
    line-height: 1.5;
}

/* ==========================================================================
   FEEDBACK VISUAL: CAMPOS PREENCHIDOS (VERDE ESMERALDA SUAVE COM CHECK)
   ========================================================================== */
.is-filled {
    border-color: var(--input-filled-border) !important;
    background-color: var(--input-filled-bg) !important;
    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='%2310b981' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 14px 14px !important;
    padding-right: 34px !important;
    transition: border-color 0.2s, background-color 0.2s;
}

input[type="date"].is-filled,
input[type="time"].is-filled,
select.is-filled {
    background-image: none !important;
    padding-right: 14px !important;
}

/* ==========================================================================
   ELEMENTOS ESPECÍFICOS NO MODO ESCURO
   ========================================================================== */
body.dark .form-section {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

body.dark .address-box, 
body.dark .contact-box, 
body.dark .body-parts-box {
    background: var(--bg-box);
    border-color: var(--border);
}

body.dark .subsection-title,
body.dark .box-title {
    color: #94a3b8;
}

body.dark input[type="text"],
body.dark input[type="date"],
body.dark input[type="time"],
body.dark input[type="tel"],
body.dark input[type="email"],
body.dark select,
body.dark textarea {
    background: #0b1120;
    color: var(--text-main);
    border-color: var(--border);
}

body.dark input::placeholder,
body.dark textarea::placeholder {
    color: #475569;
}

body.dark .field-group label {
    color: #e2e8f0;
}

body.dark .field-tip {
    color: #94a3b8;
}

body.dark .segmented-control {
    background: #0b1120;
    border-color: var(--border);
}

body.dark .segmented-control span {
    color: #94a3b8;
}

body.dark .segmented-control input[type="radio"]:checked + span {
    background: #1e293b;
    color: #38bdf8;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

body.dark .pill-option span,
body.dark .check-chip span {
    background: #0b1120;
    border-color: var(--border);
    color: #cbd5e1;
}

body.dark .pill-option span:hover,
body.dark .check-chip span:hover {
    border-color: var(--border-hover);
    color: #f8fafc;
}

body.dark .pill-option input[type="radio"]:checked + span,
body.dark .check-chip input[type="checkbox"]:checked + span {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

body.dark .notice-card {
    background: #241c10;
    border-color: #78350f;
    border-left-color: #f59e0b;
}

body.dark .notice-text {
    color: #fef3c7;
}

body.dark .notice-text code {
    background: #451a03;
    color: #fde68a;
}

body.dark .notice-close {
    color: #fde68a;
}

body.dark .notice-close:hover {
    background: #451a03;
}

body.dark .lead-badge {
    background: #1e293b;
    border-color: var(--border);
    color: #cbd5e1;
}

body.dark .modal-card {
    background: #1e293b;
    border: 1px solid var(--border);
    color: #f8fafc;
}

body.dark .modal-card h3 {
    color: #f8fafc;
}

body.dark .modal-card p {
    color: #cbd5e1;
}
