/* ===========================================================================
   AP Velas CRM — Estilos compartidos al estilo TailAdmin
   Redefine clases tipo Bootstrap (.form-control, .btn, .card...) con look
   TailAdmin (cards limpias, inputs con focus ring azul, sidebar oscuro).
   Pensado para usarse junto a Tailwind CDN — convive sin colisiones.
   =========================================================================== */

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    background-color: #f1f5f9; /* slate-100 */
    color: #1e293b;            /* slate-800 */
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ====== Inputs / Forms (compat. Bootstrap-ish) ====== */

.form-label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #334155; /* slate-700 */
}

.form-control,
.form-select,
input[type="text"].form-control,
input[type="number"].form-control,
input[type="email"].form-control,
input[type="password"].form-control,
input[type="date"].form-control,
textarea.form-control {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: #0f172a;            /* slate-900 */
    background-color: #fff;
    border: 1px solid #cbd5e1; /* slate-300 */
    border-radius: 0.5rem;
    transition: border-color .15s, box-shadow .15s;
    appearance: none;
}

.form-control:focus,
.form-select:focus,
textarea.form-control:focus {
    outline: none;
    border-color: #3b82f6;     /* blue-500 */
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.form-control[readonly], .form-control:disabled {
    background-color: #f8fafc; /* slate-50 */
    color: #64748b;            /* slate-500 */
}

.form-control.form-control-sm, .form-select.form-select-sm {
    padding: 0.375rem 0.5rem;
    font-size: 0.8125rem;
}

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 14px;
    padding-right: 2.25rem;
}

/* Checkboxes / radios */
.form-check { display: flex; align-items: center; gap: 0.5rem; }
.form-check-input {
    width: 1rem; height: 1rem; accent-color: #2563eb;
    border-radius: 0.25rem; cursor: pointer;
}
.form-check-label { font-size: 0.875rem; color: #334155; cursor: pointer; }

/* Switch */
.form-switch .form-check-input {
    width: 2.5rem; height: 1.25rem; border-radius: 999px; appearance: none;
    background: #cbd5e1; position: relative; transition: background .15s;
    cursor: pointer;
}
.form-switch .form-check-input::before {
    content: ""; position: absolute; top: 2px; left: 2px;
    width: 1rem; height: 1rem; border-radius: 999px; background: #fff;
    transition: transform .15s;
}
.form-switch .form-check-input:checked { background: #2563eb; }
.form-switch .form-check-input:checked::before { transform: translateX(1.25rem); }

/* Input groups: filas horizontales (insumos en producto) */
.input-group {
    display: flex; align-items: stretch; flex-wrap: wrap; gap: 0.5rem;
    margin-bottom: 0.75rem;
}
.input-group > .form-control,
.input-group > .form-select { flex: 1 1 auto; min-width: 6rem; }

/* ====== Botones ====== */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem; font-weight: 500;
    border: 1px solid transparent;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
    text-decoration: none;
    line-height: 1.25;
}
.btn:disabled, .btn.disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8125rem; border-radius: 0.375rem; }
.btn-lg { padding: 0.75rem 1.25rem; font-size: 0.9375rem; }
.btn-block, .w-100 { width: 100%; }

.btn-primary             { background: #2563eb; color: #fff; }
.btn-primary:hover       { background: #1d4ed8; }
.btn-secondary           { background: #fff; color: #334155; border-color: #cbd5e1; }
.btn-secondary:hover     { background: #f1f5f9; }
.btn-success             { background: #16a34a; color: #fff; }
.btn-success:hover       { background: #15803d; }
.btn-danger              { background: #dc2626; color: #fff; }
.btn-danger:hover        { background: #b91c1c; }
.btn-warning             { background: #f59e0b; color: #fff; }
.btn-warning:hover       { background: #d97706; }
.btn-info                { background: #0ea5e9; color: #fff; }
.btn-info:hover          { background: #0284c7; }
.btn-outline-secondary   { background: transparent; border-color: #cbd5e1; color: #475569; }
.btn-outline-secondary:hover { background: #f1f5f9; }
.btn-outline-primary     { background: transparent; border-color: #2563eb; color: #2563eb; }
.btn-outline-primary:hover   { background: #eff6ff; }
.btn-outline-dark        { background: transparent; border-color: #334155; color: #334155; }
.btn-outline-dark:hover  { background: #f1f5f9; }

/* ====== Cards ====== */
.card {
    background: #fff;
    border: 1px solid #e2e8f0; /* slate-200 */
    border-radius: 1rem;
    box-shadow: 0 1px 2px rgba(15,23,42,0.04);
    overflow: hidden;
}
.card + .card { margin-top: 1.25rem; }
.card-body { padding: 1.5rem; }
.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    font-weight: 600;
}
.card-title { font-size: 1rem; font-weight: 600; color: #0f172a; margin: 0 0 0.5rem; }

/* ====== Tablas ====== */
.table {
    width: 100%;
    background: #fff;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem;
}
.table thead th {
    background: #f8fafc;
    color: #64748b;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.025em;
    font-weight: 600;
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}
.table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    color: #1e293b;
    vertical-align: middle;
}
.table tbody tr:hover td { background: #f8fafc; }
.table-striped tbody tr:nth-child(odd) td { background: #fafbfc; }
.table-bordered, .table-bordered td, .table-bordered th { border: 1px solid #e2e8f0; }
.table-hover tbody tr:hover td { background: #f1f5f9; }
.table.align-middle td, .table.align-middle th { vertical-align: middle; }
.table-responsive { overflow-x: auto; }

/* Color helper headers que usan thead-dark / table-dark */
.table-dark, .table thead.table-dark th, .table .thead-dark th {
    background: #0f172a; color: #e2e8f0;
}

/* ====== Paginación ====== */
.pagination {
    display: inline-flex; gap: 0.25rem;
    list-style: none; padding: 0; margin: 1rem 0;
}
.page-item .page-link {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 2.25rem; height: 2.25rem;
    padding: 0 0.625rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    background: #fff; color: #334155;
    font-size: 0.875rem; text-decoration: none;
    transition: background .15s, color .15s;
}
.page-item .page-link:hover { background: #f1f5f9; }
.page-item.active .page-link { background: #2563eb; color: #fff; border-color: #2563eb; }
.page-item.disabled .page-link { opacity: 0.5; pointer-events: none; }

/* ====== Shell: Sidebar + Header (CSS regular, no depende de Tailwind) ====== */
.ta-sidebar {
    width: 18rem;
    height: 100vh;
    background: #0f172a; /* slate-900 */
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.ta-sidebar-brand {
    height: 4rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.5rem;
    border-bottom: 1px solid #1e293b;
}
.ta-sidebar-brand-logo {
    width: 2.25rem; height: 2.25rem;
    border-radius: 0.5rem;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: #fff; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.ta-sidebar-brand-text { color: #fff; font-weight: 600; line-height: 1.1; }
.ta-sidebar-brand-sub  { color: #94a3b8; font-size: 0.75rem; line-height: 1.1; }
.ta-sidebar-nav {
    flex: 1; overflow-y: auto;
    padding: 1rem 0.75rem;
    display: flex; flex-direction: column; gap: 0.25rem;
}
.ta-sidebar-section {
    padding: 0.5rem 0.75rem 0.25rem;
    font-size: 0.7rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: #64748b;
}
.ta-sidebar-section + .ta-sidebar-section { margin-top: 0.5rem; }
.ta-sidebar-footer {
    padding: 1rem; border-top: 1px solid #1e293b;
}

.ta-header {
    height: 4rem;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    flex-shrink: 0;
}
@media (min-width: 1024px) { .ta-header { padding: 0 1.5rem; } }

.ta-app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}
.ta-app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}
.ta-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}
@media (min-width: 1024px) { .ta-content { padding: 2rem; } }

/* ====== Sidebar links ====== */
.sidebar-link {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    border-radius: 0.625rem;
    color: #cbd5e1;            /* slate-300 */
    font-size: 0.9rem; font-weight: 500;
    transition: background .15s, color .15s;
    text-decoration: none;
}
.sidebar-link:hover { background: #1e293b; color: #fff; }
.sidebar-link.active {
    background: linear-gradient(90deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37,99,235,0.4);
}
.sidebar-link.active svg { color: #fff; }

/* ====== Badges de estado ====== */
.badge { display: inline-flex; align-items: center; padding: 0.25rem 0.625rem;
    font-size: 0.75rem; font-weight: 600; border-radius: 9999px; }
.badge-warning  { background: #fef3c7; color: #92400e; }
.badge-success  { background: #d1fae5; color: #065f46; }
.badge-danger   { background: #fee2e2; color: #991b1b; }
.badge-info     { background: #dbeafe; color: #1e40af; }
.badge-neutral  { background: #e2e8f0; color: #334155; }

/* Compat para badges con Bootstrap-style bg-* */
.badge.bg-success    { background: #16a34a; color: #fff; }
.badge.bg-secondary  { background: #94a3b8; color: #fff; }
.badge.bg-info       { background: #0ea5e9; color: #fff; }
.badge.bg-warning    { background: #f59e0b; color: #fff; }
.badge.bg-danger     { background: #dc2626; color: #fff; }
.text-dark           { color: #0f172a !important; }
.rounded             { border-radius: 0.5rem; }

.estado-pendiente { color: #b45309; font-weight: 600; }
.estado-recibida  { color: #15803d; font-weight: 600; }
.estado-cancelada { color: #b91c1c; font-weight: 600; text-decoration: line-through; }
.estado-pagada    { color: #15803d; font-weight: 600; }

/* ====== Modal helper (clases custom, gestionado por TA.modal) ====== */
.ta-modal {
    position: fixed; inset: 0; z-index: 60;
    background: rgba(15,23,42,0.5);
    backdrop-filter: blur(2px);
    align-items: flex-start; justify-content: center;
    padding: 2rem 1rem;
    overflow-y: auto;
}
.ta-modal.hidden { display: none; }
.ta-modal:not(.hidden) { display: flex; }
.ta-modal-dialog {
    background: #fff; border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    width: 100%; max-width: 42rem;
    display: flex; flex-direction: column;
    max-height: calc(100vh - 4rem);
}
.ta-modal-dialog.modal-lg { max-width: 56rem; }
.ta-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.5rem; border-bottom: 1px solid #e2e8f0;
}
.ta-modal-title { font-size: 1.0625rem; font-weight: 600; color: #0f172a; margin: 0; }
.ta-modal-close {
    background: transparent; border: 0; cursor: pointer;
    color: #64748b; font-size: 1.5rem; line-height: 1; padding: 0.25rem;
}
.ta-modal-close:hover { color: #0f172a; }
.ta-modal-body { padding: 1.25rem 1.5rem; overflow-y: auto; flex: 1 1 auto; }
.ta-modal-footer {
    display: flex; justify-content: flex-end; gap: 0.5rem;
    padding: 1rem 1.5rem; border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 0 0 1rem 1rem;
}

/* ====== Tabs (custom data-tab) ====== */
.ta-tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid #e2e8f0; margin-bottom: 1rem; }
.ta-tab-btn {
    padding: 0.625rem 1rem; font-size: 0.875rem; font-weight: 500;
    background: transparent; border: 0; border-bottom: 2px solid transparent;
    color: #64748b; cursor: pointer; transition: color .15s, border-color .15s;
}
.ta-tab-btn:hover { color: #1e40af; }
.ta-tab-btn.active { color: #2563eb; border-color: #2563eb; }
.ta-tab-pane.hidden { display: none; }

/* ====== Utilidades varias ====== */
.text-muted { color: #94a3b8 !important; }
.text-success { color: #16a34a !important; }
.text-danger { color: #dc2626 !important; }
.fw-bold { font-weight: 600 !important; }
.text-center { text-align: center; }
.text-end { text-align: right; }
.bg-light { background: #f8fafc !important; }

/* Autocomplete jQuery-UI */
.ui-autocomplete {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1); padding: 0.25rem; z-index: 2000;
    list-style: none;
}
.ui-autocomplete .ui-menu-item {
    padding: 0.5rem 0.75rem; border-radius: 0.375rem;
    font-size: 0.875rem; cursor: pointer;
}
.ui-autocomplete .ui-menu-item:hover,
.ui-autocomplete .ui-menu-item.ui-state-active {
    background: #eff6ff; color: #1e40af;
}

/* Scrollbar prolijo */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Sidebar móvil */
@media (max-width: 1023px) {
    #sidebar-container { position: fixed; inset: 0 auto 0 0; z-index: 50;
        transform: translateX(-100%); transition: transform .2s; }
    #sidebar-container.open { transform: translateX(0); }
    #sidebar-backdrop { position: fixed; inset: 0; z-index: 45; background: rgba(15,23,42,0.5); }
    #sidebar-backdrop.hidden { display: none; }
}
@media (min-width: 1024px) {
    #sidebar-backdrop { display: none !important; }
    .ta-sidebar { width: 18rem; }
}
@media (max-width: 1023px) {
    .ta-sidebar { width: 17rem; }
    .ta-header-hamburger { display: inline-flex !important; }
}
.ta-header-hamburger { display: none; }
