/* =========================
   BOTONES BASE (SISTEMA UI)
========================= */

.btn {
    display: inline-block;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: 0.2s ease;
}

/* HOVER GENERAL */
.btn:hover {
    opacity: 0.9;
}

/* =========================
   COLORES
========================= */

.btn-primary {
    background: #0ea5e9;
    color: white;
}

.btn-success {
    background: #16a34a;
    color: white;
}

.btn-danger {
    background: #dc2626;
    color: white;
}

.btn-warning {
    background: #f59e0b;
    color: black;
}

/* =========================
   TAMAÑOS
========================= */

.btn-sm {
    padding: 6px 10px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 20px;
    font-size: 16px;
}

/* =========================
   BOTÓN DESHABILITADO
========================= */

.btn-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* =========================
   INPUTS
========================= */

.input {
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    font-size: 14px;
    outline: none;
    transition: 0.2s ease;
}

/* =========================
   INPUTS PARA TABLAS (ORDEN)
========================= */

.tabla-items .input-table {
    padding: 6px 8px;
    font-size: 13px;
    border-radius: 4px;
    height: 32px;

    width: 100%;
    min-width: 0;

    box-sizing: border-box;

    line-height: 1.2;
}

/* =========================
   AJUSTE FINO INPUTS TABLA
========================= */

/* cantidad → max 3 dígitos */
.tabla-items .item-cant {
    max-width: 70px;
}

/* precio → espacio razonable (hasta millones) */
.tabla-items .item-precio {
    max-width: 110px;
}

/* descripción → ocupa todo el resto */
.tabla-items .item-desc,
.tabla-items .item-desc-servicio {
    width: 100%;
}


/* =========================
   SERVICIOS - AJUSTE FINO
========================= */

.tabla-items .item-servicio {
    width: 90px;
    max-width: 90px;
}

/* clave: no permitir que servicio empuje */
.tabla-items .item-servicio {
    flex-shrink: 0;
}

/* cantidad → 3 dígitos */
.tabla-items .item-cant {
    width: 60px;
    max-width: 60px;
}

/* precio → hasta millones */
.tabla-items .item-precio {
    width: 100px;
    max-width: 100px;
}

/* subtotal → mismo comportamiento que precio */
.tabla-items .item-subtotal {
    width: 100px;
    max-width: 100px;
    text-align: right;
}

/* aire uniforme entre inputs */
.tabla-items td {
    padding-right: 8px;
}


/* evitar doble espacio al final */
.tabla-items td:last-child {
    padding-right: 0;
}


/* select dentro de tabla */
.tabla-items select.input-table {
    height: 32px;
}

/* evitar desbordes de texto */
.tabla-items .input-table {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.input:focus {
    border-color: #0ea5e9;
    box-shadow: 0 0 0 2px rgba(14,165,233,0.2);
}

/* Tamaño pequeño (para filtros) */
.input-sm {
    padding: 6px 10px;
    font-size: 13px;
}

.form-inline {
    display: flex;
    align-items: center;
    gap: 10px;
}


/* TAMAÑOS */
.btn-sm {
    padding: 6px 10px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 20px;
    font-size: 16px;
}

/* COLORES */
.btn-primary {
    background: #2563eb;
    color: white;
    border: none;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

.btn-success {
    background: #16a34a;
}
.btn-success:hover {
    background: #15803d;
}

.btn-danger {
    background: #dc2626;
}
.btn-danger:hover {
    background: #b91c1c;
}

.btn-warning {
    background: #f59e0b;
}
.btn-warning:hover {
    background: #d97706;
}

.btn.btn-secondary {
    background: #374151 !important; /* gris oscuro */
    color: #ffffff !important;
}

.btn.btn-secondary:hover {
    background: #6b7280 !important; /* gris claro */
    color: #ffffff !important;
}

/* =========================
   ESTADOS (GLOBAL UI)
========================= */

.estado-activo,
.estado-inactivo {
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

.estado-activo {
    color: #16a34a;
}

.estado-inactivo {
    color: #dc2626;
}

/* =========================
   ALERTAS / ESTADOS VISUALES
========================= */

.bajo-stock {
    background: #fecaca;
}

/* KPI GRID */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 320px));
    gap: 15px;
    margin-top: 15px;
}

.kpi {
    padding: 18px;
    border-radius: 10px;
    color: white;
}

.kpi h4 {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
}

.kpi p {
    font-size: 22px;
    font-weight: bold;
    margin: 5px 0 0;
}

.kpi-emerald { background:#10b981; }

/* COLORES */
.kpi-blue { background:#0ea5e9; }
.kpi-green { background:#22c55e; }
.kpi-orange { background:#f59e0b; }
.kpi-red { background:#ef4444; }
.kpi-purple { background:#6366f1; }

/* =========================
   COMPONENTE TABLA ORDEN (AISLADO)
========================= */

.tabla-orden {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

/* celdas */
.tabla-orden th,
.tabla-orden td {
    padding: 6px 8px;
    text-align: left;
    vertical-align: middle;
}

/* header */
.tabla-orden th {
    font-size: 13px;
    font-weight: 600;
    color: #334155;
}

/* =========================
   INPUTS ORDEN (AISLADOS)
========================= */

.input-orden {
    width: 100%;
    height: 30px;
    padding: 4px 6px;
    font-size: 13px;

    border: 1px solid #cbd5e1;
    border-radius: 4px;

    box-sizing: border-box;
}

/* select igual que input */
select.input-orden {
    height: 30px;
}

.servicio-item.active {
    background: #e6f0ff;
}

/* =========================
   COLUMNAS CONTROLADAS
========================= */

/* servicio */
.tabla-orden .col-servicio {
    width: 100px;
}

/* cantidad (3 dígitos) */
.tabla-orden .col-cant {
    width: 60px;
}

/* precio */
.tabla-orden .col-precio {
    width: 100px;
}

/* subtotal */
.tabla-orden .col-subtotal {
    width: 110px;
    text-align: right;
}

/* descripción flexible */
.tabla-orden .col-desc {
    width: auto;
}

/* subtotal contenido */
.tabla-orden .subtotal {
    text-align: right;
    font-weight: 500;
}

.select-auto {
    width: auto;
    min-width: 180px;
}

.textarea-orden {
    width: 100%;
    min-height: 80px;

    padding: 6px 8px;
    font-size: 13px;

    border: 1px solid #cbd5e1;
    border-radius: 4px;

    box-sizing: border-box;
    resize: vertical;
}

.textarea-orden:focus {
    outline: none;
    border-color: #0ea5e9;
    box-shadow: 0 0 0 2px rgba(14,165,233,0.2);
}

/* =========================
   AUTOCOMPLETE (GLOBAL)
========================= */

#resultados_clientes,
#resultados_bicis {
    position: absolute;
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    width: 100%;
    max-height: 220px;
    overflow-y: auto;
    z-index: 999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.result-item {
    padding: 8px 10px;
    font-size: 14px;
    cursor: pointer;
}

.result-item:hover {
    background: #f1f5f9;
}

/* =========================
   DROPDOWN AUTOCOMPLETE
========================= */

#resultados_clientes,
#resultados_bicis {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    width: 100%;
    max-height: 220px;
    overflow-y: auto;
    z-index: 999;
    display: none;
}

.result-item {
    padding: 10px 12px;
    cursor: pointer;
}

.result-item:hover {
    background: #f1f5f9;
}

.result-item.activo {
    background: #e2e8f0;
}

.fila-activa {
    background: #e0f2fe;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    width: 100%;
    max-height: 220px;
    overflow-y: auto;
    z-index: 999;
    display: none;
}

.autocomplete-item {
    padding: 10px 12px;
    cursor: pointer;
}

.autocomplete-item:hover {
    background: #f1f5f9;
}

.autocomplete-item.active {
    background: #e2e8f0;
}

.servicio-item.activo{
    background:#e2e8f0;
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(59,130,246,0.4); /* azul suave */
}
