/* Digitalia v342.4.0 · Fase Visual 5 · Formularios
   Capa visual segura: no altera lógica, validaciones ni estructura de datos. */

:root {
    --f342-field-h: 42px;
    --f342-radius: 10px;
    --f342-gap: 14px;
    --f342-section-gap: 18px;
}

/* Excluir POS y Nueva Venta: se modernizarán en fases específicas. */
body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content form.card.form-grid,
body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content .commercial-form-section,
body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content .settings-section,
body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content fieldset {
    border-color: color-mix(in srgb, var(--v342-border, #dfe5ee) 92%, transparent);
}

/* Formularios genéricos: menos aire, mejor ritmo visual. */
body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content form.card.form-grid {
    gap: var(--f342-gap);
    padding: 20px;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .05), 0 10px 28px rgba(15, 23, 42, .035);
}

body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content :is(.form-grid, .compact-form-grid) {
    column-gap: 14px;
    row-gap: 13px;
}

/* Labels: jerarquía más clara sin modificar HTML. */
body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content :is(.form-grid, .commercial-form-grid, .purchase-header-grid) > label,
body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content .purchase-field,
body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content .field-with-action > label {
    display: grid;
    align-content: start;
    gap: 6px;
    min-width: 0;
    font-size: .78rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: .005em;
}

body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content :is(label, .field-label) > small,
body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content .purchase-field > small {
    margin-top: -1px;
    font-size: .70rem;
    font-weight: 500;
    line-height: 1.4;
}

/* Inputs / selects / textareas uniformes. */
body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content :is(
    input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
    select,
    textarea
) {
    width: 100%;
    min-width: 0;
    min-height: var(--f342-field-h);
    padding: 9px 11px;
    border: 1px solid var(--v342-border-strong, #ccd5e1);
    border-radius: var(--f342-radius);
    background: var(--v342-surface, #fff);
    color: var(--v342-text, #172033);
    font-size: .86rem;
    line-height: 1.25;
    box-shadow: inset 0 1px 1px rgba(15, 23, 42, .015);
}

body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content textarea {
    min-height: 88px;
    resize: vertical;
    line-height: 1.45;
}

body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content select {
    padding-right: 34px;
}

body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content :is(
    input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
    select,
    textarea
):hover:not(:disabled) {
    border-color: color-mix(in srgb, var(--v342-primary, #2563eb) 28%, var(--v342-border-strong, #ccd5e1));
}

body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content :is(
    input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
    select,
    textarea
):focus {
    border-color: var(--v342-primary, #2563eb);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--v342-primary, #2563eb) 14%, transparent);
    outline: none;
}

/* Solo lectura / disabled distinguibles sin perder legibilidad. */
body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content :is(input, select, textarea):disabled,
body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content :is(input, textarea)[readonly] {
    background: color-mix(in srgb, var(--v342-surface-soft, #f7f9fc) 94%, var(--v342-border, #dfe5ee));
    color: color-mix(in srgb, var(--v342-text, #172033) 72%, var(--v342-muted, #667085));
}

/* Checkboxes / radios: área táctil y alineación consistentes. */
body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content :is(.checkbox-row, .radio-row) {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 38px;
    padding: 5px 2px;
    font-size: .82rem;
    font-weight: 650;
}

body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content input[type="checkbox"],
body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content input[type="radio"] {
    width: 17px;
    height: 17px;
    margin: 0;
    accent-color: var(--v342-primary, #2563eb);
    flex: 0 0 auto;
}

/* Campo + botón (+, buscar, cargar TC, etc.). */
body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content :is(.field-action-row, .input-group, .apiperu-exchange-control) {
    gap: 8px;
    align-items: stretch;
}

body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content :is(.field-create-button, .purchase-entity-add) {
    min-width: 42px;
    min-height: 42px;
    border-radius: 10px;
}

/* Secciones de formularios largos. */
body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content :is(
    .commercial-form-section,
    .purchase-document-card,
    .purchase-modern-card,
    .settings-card,
    fieldset
) {
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .045);
}

body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content :is(
    .section-head,
    .commercial-form-section-head,
    .purchase-card-heading
) h2 {
    margin: 0;
    font-size: .98rem;
    line-height: 1.3;
    letter-spacing: -.01em;
}

body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content :is(
    .section-head,
    .commercial-form-section-head,
    .purchase-card-heading
) p {
    margin-top: 3px;
    margin-bottom: 0;
    font-size: .76rem;
    line-height: 1.4;
}

/* Form actions: barra final clara y compacta. */
body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content form > .actions.full,
body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content .commercial-form-actionbar,
body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content .form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
    flex-wrap: wrap;
    padding-top: 14px;
    margin-top: 2px;
    border-top: 1px solid color-mix(in srgb, var(--v342-border, #dfe5ee) 86%, transparent);
}

body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content form > .actions.full > :is(a, button),
body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content .form-actions > :is(a, button) {
    min-height: 40px;
}

/* Tabs de formularios/configuración. */
body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content :is(.tabs, .form-tabs, .general-settings-tabs) {
    gap: 6px;
}

body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content :is(.tabs, .form-tabs) :is(a, button),
body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content .general-settings-tabs :is(a, button) {
    border-radius: 9px;
}

/* Compras: armonizar controles sin reescribir su layout especializado. */
body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content .purchase-workspace {
    gap: 16px;
}

body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content .purchase-header-grid {
    gap: 12px 14px;
}

body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content .purchase-section-kicker {
    font-size: .66rem;
    letter-spacing: .075em;
}

/* Dark mode: conservar contraste de la capa final. */
html[data-theme="dark"] body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content form.card.form-grid,
html[data-theme="dark"] body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content :is(.commercial-form-section, .purchase-document-card, .purchase-modern-card, fieldset) {
    box-shadow: 0 1px 3px rgba(0, 0, 0, .20);
}

/* Responsive: una columna en móvil sin forzar anchos mínimos. */
@media (max-width: 760px) {
    body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content form.card.form-grid {
        padding: 15px;
        gap: 12px;
    }

    body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content :is(.form-grid, .compact-form-grid, .commercial-form-grid) {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content form > .actions.full,
    body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content .commercial-form-actionbar,
    body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content .form-actions {
        align-items: stretch;
    }

    body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content form > .actions.full > :is(a, button),
    body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content .form-actions > :is(a, button) {
        flex: 1 1 auto;
        justify-content: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.app-layout:not(.pos-mode):not(.sales-create-hover-mode) .app-content :is(input, select, textarea) {
        transition: none !important;
    }
}
