/* VARIABLES Y CONFIGURACIÓN BASE */
:root {
    --primary: #253F25;
    --primary-hover: #1a2e1a;
    --primary-light: #e4ebe4;
    --text-main: #303030;
    --text-muted: #7a746f;
    --bg-page: #F2EFED;
    --border-color: #e3deda;
    --border-focus: #253F25;

    /* Sombras más modernas y difusas */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-card: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-float: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    line-height: 1.6;
    margin: 0;
    padding-bottom: 6rem;
    /* pb-24 equivalent */
    min-height: 100vh;
}

/* HEADER */
.form-header {
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    padding: 1rem 2rem;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.arraigo-logo {
    height: 35px;
    /* IMPORTANTE: Fija la altura para evitar que se descuadre */
    width: auto;
    /* Mantiene la proporción de la imagen */
    object-fit: contain;
}

.header-left-group {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.back-link {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.2s;
    white-space: nowrap;
}

.back-link:hover {
    color: var(--primary);
}

.header-mini-title {
    font-weight: 600;
    color: var(--primary-hover);
    padding-left: 1.5rem;
    border-left: 1px solid var(--border-color);
    line-height: 1.2;
    display: block;
    white-space: nowrap;
}

.submit-btn-header {
    background-color: var(--primary);
    color: white;
    padding: 0.575rem 1.375rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
    white-space: nowrap;
}

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

.submit-btn-header.large {
    padding: 0.875rem 2rem;
    font-size: 1rem;
}

/* LAYOUT & CONTAINERS */
.main-container {
    max-width: 64rem;
    /* max-w-5xl */
    margin: 3rem auto 0;
    padding: 0 1.5rem;
    box-sizing: border-box;
}

@media (max-width: 640px) {
    .main-container {
        margin-top: 2rem;
        padding: 0 1rem;
    }

    .header-mini-title {
        display: none;
    }

    .form-header {
        padding: 1rem;
    }

    /* Increase tap targets for mobile */
    .checkbox-label,
    .radio-label {
        padding: 0.75rem;
    }
}

/* Checkbox Groups */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.checkbox-item {
    display: flex;
    align-items: flex-start;
    /* Better for multi-line text */
    gap: 0.75rem;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background-color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.checkbox-item:hover,
.checkbox-item:active {
    background-color: var(--bg-page);
    border-color: var(--primary);
}

.checkbox-item input[type="checkbox"] {
    margin-top: 0.25rem;
    /* Align with first line of text */
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    accent-color: var(--primary);
}

/* Joined Checkbox Group Style */
.checkbox-group.joined {
    gap: 0;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    overflow: hidden;
    background-color: #f8fafc;
    /* Slate 50 or similar */
}

.checkbox-group.joined .checkbox-item {
    border: none;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
    margin-bottom: 0;
    background-color: transparent;
}

.checkbox-group.joined .checkbox-item:last-child {
    border-bottom: none;
}

.checkbox-group.joined .checkbox-item:hover {
    background-color: #f1f5f9;
    /* Just a bit darker on hover */
}

.hero-section {
    margin-bottom: 3rem;
    margin-left: auto;
    margin-right: auto;
}

.hero-header {
    text-align: center;
    margin-bottom: 1rem;
}

.hero-logo {
    display: block;
    margin: 0 auto 1.5rem auto;
    height: 60px;
    width: auto;
    object-fit: contain;
}

.hero-title {
    font-size: 1.75rem;
    /* text-4xl mobile adjusted */
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.025em;
    /* tracking-tight */
    margin: 0;
}

@media (min-width: 768px) {
    .hero-title {
        font-size: 2.25rem;
    }
}

.hero-content-box {
    background: white;
    padding: 1.5rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    color: #475569;
    font-size: 1.0625rem;
    line-height: 1.7;
    text-align: left;
    display: flex;
    flex-direction: column;
}

@media (min-width: 768px) {
    .hero-content-box {
        padding: 2.5rem;
    }
}

.text-brand {
    color: #065f46;
    font-weight: 600;
}

/* emerald-800 font-semibold */
.text-strong {
    color: var(--text-main);
    font-weight: 500;
}

.form-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    /* space-y-8 */
}

/* FORM CARDS */
.form-card {
    background: white;
    padding: 1.5rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

@media (min-width: 768px) {
    .form-card {
        padding: 2.5rem;
    }
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-hover);
    margin: 0 0 2rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-light);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-description {
    font-size: 0.875rem;
    color: #858585;
    margin-bottom: 2rem;
    line-height: 1.625;
    margin-top: -1.5rem;
    /* Pull up closer to title */
}

/* FORM ELEMENTS */
.form-group-stack {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    margin-bottom: 0rem;
    /* Let flex/grid handle spacing */
    position: relative;
    width: 100%;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 1rem;
}

.required {
    color: #ef4444;
    margin-left: 2px;
}

.form-input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 16px;
    /* Explicit 16px to prevent iOS zoom */
    color: var(--text-main);
    background-color: #fff;
    transition: all 0.2s ease;
    margin-bottom: 0.5rem;
    max-width: 100%;
    min-width: 0;
    /* Fix for iOS date inputs overflowing */
    appearance: none;
    -webkit-appearance: none;
}

/* Specific fix for date/month inputs on mobile */
input[type="date"],
input[type="month"] {
    display: block;
    width: 100%;
    min-width: 0;
    line-height: 1.3;
    /* Fix vertical alignment */
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
}

.form-input::placeholder {
    color: #94a3b8;
}

/* Placeholder visual para selects requeridos vacíos */
select.form-input:required:invalid,
select.form-input.placeholder-active {
    color: #94a3b8;
    /* Mismo gris que tus placeholders de texto */
}

/* Asegurar que las opciones internas se vean oscuras al desplegar */
select.form-input option {
    color: var(--text-main);
    /* #1e293b */
}

textarea.form-input {
    min-height: 8rem;
    resize: none;
    font-family: 'Outfit', sans-serif;
}

.icon-wrapper {
    position: relative;
}

.form-input.has-icon {
    padding-right: 2.5rem;
}

.icon-suffix {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 1rem;
    pointer-events: none;
    color: var(--text-muted);
    font-size: 1.125rem;
    display: flex;
}

.form-help {
    display: block;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* GRIDS */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 1.5rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .grid-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

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

/* CONDITIONAL VISIBILITY */
.hidden {
    display: none !important;
}

.conditional-box {
    padding: 1rem;
    background-color: #f1f5f9;
    /* slate-100 */
    border: 1px solid #e2e8f0;
    /* slate-200 */
    border-radius: 0.5rem;
    margin-top: 1rem;
}

.conditional-box.nested {
    border-left: 2px solid var(--primary-light);
    padding-left: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: transparent;
    border-top: none;
    border-right: none;
    border-bottom: none;
    margin-bottom: 1.5rem;
}

.select-wrapper {
    position: relative;
}

.select-wrapper::after {
    content: "▼";
    font-size: 0.7rem;
    position: absolute;
    right: 1.2rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary);
    pointer-events: none;
}

select.form-input {
    appearance: none;
    cursor: pointer;
}

/* CHECKBOX CARD */
.checkbox-container {
    margin-top: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background-color: white;
    cursor: pointer;
    transition: background-color 0.2s;
}

.checkbox-label:hover {
    background-color: var(--bg-page);
}

.checkbox-input {
    margin-top: 0.25rem;
    accent-color: var(--primary);
    width: 1.25rem;
    height: 1.25rem;
}

.checkbox-text {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.6;
    text-align: justify;
}

/* ANIMATIONS */
.fade-in {
    animation: fadeIn 0.5s ease-out forwards;
    opacity: 0;
}

.delay-100 {
    animation-delay: 100ms;
}

.delay-200 {
    animation-delay: 200ms;
}

.delay-300 {
    animation-delay: 300ms;
}

.delay-500 {
    animation-delay: 500ms;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.btn-center-wrapper {
    margin-top: 3rem;
    display: flex;
    justify-content: center;
}

.text-color-primary {
    color: var(--primary);
}

.text-color-slate {
    color: #334155;
}

/* Privacy Policy Collapsible */
.privacy-policy-container {
    margin-top: -2rem;
    margin-bottom: 0rem;
}

.privacy-toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--primary-light);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary-hover);
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
    width: 100%;
    text-align: left;
}

.privacy-toggle-btn:hover {
    background: #d6e4d6;
    border-color: var(--primary);
}

.privacy-toggle-btn i {
    font-size: 1rem;
    transition: transform 0.3s ease;
}

.privacy-toggle-btn.expanded i {
    transform: rotate(90deg);
}

.privacy-policy-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, padding 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    background-color: #f8fafc;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 0.5rem 0.5rem;
    padding: 0 1rem;
}

.privacy-policy-content.visible {
    max-height: 3000px;
    padding: 1rem;
    opacity: 1;
}

.privacy-policy-content.hidden {
    display: block !important;
    max-height: 0;
    padding: 0 1rem;
    opacity: 0;
}

/* Alert Box */
.alert-box {
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

.alert-box.warning {
    background-color: #fff7ed;
    border: 1px solid #fed7aa;
    color: #991b1b;
}

.alert-box i {
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* Flash message (avisos de envío del formulario: errores y duplicados).
   Banner fijo en la parte superior, visible esté donde esté el scroll. */
.flash-message {
    position: fixed;
    top: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    max-width: 90%;
    width: max-content;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.9rem 1.1rem;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    line-height: 1.5;
    box-shadow: var(--shadow-card);
    animation: flashIn 0.25s ease-out;
}

.flash-message.error {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.flash-message.success {
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.flash-message-text {
    flex: 1;
}

.flash-message-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 0;
    font-size: 1.1rem;
    line-height: 1;
    opacity: 0.7;
    flex-shrink: 0;
}

.flash-message-close:hover {
    opacity: 1;
}

@keyframes flashIn {
    from {
        opacity: 0;
        transform: translate(-50%, -0.5rem);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}