/* ==========================================================================
   TECSAR — Estándar UI/UX Inputs de Texto Odoo 19 (Desktop, Tablet & Mobile)
   ========================================================================== */

:root {
    --o-input-border: #E2E8F0;
    --o-input-border-hover: #9CA3AF;
    --o-input-focus: var(--brand-primary, #0062be); /* Color primario corporativo TECSAR */
    --o-input-error: #DC2626;
    --o-input-text: #1F2937;
    --o-input-muted: #6B7280;
    --o-label-color: #374151;
}

/* Etiqueta estándar Odoo 19 */
.o-label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    line-height: 1.35;
    color: var(--o-label-color);
}

/* Contenedor de campo horizontal (Desktop/Tablet: label izquierda | Mobile: label arriba) */
.o-field-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
    align-items: center;
}
@media (min-width: 768px) {
    .o-field-row {
        grid-template-columns: minmax(120px, 34%) 1fr;
        gap: 12px;
    }
    .o-field-row .o-label {
        padding-right: 10px;
        border-right: 1px solid #F1F5F9;
    }
}

/* Wrapper del input con underline minimalista Odoo 19 */
.o-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--o-input-border);
    transition: border-color 150ms ease, box-shadow 150ms ease;
    min-height: 36px;
}

.o-input-wrap:hover:not(.o-is-disabled):not(.o-is-readonly):not(.o-is-error) {
    border-bottom-color: var(--o-input-border-hover);
}

.o-input-wrap:focus-within:not(.o-is-disabled):not(.o-is-readonly):not(.o-is-error) {
    border-bottom-color: var(--o-input-focus);
    box-shadow: inset 0 -1px 0 0 var(--o-input-focus);
}

/* Estado Error */
.o-input-wrap.o-is-error {
    border-bottom-color: var(--o-input-error);
    box-shadow: inset 0 -1px 0 0 var(--o-input-error);
}

/* Estado Solo Lectura (sin borde inferior) */
.o-input-wrap.o-is-readonly {
    border-bottom-color: transparent !important;
    box-shadow: none !important;
}

/* Estado Deshabilitado (borde inferior punteado + texto atenuado) */
.o-input-wrap.o-is-disabled {
    border-bottom: 1px dashed #D1D5DB !important;
    box-shadow: none !important;
}

/* Input nativo interno */
.o-input {
    width: 100%;
    min-width: 0;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    padding: 6px 4px;
    min-height: 34px;
    font-size: 14px;
    line-height: 1.4;
    color: var(--o-input-text);
    font-weight: 500;
}

.o-input::placeholder {
    color: #9CA3AF;
    font-weight: 400;
}

.o-input:disabled {
    color: var(--o-input-muted);
    cursor: not-allowed;
}

.o-input[readonly] {
    color: var(--o-input-text);
    cursor: default;
}

/* Uso directo de clase .o-input sin wrapper (cuando se aplica inline en tablas/modales) */
input.o-input-standalone,
textarea.o-input-standalone {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--o-input-border);
    border-radius: 0;
    padding: 6px 4px;
    min-height: 34px;
    font-size: 14px;
    line-height: 1.4;
    color: var(--o-input-text);
    font-weight: 500;
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

input.o-input-standalone:hover:not(:disabled):not([readonly]),
textarea.o-input-standalone:hover:not(:disabled):not([readonly]) {
    border-bottom-color: var(--o-input-border-hover);
}

input.o-input-standalone:focus:not(:disabled):not([readonly]),
textarea.o-input-standalone:focus:not(:disabled):not([readonly]) {
    border-bottom-color: var(--o-input-focus);
    box-shadow: inset 0 -1px 0 0 var(--o-input-focus);
}

input.o-input-standalone:disabled,
textarea.o-input-standalone:disabled {
    color: var(--o-input-muted);
    border-bottom: 1px dashed #D1D5DB;
    cursor: not-allowed;
}

input.o-input-standalone[readonly],
textarea.o-input-standalone[readonly] {
    border-bottom-color: transparent;
}

/* Variante: Título Principal de Ficha (o_field_char grande) */
.o-input-title-wrap {
    border-bottom-color: transparent;
}
.o-input-title-wrap:hover:not(.o-is-disabled):not(.o-is-readonly) {
    border-bottom-color: var(--o-input-border-hover);
}
.o-input-title {
    font-size: 22px;
    line-height: 1.25;
    font-weight: 600;
    color: #111827;
    padding: 4px 2px;
    min-height: 40px;
}
@media (min-width: 768px) {
    .o-input-title {
        font-size: 26px;
    }
}

/* Variante: Numérico / Monetario */
.o-input-currency {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.o-affix {
    color: var(--o-input-muted);
    font-size: 13px;
    font-weight: 600;
    user-select: none;
    flex-shrink: 0;
}

/* Variante: Textarea con auto-resize */
.o-textarea {
    resize: none;
    overflow-y: hidden;
    min-height: 36px;
    line-height: 1.5;
}

/* Botones de acción inline (limpiar X, ojo password, copiar) */
.o-inline-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    color: #9CA3AF;
    opacity: 0.7;
    transition: opacity 120ms ease, color 120ms ease, background-color 120ms ease;
    flex-shrink: 0;
    cursor: pointer;
}
.o-inline-btn:hover {
    opacity: 1;
    color: var(--o-input-focus);
    background-color: #F1F5F9;
}

/* Mensaje de error compacto (12px rojo) */
.o-error-msg {
    margin-top: 3px;
    font-size: 12px;
    line-height: 1.3;
    font-weight: 600;
    color: var(--o-input-error);
}

/* Adaptación Mobile (< 768px): 44px altura táctil + 16px font-size para evitar zoom iOS Safari */
@media (max-width: 767px) {
    .o-input-wrap {
        min-height: 44px;
    }
    .o-input,
    input.o-input-standalone,
    textarea.o-input-standalone {
        min-height: 44px;
        font-size: 16px;
        padding: 8px 4px;
    }
    .o-input-title {
        font-size: 20px;
        min-height: 44px;
    }
}

/* Variante embebida: campo dentro de un contenedor propio (composer de chat, barras compuestas) */
input.o-input-standalone.o-input-embedded,
textarea.o-input-standalone.o-input-embedded {
    border-bottom-color: transparent !important;
    box-shadow: none !important;
}
