/* =====================================================
   COTIZADOR FANOSA — Estilos
   Réplica del aspecto de la app en Streamlit (layout "wide").
   ===================================================== */

:root {
    /* Color principal de botones: el rojo es el predeterminado de Streamlit.
       Para usar el azul corporativo, cámbialo a #005A9C */
    --primario: #FF4B4B;
    --primario-hover: #FF2B2B;
    --texto: #31333F;
    --texto-suave: rgba(49, 51, 63, 0.6);
    --borde: rgba(49, 51, 63, 0.2);
    --fondo-campo: #F0F2F6;
    --azul-fanosa: #005A9C;
    --naranja-fanosa: #F58220;
    --radio: 0.5rem;
    --fuente: "Source Sans Pro", "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body {
    margin: 0;
    font-family: var(--fuente);
    color: var(--texto);
    background: #FFFFFF;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Ajustes generales */
.block-container {
    width: 100%;
    padding: 2rem 5rem 2rem;
    margin: 0 auto;
}
.block-container.angosto { max-width: 46rem; padding-left: 1rem; padding-right: 1rem; }

h1, h2, h3 { font-weight: 700; color: var(--texto); margin: 0; line-height: 1.2; }
h1 { font-size: 2.75rem; padding: 1.25rem 0 1rem; }
h2 { font-size: 2.25rem; padding: 1rem 0; letter-spacing: -0.005em; }
h3 { font-size: 1.75rem; padding: 0.5rem 0 1rem; }

p { margin: 0 0 1rem; }

.caption {
    font-size: 0.875rem;
    color: var(--texto-suave);
    margin: 0 0 1rem;
    overflow-wrap: anywhere;
}

hr {
    border: none;
    border-bottom: 1px solid var(--borde);
    margin: 2rem 0;
}

a { color: #0068C9; }
code { background: var(--fondo-campo); padding: 0.1em 0.3em; border-radius: 0.25rem; font-size: 0.9em; }

.logo { width: 320px; max-width: 100%; height: auto; display: block; margin-bottom: 1rem; object-fit: contain; }

/* Bloques verticales / columnas */
.pila > * + * { margin-top: 1rem; }
.columnas { display: flex; gap: 1rem; width: 100%; align-items: flex-start; }
.columnas > .col { flex: 1 1 0; min-width: 0; }
.columnas > .col > * + * { margin-top: 1rem; }

/* Campos */
.campo { display: block; width: 100%; }
.campo > span, .etiqueta {
    display: block;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    color: var(--texto);
}
input[type="text"], input[type="password"], input[type="email"], input[type="date"],
input[type="number"], textarea, select, input[type="file"] {
    width: 100%;
    font-family: inherit;
    font-size: 1rem;
    color: var(--texto);
    background: var(--fondo-campo);
    border: 1px solid transparent;
    border-radius: var(--radio);
    padding: 0.5rem 0.75rem;
    min-height: 2.5rem;
    outline: none;
    transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--primario); }
input:disabled, textarea:disabled, select:disabled { color: rgba(49, 51, 63, 0.4); cursor: not-allowed; }
textarea { resize: vertical; line-height: 1.5; }
select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2331333F' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.25rem;
    cursor: pointer;
}
select.placeholder { color: var(--texto-suave); }

/* Número con botones − + (como st.number_input) */
.numero { display: flex; align-items: stretch; background: var(--fondo-campo); border-radius: var(--radio); border: 1px solid transparent; }
.numero:focus-within { border-color: var(--primario); }
.numero input { background: transparent; border: none; border-radius: var(--radio) 0 0 var(--radio); -moz-appearance: textfield; min-width: 0; }
.numero input::-webkit-outer-spin-button, .numero input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.numero button {
    border: none; background: transparent; width: 2.25rem; font-size: 1.1rem; cursor: pointer; color: var(--texto);
}
.numero button:hover { background: var(--primario); color: #fff; }
.numero button:last-child { border-radius: 0 var(--radio) var(--radio) 0; }

/* Radio y checkbox */
.radio-grupo { display: flex; flex-direction: column; gap: 0.35rem; }
.radio-grupo.horizontal { flex-direction: row; flex-wrap: wrap; gap: 0.5rem 1.25rem; }
.radio-grupo label, .check { display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer; font-size: 1rem; }
input[type="radio"], input[type="checkbox"] { accent-color: var(--primario); width: 1.05rem; height: 1.05rem; margin: 0; cursor: pointer; }

/* Botones */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.6;
    padding: 0.25rem 0.75rem;
    min-height: 2.5rem;
    border-radius: var(--radio);
    border: 1px solid var(--borde);
    background: #FFFFFF;
    color: var(--texto);
    cursor: pointer;
    text-decoration: none;
    user-select: none;
    transition: border-color .15s, color .15s, background .15s;
}
.btn:hover:not(:disabled) { border-color: var(--primario); color: var(--primario); }
.btn.primario { background: var(--primario); border-color: var(--primario); color: #FFFFFF; }
.btn.primario:hover:not(:disabled) { background: var(--primario-hover); border-color: var(--primario-hover); color: #FFFFFF; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.ancho { width: 100%; }
.btn.icono { padding: 0.25rem 0.6rem; }

/* Alertas (st.success / st.info / st.warning / st.error) */
.alerta {
    border-radius: var(--radio);
    padding: 1rem;
    font-size: 1rem;
    overflow-wrap: anywhere;
}
.alerta.exito { background: rgba(33, 195, 84, 0.1); color: rgb(23, 114, 51); }
.alerta.info { background: rgba(28, 131, 225, 0.1); color: rgb(0, 66, 128); }
.alerta.aviso { background: rgba(255, 227, 18, 0.1); color: rgb(146, 108, 5); }
.alerta.error { background: rgba(255, 43, 43, 0.09); color: rgb(125, 53, 59); }

/* Métricas (st.metric) */
.metrica .m-etiqueta { font-size: 0.875rem; color: var(--texto); margin-bottom: 0.1rem; }
.metrica .m-valor { font-size: 2.25rem; line-height: 1.25; font-weight: 400; overflow-wrap: anywhere; }

/* Contenedores con borde */
.tarjeta {
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    padding: 1rem;
}
.tarjeta > * + * { margin-top: 1rem; }
.tarjeta ul { margin: 0; padding-left: 1.25rem; }

/* Tablas (st.dataframe) */
.tabla-envoltura {
    width: 100%;
    max-width: 100%;
    overflow: auto;
    max-height: 420px;
    border: 1px solid var(--borde);
    border-radius: var(--radio);
}
table.datos { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
table.datos th, table.datos td {
    padding: 0.35rem 0.6rem;
    border-bottom: 1px solid rgba(49, 51, 63, 0.1);
    border-right: 1px solid rgba(49, 51, 63, 0.1);
    text-align: left;
    white-space: nowrap;
}
table.datos th { position: sticky; top: 0; background: #F8F9FB; color: var(--texto-suave); font-weight: 400; z-index: 1; }
table.datos td.num { text-align: right; }
table.datos tr:hover td { background: #F8F9FB; }

/* Total grande (sección 4 de cotización formal) */
.total-caja {
    background-color: #f0f2f6;
    padding: 22px;
    border-radius: 12px;
    text-align: center;
}
.total-caja p { font-size: 18px; color: #444; margin: 0 0 0.5rem; }
.total-caja h1 { color: #18784b; font-size: 38px; padding: 0.25rem 0 0.75rem; }
.total-caja p.iva { font-size: 16px; color: #666; margin: 0; }

/* Gráfica de pastel */
.grafica { display: flex; align-items: center; gap: 2rem; flex-wrap: wrap; position: relative; }
.grafica svg { max-width: 100%; height: auto; }
.grafica path { stroke: #fff; stroke-width: 1; cursor: pointer; transition: opacity .15s; }
.grafica path:hover { opacity: 0.8; }
.leyenda { font-size: 0.8rem; }
.leyenda .titulo { font-weight: 700; margin-bottom: 0.3rem; }
.leyenda div { display: flex; align-items: center; gap: 0.4rem; line-height: 1.6; }
.leyenda i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.tooltip {
    position: fixed; pointer-events: none; background: #fff; border: 1px solid #ddd; border-radius: 4px;
    padding: 0.4rem 0.6rem; font-size: 0.8rem; box-shadow: 0 2px 8px rgba(0,0,0,.15); z-index: 50; display: none;
}
.tooltip b { display: inline-block; min-width: 3.5rem; color: #555; font-weight: 400; }

/* Aviso flotante (toast) */
.toast {
    position: fixed; right: 1rem; bottom: 1rem; z-index: 100;
    background: #fff; color: var(--texto); border-radius: var(--radio);
    box-shadow: 0 4px 16px rgba(0,0,0,.18); padding: 0.75rem 1rem; max-width: 22rem;
    border-left: 4px solid rgb(33, 195, 84);
    animation: entrar .2s ease-out;
}
.toast.error { border-left-color: rgb(255, 43, 43); }
@keyframes entrar { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

.cargando { color: var(--texto-suave); padding: 1rem 0; }
.cargando::before {
    content: ""; display: inline-block; width: 1rem; height: 1rem; margin-right: 0.5rem; vertical-align: -2px;
    border: 2px solid var(--borde); border-top-color: var(--primario); border-radius: 50%; animation: girar .8s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

.pie { margin-top: 1rem; }
.barra-sesion { text-align: right; font-size: 0.8rem; }
.barra-sesion a { color: var(--texto-suave); }

/* =====================================================
   DISEÑO RESPONSIVE: COMPUTADORA Y CELULAR
   ===================================================== */
@media screen and (max-width: 1100px) {
    .block-container { padding-left: 2rem; padding-right: 2rem; }
}

/* Ajustes para celulares */
@media screen and (max-width: 768px) {
    .block-container {
        padding-left: 0.8rem !important;
        padding-right: 0.8rem !important;
        padding-top: 1rem !important;
    }
    h1 { font-size: 1.8rem !important; }
    h2 { font-size: 1.4rem !important; }
    h3 { font-size: 1.2rem !important; }

    /* Columnas se apilan como en Streamlit */
    .columnas { flex-direction: column; gap: 0.8rem; }
    .columnas > .col { width: 100%; }

    /* Botones más cómodos para tocar */
    .btn { width: 100%; min-height: 44px; white-space: normal; }

    .metrica .m-valor { font-size: 1.75rem; }
    .pila > * + * { margin-top: 0.8rem; }
    hr { margin: 1.5rem 0; }
}
