/* ============================================================
   ACADEMIKA PLUS — FORMS SYSTEM
   Requires: variables.css loaded first
   Covers: Input · Textarea · Select · Toggle · Checkbox ·
           Radio · File Upload · Form sections · Validation
   ============================================================ */


/* ══════════════════════════════════════════════════════════
   1. LABEL
   ══════════════════════════════════════════════════════════ */

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.75);
    margin-bottom: 6px;
    line-height: 1.4;
}

:root:not(.dark) .form-label {
    color: #444;
}

/* Marker de campo obligatorio */
.form-label .required {
    color: var(--color-lime);
    font-weight: 700;
    margin-left: 2px;
}

:root:not(.dark) .form-label .required {
    color: var(--color-primary);
}

/* Descripción/hint debajo del label */
.form-hint {
    font-size: 0.78rem;
    opacity: 0.50;
    margin-top: -2px;
    margin-bottom: 8px;
    display: block;
    line-height: 1.4;
}


/* ══════════════════════════════════════════════════════════
   2. INPUT BASE / TEXTAREA / SELECT
   ══════════════════════════════════════════════════════════ */

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    display: block;
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-md);
    color: rgba(255, 255, 255, 0.90);
    padding: 12px 16px;
    font-size: 0.9rem;
    font-family: inherit;
    line-height: 1.4;
    transition: var(--transition-fast);
    outline: none;
    box-sizing: border-box;
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: rgba(255, 255, 255, 0.30);
}

:root:not(.dark) .form-input,
:root:not(.dark) .form-textarea,
:root:not(.dark) .form-select {
    background: rgba(255, 255, 255, 0.80);
    border-color: rgba(180, 190, 210, 0.70);
    color: var(--color-dark);
}

:root:not(.dark) .form-input::placeholder,
:root:not(.dark) .form-textarea::placeholder {
    color: #aab0c0;
}

/* ─── Focus ─── */
.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 146, 69, 0.18);
    background: rgba(255, 255, 255, 0.09);
}

:root:not(.dark) .form-input:focus,
:root:not(.dark) .form-textarea:focus,
:root:not(.dark) .form-select:focus {
    box-shadow: 0 0 0 3px rgba(0, 146, 69, 0.12);
    background: #ffffff;
}

/* ─── Textarea ─── */
.form-textarea {
    resize: vertical;
    min-height: 100px;
}

/* ─── Disabled ─── */
.form-input:disabled,
.form-textarea:disabled,
.form-select:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}


/* ══════════════════════════════════════════════════════════
   3. CONTENEDOR CON ÍCONO EMBEBIDO
   ══════════════════════════════════════════════════════════ */

.form-field {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper .form-input,
.input-wrapper .form-select {
    padding-left: 42px;
}

.input-wrapper.icon-right .form-input {
    padding-left: 16px;
    padding-right: 42px;
}

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.35);
    font-size: 0.88rem;
    pointer-events: none;
    z-index: 1;
}

:root:not(.dark) .input-icon {
    color: #aab0c0;
}

.input-icon-right {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.35);
    font-size: 0.88rem;
    pointer-events: none;
    z-index: 1;
}


/* ══════════════════════════════════════════════════════════
   4. ESTADOS DE VALIDACIÓN
   ══════════════════════════════════════════════════════════ */

/* Error */
.form-input.is-invalid,
.form-textarea.is-invalid,
.form-select.is-invalid {
    border-color: var(--color-error) !important;
    box-shadow: 0 0 0 3px rgba(204, 51, 0, 0.12) !important;
}

.form-input.is-invalid:focus,
.form-textarea.is-invalid:focus,
.form-select.is-invalid:focus {
    border-color: var(--color-error) !important;
}

/* Success */
.form-input.is-valid,
.form-textarea.is-valid,
.form-select.is-valid {
    border-color: var(--color-success);
    box-shadow: 0 0 0 3px rgba(0, 146, 69, 0.12);
}

/* Mensaje de error bajo el campo */
.form-error {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 5px;
    color: var(--color-error);
    font-size: 0.80rem;
    line-height: 1.3;
    animation: errorIn 0.2s ease;
}

.form-error i {
    flex-shrink: 0;
    font-size: 0.72rem;
}

@keyframes errorIn {
    from {
        opacity: 0;
        transform: translateY(-3px);
    }

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

/* Indicador de validación (ícono dentro del input) */
.validation-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    pointer-events: none;
    z-index: 2;
}

.validation-icon.valid {
    color: var(--color-success);
}

.validation-icon.invalid {
    color: var(--color-error);
}


/* ══════════════════════════════════════════════════════════
   5. SELECT PERSONALIZADO
   ══════════════════════════════════════════════════════════ */

.form-select {
    appearance: none;
    -webkit-appearance: none;
    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='rgba(255,255,255,0.45)' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
    cursor: pointer;
}

:root:not(.dark) .form-select {
    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='%23aab0c0' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* Opciones del select (limitado en navegadores, usa JS dropdown para avanzado) */
.form-select option {
    background: #0a1a0e;
    color: rgba(255, 255, 255, 0.90);
    padding: 8px;
}

:root:not(.dark) .form-select option {
    background: #ffffff;
    color: var(--color-dark);
}


/* ══════════════════════════════════════════════════════════
   6. TOGGLE SWITCH
   ══════════════════════════════════════════════════════════ */

.toggle-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.toggle-wrapper input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-track {
    position: relative;
    width: 48px;
    height: 26px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.15);
    transition: all 0.25s ease;
    flex-shrink: 0;
}

:root:not(.dark) .toggle-track {
    background: #ccc;
}

.toggle-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    transition: transform 0.25s ease;
}

/* Checked state */
.toggle-wrapper input:checked+.toggle-track {
    background: linear-gradient(90deg, var(--color-primary), #00cc5f);
    box-shadow: 0 0 8px rgba(0, 146, 69, 0.40);
}

.toggle-wrapper input:checked+.toggle-track::after {
    transform: translateX(22px);
}

/* Focus */
.toggle-wrapper input:focus-visible+.toggle-track {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.toggle-label {
    font-size: 0.88rem;
    font-weight: 500;
}


/* ══════════════════════════════════════════════════════════
   7. CHECKBOX PERSONALIZADO
   ══════════════════════════════════════════════════════════ */

.checkbox-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    line-height: 1;
}

.checkbox-wrapper input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.checkbox-custom {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border-radius: 4px;
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
    flex-shrink: 0;
}

:root:not(.dark) .checkbox-custom {
    border-color: #ccc;
    background: rgba(255, 255, 255, 0.80);
}

/* Checkmark SVG */
.checkbox-custom::after {
    content: '';
    width: 10px;
    height: 7px;
    border-left: 2px solid transparent;
    border-bottom: 2px solid transparent;
    transform: rotate(-45deg) translateY(-1px);
    transition: border-color 0.15s ease;
}

.checkbox-wrapper input:checked+.checkbox-custom {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.checkbox-wrapper input:checked+.checkbox-custom::after {
    border-color: #ffffff;
}

.checkbox-wrapper input:focus-visible+.checkbox-custom {
    box-shadow: 0 0 0 3px rgba(0, 146, 69, 0.18);
}

.checkbox-label {
    font-size: 0.88rem;
    font-weight: 500;
}


/* ══════════════════════════════════════════════════════════
   8. RADIO PERSONALIZADO
   ══════════════════════════════════════════════════════════ */

.radio-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.radio-wrapper input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.radio-custom {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
    flex-shrink: 0;
}

:root:not(.dark) .radio-custom {
    border-color: #ccc;
    background: rgba(255, 255, 255, 0.80);
}

.radio-custom::after {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: transparent;
    transition: background 0.15s ease;
}

.radio-wrapper input:checked+.radio-custom {
    border-color: var(--color-primary);
}

.radio-wrapper input:checked+.radio-custom::after {
    background: var(--color-primary);
}

.radio-wrapper input:focus-visible+.radio-custom {
    box-shadow: 0 0 0 3px rgba(0, 146, 69, 0.18);
}

.radio-label {
    font-size: 0.88rem;
    font-weight: 500;
}


/* ══════════════════════════════════════════════════════════
   9. INPUT FILE / DROPZONE
   ══════════════════════════════════════════════════════════ */

.file-dropzone {
    position: relative;
    background: rgba(0, 146, 69, 0.05);
    border: 2px dashed rgba(0, 146, 69, 0.35);
    border-radius: var(--radius-lg);
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-base);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

:root:not(.dark) .file-dropzone {
    background: rgba(0, 146, 69, 0.03);
    border-color: rgba(0, 146, 69, 0.30);
}

.file-dropzone:hover,
.file-dropzone.drag-over {
    border-color: var(--color-primary);
    background: rgba(0, 146, 69, 0.10);
}

.file-dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.file-dropzone-icon {
    font-size: 2rem;
    color: var(--color-primary);
    opacity: 0.70;
}

.file-dropzone-title {
    font-size: 0.9rem;
    font-weight: 600;
    opacity: 0.85;
}

.file-dropzone-hint {
    font-size: 0.78rem;
    opacity: 0.45;
}

.file-dropzone-selected {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 0.82rem;
    color: var(--color-primary);
}


/* ══════════════════════════════════════════════════════════
   10. SECCIÓN DE FORMULARIO
   ══════════════════════════════════════════════════════════ */

.form-section-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.45);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 20px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: block;
}

:root:not(.dark) .form-section-label {
    color: #888;
    border-bottom-color: rgba(0, 0, 0, 0.08);
}


/* ══════════════════════════════════════════════════════════
   11. FORM GROUP (spacing helper)
   ══════════════════════════════════════════════════════════ */

.form-group {
    margin-bottom: 18px;
}

.form-row {
    display: grid;
    gap: 16px;
}

.form-row-2 {
    grid-template-columns: 1fr 1fr;
}

.form-row-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

@media (max-width: 640px) {

    .form-row-2,
    .form-row-3 {
        grid-template-columns: 1fr;
    }
}

/* ══════════════════════════════════════════════════════════
   12. FORM ACTIONS (botones al pie)
   ══════════════════════════════════════════════════════════ */

.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.form-actions.right {
    justify-content: flex-end;
}

.form-actions.center {
    justify-content: center;
}

/* ══════════════════════════════════════════════════════════
   13. FORM CONTAINER (wraps the whole form card)
   ══════════════════════════════════════════════════════════ */

.form-card {
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-xl);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.30);
    padding: 32px;
}

:root:not(.dark) .form-card {
    background: rgba(255, 255, 255, 0.80);
    border-color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 8px 32px rgba(18, 22, 41, 0.10);
}

.form-card-title {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 6px;
}

.form-card-subtitle {
    font-size: 0.88rem;
    opacity: 0.55;
    margin-bottom: 24px;
}

/* Divider dentro de form-card */
.form-card hr,
.form-card .form-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    margin: 20px 0;
}

:root:not(.dark) .form-card hr,
:root:not(.dark) .form-card .form-divider {
    background: rgba(18, 22, 41, 0.08);
}