/* ============================================================
   PolloCheff Inventario — components.css
   Botones, tarjetas, tablas, formularios, alertas, badges,
   modales, toasts, estados vacíos y spinners.
   ============================================================ */

/* ---------- Botones (estilo ByPolloCheff) ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    cursor: pointer;
    white-space: nowrap;
    min-height: 42px;
    box-shadow: var(--shadow-soft);
    transition: transform var(--transition-fast), background var(--transition-fast),
                border-color var(--transition-fast), color var(--transition-fast),
                box-shadow var(--transition-fast), filter var(--transition-fast);
}
.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-strong);
    filter: brightness(1.05);
}
.btn:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
    box-shadow: var(--shadow-sm);
}
.btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn .icon { flex-shrink: 0; }

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); }

.btn-secondary { background: var(--color-secondary); color: var(--color-on-secondary); }
.btn-secondary:hover:not(:disabled) { background: var(--color-secondary-hover); }

.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-ghost { background: transparent; color: var(--color-text-secondary); box-shadow: none; }
.btn-ghost:hover:not(:disabled) { background: var(--color-surface-hover); color: var(--color-text); box-shadow: var(--shadow-sm); }

.btn-whatsapp { background: var(--color-whatsapp); color: #fff; }

.btn-sm { padding: 7px 12px; font-size: 12px; min-height: 32px; }
.btn-lg { padding: 14px 24px; font-size: 15px; min-height: 50px; }
.btn-block { width: 100%; }

/* ---------- Tarjetas ---------- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-base), transform var(--transition-base);
}
.card:hover {
    box-shadow: var(--shadow-soft);
}
.card-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
}
.card-title { font-size: 16px; font-weight: 600; }
.card-body { padding: var(--space-5); }

/* ---------- Formularios ---------- */
.form-group { margin-bottom: var(--space-4); }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    font-size: 15px;
    background: var(--color-surface);
    min-height: 42px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-control:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(183, 28, 28, 0.15); }
.form-control::placeholder { color: var(--color-text-muted); }
textarea.form-control { min-height: 100px; resize: vertical; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.form-hint { font-size: 12px; color: var(--color-text-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--color-danger); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }

/* ---------- Formularios de filtro (rejilla adaptable) ---------- */
.filter-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: var(--space-4);
    align-items: end;
}
.filter-form .form-group { margin-bottom: 0; }
.filter-form .filter-actions { display: flex; gap: var(--space-2); align-items: center; }
.checkbox input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--color-primary); cursor: pointer; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-secondary);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}
.table td { padding: 14px 16px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.table tbody tr { transition: background var(--transition-fast); }
.table tbody tr:hover { background: var(--color-surface-hover); }
.table tbody tr:last-child td { border-bottom: none; }
.table .actions { display: flex; gap: var(--space-2); justify-content: flex-end; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}
.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-info { background: var(--color-info-soft); color: var(--color-info); }
.badge-neutral { background: var(--color-surface-hover); color: var(--color-text-secondary); }

/* ---------- Alertas ---------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    border: 1px solid transparent;
    margin-bottom: var(--space-4);
}
.alert .icon { flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--color-success-soft); color: var(--color-success); border-color: var(--color-success-border); }
.alert-danger { background: var(--color-danger-soft); color: var(--color-danger); border-color: var(--color-danger-border); }
.alert-warning { background: var(--color-warning-soft); color: var(--color-warning); border-color: var(--color-warning-border); }
.alert-info { background: var(--color-info-soft); color: var(--color-info); border-color: var(--color-info-border); }

/* ---------- Estados vacíos ---------- */
.empty-state { text-align: center; padding: var(--space-8) var(--space-5); color: var(--color-text-secondary); }
.empty-state .icon { margin: 0 auto var(--space-3); color: var(--color-text-muted); }
.empty-state h3 { font-size: 16px; color: var(--color-text); margin-bottom: 4px; }
.empty-state p { font-size: 14px; }

/* ---------- Modales ---------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base), visibility var(--transition-base);
}
.modal-backdrop.open { opacity: 1; visibility: visible; }
.modal {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(8px);
    transition: transform var(--transition-base);
}
.modal-backdrop.open .modal { transform: translateY(0); }
.modal-header { padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-body { padding: var(--space-5); }
.modal-footer { padding: var(--space-4) var(--space-5); border-top: 1px solid var(--color-border); display: flex; justify-content: flex-end; gap: var(--space-2); }
.modal-close { background: none; border: none; cursor: pointer; color: var(--color-text-muted); padding: 4px; border-radius: var(--radius-sm); display: flex; }
.modal-close:hover { background: var(--color-surface-hover); color: var(--color-text); }

/* ---------- Escáner de código de barras ---------- */
.scanner-modal { max-width: 480px; }
.scanner-view { position: relative; border-radius: var(--radius-md); overflow: hidden; background: #000; }
#barcode-reader { width: 100%; }
#barcode-reader video { width: 100% !important; height: auto !important; display: block; }
.scanner-guide {
    position: absolute;
    left: 10%;
    right: 10%;
    top: 38%;
    height: 24%;
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 6px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}
.scanner-hint { font-size: 13px; color: var(--color-text-muted); text-align: center; margin-top: var(--space-3); }
.scanner-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    text-align: center;
    padding: var(--space-5);
    color: var(--color-danger);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}
.scanner-error p { font-size: 14px; color: var(--color-text); margin: 0; }

/* ---------- Toasts ---------- */
.toast-container {
    position: fixed;
    bottom: var(--space-5);
    right: var(--space-5);
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
.toast {
    background: var(--color-text);
    color: #fff;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 360px;
    animation: toast-in var(--transition-base);
}
.toast-success { background: var(--color-success); }
.toast-error { background: var(--color-danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Paginación ---------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--color-border);
}
.pagination-info { font-size: 13px; color: var(--color-text-secondary); }

/* ---------- Spinner ---------- */
.spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Listas ---------- */
.list { list-style: none; }
.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 10px 0;
    border-bottom: 1px solid var(--color-border);
}
.list-item:last-child { border-bottom: none; }
.list-item-title { font-size: 14px; }
.list-item-value { font-size: 14px; font-weight: 600; }

/* ---------- Detalle ---------- */
.detail-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-4); }
.detail-label { font-size: 12px; color: var(--color-text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 2px; }
.detail-value { font-size: 15px; }

/* ---------- Edición inline de precio (tabla de stock) ---------- */
.price-form { display: flex; align-items: center; gap: 6px; }
.price-form .price-input { width: 96px; min-height: 34px; padding: 6px 8px; font-size: 14px; }
.price-form .btn { min-height: 34px; padding: 6px 8px; }

/* ---------- Buscador de producto físico (combobox de recetas) ---------- */
.product-search { position: relative; }
.product-search-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 240px;
    overflow-y: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    display: none;
}
.product-search-dropdown.open { display: block; }
.product-search-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 9px 12px;
    border: none;
    background: none;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    color: var(--color-text);
}
.product-search-option:hover,
.product-search-option:focus-visible { background: var(--color-surface-hover); }
.product-search-name { flex: 1 1 auto; min-width: 0; white-space: normal; overflow-wrap: anywhere; word-break: break-word; line-height: 1.25; }
.product-search-sku { font-size: 12px; color: var(--color-text-muted); white-space: nowrap; }
.product-search-empty { padding: 12px; font-size: 13px; color: var(--color-text-muted); text-align: center; }

/* ---------- Barra de búsqueda ---------- */
.search-card { margin-bottom: var(--space-4); }
.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: var(--space-3) var(--space-4);
    width: 100%;
}
.search-bar .search-bar-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
}
.search-bar .form-control { flex: 1; min-width: 0; }
.search-bar .btn { flex-shrink: 0; }

/* Quitar la "X" nativa del input type=search para no superponerse con el botón Limpiar */
input[type="search"].form-control::-webkit-search-cancel-button,
input[type="search"].form-control::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
input[type="search"].form-control::-ms-clear { display: none; }

/* ---------- Acciones rápidas (Panel) ---------- */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}
.quick-action {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 22px 24px;
    border-radius: var(--radius-lg);
    color: #fff;
    text-decoration: none;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}
.quick-action:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-strong);
    text-decoration: none;
    color: #fff;
}
.quick-action .qa-icon {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.22);
    display: flex;
    align-items: center;
    justify-content: center;
}
.quick-action .qa-title { font-size: 22px; font-weight: 800; line-height: 1.1; }
.quick-action .qa-sub { font-size: 13px; opacity: 0.95; margin-top: 3px; }
.quick-action .qa-chevron { margin-left: auto; opacity: 0.9; flex-shrink: 0; }
.qa-entry { background: linear-gradient(135deg, #16a34a, #15803d); }
.qa-exit { background: linear-gradient(135deg, #dc2626, #b91c1c); }

/* Opción activa del combobox de producto */
.product-search-option.active { background: var(--color-primary-soft); }
