/* ---------------------------------------------------------------------
   Enlace de Stock — panel interno
   Paleta inspirada en sixmotors.com.ar (rubro repuestos/accesorios):
   base oscura + acento naranja. Tipografía del sistema (sin depender de
   internet para fuentes, ya que este panel se usa desde el local).
--------------------------------------------------------------------- */

:root {
    --bg: #f3f4f6;
    --panel-dark: #16181d;
    --panel-dark-2: #1f2229;
    --accent: #e8590c;
    --accent-hover: #ff7a1a;
    --text-main: #1c1c1e;
    --text-muted: #6b7280;
    --white: #ffffff;
    --border: #e5e7eb;
    --success: #15803d;
    --warning: #b45309;
    --danger: #b91c1c;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
}

a { color: inherit; text-decoration: none; }

/* ---------- Layout general con sidebar ---------- */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--panel-dark);
    color: #d1d5db;
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
}

.sidebar .logo-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 6px 20px 6px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 16px;
}

.sidebar .logo-box img {
    max-width: 100%;
    max-height: 46px;
    object-fit: contain;
}

.sidebar .logo-box .fallback-name {
    font-weight: 700;
    font-size: 16px;
    color: var(--white);
    letter-spacing: 0.5px;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #cbd0d8;
    font-weight: 500;
}

.sidebar nav a:hover {
    background: var(--panel-dark-2);
    color: var(--white);
}

.sidebar nav a.active {
    background: var(--accent);
    color: var(--white);
}

.sidebar .logout-link {
    padding: 10px 12px;
    border-radius: 8px;
    color: #9aa0aa;
    font-size: 13px;
}

.sidebar .logout-link:hover {
    color: var(--white);
}

.main-content {
    flex: 1;
    padding: 28px 32px;
    max-width: 100%;
    overflow-x: auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h1 {
    font-size: 22px;
    margin: 0;
}

.page-header .subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 2px;
}

/* ---------- Componentes comunes ---------- */

.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
    background: var(--accent);
    color: var(--white);
    transition: background 0.15s ease;
}

.btn:hover { background: var(--accent-hover); }

.btn.btn-secondary {
    background: var(--white);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn.btn-secondary:hover { background: #f5f5f5; }

.btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

input[type="text"], input[type="number"], input[type="password"], select {
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13.5px;
    background: var(--white);
    color: var(--text-main);
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(232, 89, 12, 0.15);
}

.search-box {
    width: 100%;
    max-width: 420px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

.thumb {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    object-fit: cover;
    background: #f0f0f0;
    border: 1px solid var(--border);
}

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
}

.badge-ml { background: #fff3cd; color: #7a5b00; }
.badge-tn { background: #d7ebff; color: #0a4a86; }
.badge-none { background: #f1f1f1; color: var(--text-muted); }

.stock-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 12.5px;
}

.stock-ok { background: #dcfce7; color: var(--success); }
.stock-low { background: #fef3c7; color: var(--warning); }
.stock-out { background: #fee2e2; color: var(--danger); }

.alert {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13.5px;
}

.alert-warning { background: #fef3c7; color: #7a4d00; border: 1px solid #fde68a; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #dcfce7; color: #14532d; border: 1px solid #bbf7d0; }

/* ---------- Login ---------- */

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--panel-dark);
}

.login-card {
    background: var(--white);
    border-radius: 14px;
    padding: 36px 32px;
    width: 100%;
    max-width: 340px;
    text-align: center;
}

.login-card img {
    max-width: 180px;
    max-height: 60px;
    object-fit: contain;
    margin-bottom: 18px;
}

.login-card h1 {
    font-size: 18px;
    margin: 0 0 20px 0;
}

.login-card form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-card .btn { margin-top: 6px; }

/* ---------- Panel de Ventas (POS) ---------- */

.pos-layout {
    display: flex;
    gap: 22px;
    align-items: flex-start;
}

.pos-products {
    flex: 1;
    min-width: 0;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
    margin-top: 16px;
}

.product-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    cursor: pointer;
    transition: box-shadow 0.15s ease, transform 0.1s ease;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}

.product-card.out-of-stock {
    opacity: 0.5;
    cursor: not-allowed;
}

.product-card img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 8px;
    background: #f0f0f0;
    margin-bottom: 8px;
}

.product-card .p-name {
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card .p-sku {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.product-card .p-price {
    font-weight: 700;
    color: var(--accent);
    font-size: 13.5px;
}

.product-card .p-stock {
    font-size: 11px;
    margin-top: 4px;
}

.cart-panel {
    width: 340px;
    flex-shrink: 0;
    position: sticky;
    top: 20px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 40px);
}

.cart-panel h2 {
    font-size: 15px;
    margin: 0 0 12px 0;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.cart-item {
    display: flex;
    gap: 8px;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

.cart-item img {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    background: #f0f0f0;
}

.cart-item-info { flex: 1; min-width: 0; }

.cart-item-info .name {
    font-size: 12.5px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cart-item-info .sku {
    font-size: 11px;
    color: var(--text-muted);
}

.qty-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.qty-controls button {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--white);
    cursor: pointer;
    font-weight: 700;
    line-height: 1;
}

.qty-controls span { width: 22px; text-align: center; font-weight: 600; font-size: 12.5px; }

.cart-item .line-price {
    width: 70px;
    text-align: right;
    font-size: 12.5px;
    font-weight: 700;
}

.cart-item .remove-btn {
    color: var(--danger);
    font-size: 16px;
    cursor: pointer;
    padding: 0 2px;
}

.cart-empty {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 30px 0;
}

.cart-footer {
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.cart-total {
    display: flex;
    justify-content: space-between;
    font-size: 16px;
    font-weight: 800;
    margin-bottom: 12px;
}

.cart-footer label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-muted);
}

.cart-footer select { width: 100%; margin-bottom: 12px; }

.cart-footer .btn { width: 100%; padding: 12px; font-size: 14.5px; }

/* ---------- Comprobante ---------- */

.receipt-box {
    max-width: 420px;
    margin: 0 auto;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.receipt-header {
    background: var(--accent);
    color: var(--white);
    padding: 18px 20px;
}

.receipt-header h2 { margin: 0; font-size: 18px; }
.receipt-header p { margin: 4px 0 0 0; font-size: 12.5px; opacity: 0.9; }

.receipt-body { padding: 18px 20px; }

.receipt-body table { margin-bottom: 12px; }
.receipt-body th, .receipt-body td { padding: 6px 4px; font-size: 12.5px; }

.receipt-total {
    display: flex;
    justify-content: space-between;
    font-size: 17px;
    font-weight: 800;
    border-top: 1px solid var(--border);
    padding-top: 10px;
    margin-top: 6px;
}

.receipt-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* ---------- Modal genérico (Nuevo producto) ---------- */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal-box {
    background: var(--white);
    border-radius: 14px;
    padding: 24px 26px;
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-box h2 {
    margin: 0 0 8px 0;
    font-size: 17px;
}

.modal-hint {
    font-size: 12.5px;
    color: var(--text-muted);
    margin: 0 0 16px 0;
    line-height: 1.4;
}

.modal-box form {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.modal-box label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 10px;
}

.modal-box input {
    width: 100%;
    margin-top: 4px;
}

.modal-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* ---------- Historial agrupado por día ---------- */

.dia-group {
    margin-bottom: 22px;
}

.dia-header {
    display: flex;
    align-items: baseline;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.dia-header h3 {
    margin: 0;
    font-size: 15px;
    text-transform: capitalize;
}

.dia-resumen {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.canal-section {
    margin-bottom: 10px;
}

.canal-section h4 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    margin: 0 0 6px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge-local { background: #ede9fe; color: #5b21b6; }
.badge-paused { background: #fee2e2; color: var(--danger); }

.btn-sm {
    padding: 6px 12px;
    font-size: 12.5px;
}

.btn-link {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 6px;
}

.btn-link:hover { text-decoration: underline; }

/* Barra de acciones masivas (Inventario) */
.bulk-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 14px;
    font-size: 13px;
    font-weight: 600;
    color: #7c2d12;
}

.bulk-sep {
    width: 1px;
    height: 20px;
    background: #fed7aa;
}

.bulk-percent-input {
    width: 70px;
    padding: 6px 8px !important;
}

/* Ficha de "Ver características" */
.ficha-caracteristicas {
    max-height: 60vh;
    overflow-y: auto;
}

.ficha-fila {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
}

.ficha-label {
    color: var(--text-muted);
    font-weight: 600;
    flex-shrink: 0;
}

.ficha-valor {
    text-align: right;
    word-break: break-word;
}

.ficha-separador {
    margin-top: 14px;
    margin-bottom: 4px;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 700;
}

/* Reportes: barras simples de comparación */
.reporte-bar-track {
    background: #f1f1f1;
    border-radius: 6px;
    height: 14px;
    overflow: hidden;
}

.reporte-bar {
    background: var(--accent);
    height: 100%;
    border-radius: 6px;
}

.icon-btn {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 8px;
    margin-right: 4px;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
}

.icon-btn:hover {
    background: #f3f4f6;
}

.icon-btn-danger:hover {
    background: #fde8e8;
    border-color: var(--danger);
}

@media print {
    .sidebar, .receipt-actions, .no-print { display: none !important; }
    .main-content { padding: 0 !important; }
    body { background: white !important; }
}

/* --- Agenda --- */
.agenda-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.agenda-nav-titulo {
    font-weight: 700;
    font-size: 14.5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.agenda-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(160px, 1fr));
    gap: 12px;
    overflow-x: auto;
}

@media (max-width: 1100px) {
    .agenda-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

.agenda-dia {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    min-height: 220px;
}

.agenda-dia-hoy {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(232, 89, 12, 0.15);
}

.agenda-dia-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.agenda-dia-nombre {
    font-weight: 700;
    font-size: 13.5px;
}

.agenda-dia-fecha {
    font-size: 12px;
    color: var(--text-muted);
}

.agenda-lista {
    list-style: none;
    margin: 0 0 10px 0;
    padding: 0;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.agenda-vacio {
    color: var(--text-muted);
    font-size: 12.5px;
    padding: 6px 0;
}

.agenda-tarea {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 13px;
    padding: 4px 0;
}

.agenda-tarea input[type="checkbox"] {
    margin-top: 3px;
    flex-shrink: 0;
}

.agenda-tarea-titulo {
    flex-grow: 1;
    word-break: break-word;
}

.agenda-tarea.completada .agenda-tarea-titulo {
    text-decoration: line-through;
    color: var(--text-muted);
}

.agenda-tarea-tipo {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 999px;
    flex-shrink: 0;
    white-space: nowrap;
}

.agenda-tarea-tipo-fija { background: #ede9fe; color: #5b21b6; }
.agenda-tarea-tipo-variable { background: #d7ebff; color: #0a4a86; }

.agenda-tarea-borrar {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    flex-shrink: 0;
    padding: 2px 4px;
}

.agenda-tarea-borrar:hover { color: var(--danger); }

.agenda-nueva-tarea {
    display: flex;
    gap: 4px;
    border-top: 1px solid var(--border);
    padding-top: 8px;
}

.agenda-nueva-tarea input[type="text"] {
    flex-grow: 1;
    min-width: 0;
    padding: 6px 8px;
    font-size: 12.5px;
}

.agenda-nueva-tarea select {
    padding: 6px 4px;
    font-size: 11px;
    max-width: 92px;
}

/* --- Anotaciones --- */
.anotaciones-estado {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.anotaciones-pendiente { color: var(--warning); }
.anotaciones-ok { color: var(--success); }
.anotaciones-error { color: var(--danger); }

.anotaciones-textarea {
    width: 100%;
    min-height: 60vh;
    border: none;
    outline: none;
    resize: vertical;
    font-size: 14.5px;
    line-height: 1.6;
    font-family: inherit;
    color: var(--text-main);
}

.analisis-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border, #e5e7eb);
}

.analisis-tab {
    padding: 10px 18px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.analisis-tab:hover {
    color: var(--text-main);
}

.analisis-tab.active {
    color: var(--accent);
    border-bottom: 2px solid var(--accent);
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
}
