* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", Arial, sans-serif;
    background: #f4f6f8;
    color: #333;
}

a { color: #1a73e8; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Login */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a2980, #26d0ce);
}

.login-box {
    background: #fff;
    padding: 2rem;
    border-radius: 8px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.login-title { margin: 0 0 0.25rem; font-size: 1.5rem; text-align: center; }
.login-subtitle { margin: 0 0 1.5rem; text-align: center; color: #666; font-size: 0.9rem; }

label { display: block; margin: 0.75rem 0 0.25rem; font-weight: 600; font-size: 0.9rem; }

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.55rem 0.6rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.95rem;
    background: #fff;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #1a73e8;
}

.btn {
    display: inline-block;
    padding: 0.55rem 1rem;
    border: none;
    border-radius: 4px;
    background: #1a73e8;
    color: #fff;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
}

.btn:hover { background: #1557b0; text-decoration: none; }
.btn-block { width: 100%; margin-top: 1rem; }
.btn-link { background: none; color: #1a73e8; padding: 0; font-size: 0.9rem; }
.btn-danger { background: #d93025; }
.btn-danger:hover { background: #b3261e; }
.btn-success { background: #188038; }
.btn-success:hover { background: #146c2e; }
.btn-info { background: #1a73e8; }
.btn-info:hover { background: #1557b0; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.ticket-list { font-family: "Courier New", monospace; font-size: 0.85rem; color: #555; }

/* Gráfico de barras (CSS) */
.bar-chart { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.6rem; }
.bar-row { display: flex; align-items: center; gap: 0.6rem; }
.bar-label { width: 220px; text-align: right; font-size: 0.85rem; color: #333; flex-shrink: 0; }
.bar-track { flex: 1; background: #eef1f5; border-radius: 4px; height: 26px; }
.bar-fill {
    height: 26px;
    border-radius: 4px;
    background: linear-gradient(90deg, #1a73e8, #26d0ce);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 0.5rem;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 0;
}
.bar-empty { text-align: center; color: #888; padding: 1.5rem; background: #fff; border: 1px solid #e3e6ea; border-radius: 8px; margin-top: 1rem; }

.print-status {
    margin-top: 1rem;
    padding: 0.6rem 0.9rem;
    border-radius: 4px;
    font-size: 0.85rem;
    background: #e8f0fe;
    color: #174ea6;
    border: 1px solid #cfe0fb;
}

.checkbox-label { display: flex; align-items: center; gap: 0.5rem; }
.hint { font-size: 0.8rem; color: #666; margin: 0.5rem 0 0; }

/* Alertas */
.alert { padding: 0.7rem 0.9rem; border-radius: 4px; margin-bottom: 1rem; font-size: 0.9rem; }
.alert-error { background: #fce8e6; color: #d93025; border: 1px solid #f5c6c2; }
.alert-success { background: #e6f4ea; color: #188038; border: 1px solid #c8e6c9; }
.alert-info { background: #e8f0fe; color: #174ea6; border: 1px solid #c5d6f2; }

/* Layout con menú vertical a la izquierda */
.app { display: flex; min-height: 100vh; }

/* Topbar con hamburguesa */
.topbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.25rem;
    background: #fff;
    border-bottom: 1px solid #e3e6ea;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-brand { font-weight: 700; color: #1a2980; font-size: 1.05rem; }

.topbar-logout {
    margin-left: auto;
    color: #d93025;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}
.topbar-logout:hover { color: #b3261e; text-decoration: underline; }

.menu-toggle {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 28px;
    height: 20px;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
}
.menu-toggle span {
    display: block;
    height: 3px;
    width: 100%;
    background: #1a2980;
    border-radius: 2px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}
.menu-toggle.open span:nth-child(1) { transform: translateY(8.5px) rotate(45deg); }
.menu-toggle.open span:nth-child(2) { opacity: 0; }
.menu-toggle.open span:nth-child(3) { transform: translateY(-8.5px) rotate(-45deg); }

.sidebar {
    width: 230px;
    flex-shrink: 0;
    background: #1a2980;
    color: #fff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.app.menu-open .sidebar { display: none; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 40;
}

.sidebar-brand {
    font-weight: 700;
    font-size: 1.1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.sidebar-nav { display: flex; flex-direction: column; margin-top: 0.75rem; flex: 1; }
.sidebar-nav a.menu-link {
    color: #c7d2fe;
    padding: 0.7rem 1.25rem;
    text-decoration: none;
}
.sidebar-nav a.menu-link:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.sidebar-nav a.menu-link.active {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-left: 3px solid #26d0ce;
}

.menu-group { display: flex; flex-direction: column; }
.menu-parent {
    display: block;
    color: #c7d2fe;
    padding: 0.7rem 1.25rem;
    cursor: pointer;
    user-select: none;
}
.menu-parent:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.menu-sub { display: none; }
.menu-group.open .menu-sub { display: block; }
.menu-sub-link {
    display: block;
    color: #b3bff0;
    padding: 0.5rem 1.25rem 0.5rem 2.25rem;
    font-size: 0.85rem;
    text-decoration: none;
    border-left: 3px solid transparent;
}
.menu-sub-link:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.menu-sub-link.active {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border-left: 3px solid #26d0ce;
}

.sidebar-user {
    padding: 0.9rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.sidebar-user small { color: #c7d2fe; }
.btn-sidebar { color: #26d0ce; padding: 0; margin-top: 0.35rem; font-size: 0.85rem; }

.content { flex: 1; display: flex; flex-direction: column; }

/* Contenedor y tarjetas */
.container { max-width: 1000px; margin: 1.5rem auto; padding: 0 1.5rem; flex: 1; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}

.form-actions { display: flex; gap: 0.5rem; margin-top: 1rem; align-items: center; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin-top: 1rem; }

.card {
    background: #fff;
    border: 1px solid #e3e6ea;
    border-radius: 8px;
    padding: 1.25rem;
}

.card h3 { margin: 0 0 0.5rem; }

/* Tarjetas compactas en una sola línea */
.card-grid-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: stretch;
}
.stat-mini {
    background: #f8f9fa;
    border: 1px solid #e3e6ea;
    border-radius: 6px;
    padding: 0.5rem 0.9rem;
    flex: 1 1 auto;
    min-width: 140px;
    display: flex;
    flex-direction: column;
}
.stat-mini span { font-size: 0.75rem; color: #888; text-transform: uppercase; letter-spacing: 0.4px; }
.stat-mini strong { font-size: 1.05rem; font-weight: 700; color: #174ea6; margin-top: 0.15rem; }

/* Tarjetas de estadísticas */
.stat-card { text-align: center; padding: 1.5rem 1.25rem; }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; margin: 0.25rem 0 0; color: #174ea6; }
.stat-card .stat-sub { margin: 0.35rem 0 0; font-size: 0.85rem; color: #888; }
.pagos-lista { list-style: none; margin: 0.5rem 0 0; padding: 0; text-align: left; }
.pagos-lista li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 0;
    border-bottom: 1px dashed #e3e6ea;
    font-size: 0.9rem;
}
.pagos-lista li:last-child { border-bottom: none; }

/* Tablas */
.table { width: 100%; border-collapse: collapse; background: #fff; margin-top: 1rem; }
.table th, .table td { border: 1px solid #e3e6ea; padding: 0.55rem 0.7rem; text-align: left; font-size: 0.9rem; }
.table th { background: #f1f3f5; }

/* Reportes */
.report-header {
    max-width: 220mm;
    margin: 0 auto 1rem;
    font-family: "Courier New", monospace;
    font-size: 12px;
    color: #000;
}
.report-num { font-size: 1.5rem; font-weight: 700; margin: 0.25rem 0; }

/* Validación de tickets */
.scan-input {
    font-size: 1.25rem;
    padding: 0.8rem 0.9rem;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Nueva venta: layout de dos columnas (datos + juegos) */
.venta-layout {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 1.5rem;
    align-items: start;
}
.venta-layout > * { min-width: 0; }
.venta-left label,
.venta-left input,
.venta-left select {
    display: block;
    width: 100%;
    margin-bottom: 0.75rem;
}
.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
.venta-right-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}
.venta-right-head h3 { margin: 0; }
.venta-left-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}
.venta-left-head h3 { margin: 0; }
.promos-panel {
    border: 1px solid #cfe8ff;
    background: #f1f9ff;
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    margin-top: 0.75rem;
}
.promo-item {
    font-size: 0.85rem;
    padding: 0.25rem 0;
}
.promo-item + .promo-item {
    border-top: 1px dashed #cfe8ff;
}
@media (max-width: 600px) {
    .form-row-2 { grid-template-columns: 1fr; }
}
.venta-right .juego-table th:nth-child(1) { text-align: left; }
.venta-right .juego-table th:nth-child(3) { width: 70px; }
.venta-right .juego-table th:nth-child(4) { width: 100px; }
.venta-right .juego-table td:nth-child(1) { text-align: left; }
.venta-right .juego-table .juego-cant { width: 60px; }

/* Catálogo de juegos estilo jTable: buscador + scroll con altura limitada a la pantalla */
.jtable-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    background: #f1f3f5;
    border: 1px solid #e3e6ea;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    padding: 0.5rem 0.6rem;
    margin-top: 1rem;
}
.jtable-toolbar input[type="search"] {
    width: 220px;
    padding: 0.45rem 0.6rem;
    margin: 0;
    font-size: 0.85rem;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
}
.jtable-scroll {
    max-height: calc(100vh - 280px);
    min-height: 120px;
    overflow-y: auto;
    border: 1px solid #e3e6ea;
    border-radius: 0 0 8px 8px;
    background: #fff;
}
.jtable-scroll .table {
    margin-top: 0;
    border: none;
}
.jtable-scroll .table thead th {
    position: sticky;
    top: 0;
    background: #e9edf2;
    z-index: 2;
    box-shadow: inset 0 -1px 0 #d5dbe3;
}
.jtable-empty {
    border: 1px dashed #d0d5dd;
    border-radius: 8px;
    background: #fafbfc;
    color: #667085;
    text-align: center;
    padding: 1rem;
    font-size: 0.9rem;
    margin-top: 0.75rem;
}

@media (max-width: 900px) {
    .venta-layout { grid-template-columns: 1fr; }
}

/* Responsive: menú lateral en móvil */
@media (max-width: 768px) {
    .app { flex-direction: column; }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 260px;
        max-width: 85vw;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 60;
        box-shadow: 4px 0 16px rgba(0, 0, 0, 0.3);
    }
    .app.menu-open .sidebar {
        display: flex;
        transform: translateX(0);
    }
    .app.menu-open .sidebar-overlay { display: block; }
    .app:not(.menu-open) .sidebar-overlay { display: none; }

    .topbar {
        position: sticky;
        top: 0;
        z-index: 50;
    }

    .container { padding: 0 0.8rem; margin: 1rem auto; }

    .table { font-size: 0.82rem; }
    .table th, .table td { padding: 0.45rem 0.5rem; }

    .card-grid, .form-grid { grid-template-columns: 1fr; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar select, .filter-bar input[type="date"] { width: 100%; }

    .jtable-toolbar input[type="search"] { width: 100%; }
    .line-scroll { height: 300px; }

    .ticket-page, .ticket { width: 100%; }
}

@media (max-width: 380px) {
    .venta-right-head,
    .venta-left-head { flex-direction: column; align-items: flex-start; gap: 0.4rem; }
    .vista-acciones, .venta-actions { flex-wrap: wrap; }
}

/* Utilidades */
.mt { margin-top: 1rem; }
.mb { margin-bottom: 1rem; }
.text-right { text-align: right; }
.text-center { text-align: center; }

.footer { text-align: center; color: #888; font-size: 0.8rem; padding: 1.5rem 0; }

/* Filtros y estados */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
    background: #fff;
    border: 1px solid #e3e6ea;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

.filter-bar label { margin: 0; }
.filter-bar select { width: auto; }
.filter-bar input[type="date"] { width: auto; }

.badge { padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge-ok { background: #e6f4ea; color: #188038; }
.badge-warn { background: #fef7e0; color: #b06000; }
.badge-danger { background: #fce8e6; color: #d93025; }

/* Tabla de líneas de venta */
.line-table {
    width: 100%;
    table-layout: fixed;
}
.line-table th { overflow: hidden; }
.line-table th:nth-child(1) { width: auto; }
.line-table th:nth-child(2) { width: 90px; }
.line-table th:nth-child(3) { width: 70px; }
.line-table th:nth-child(4) { width: 100px; }
.line-table th:nth-child(5) { width: 95px; }
.line-table .subtotal { background: #f1f3f5; width: 90px; text-align: right; }
.line-table .celda-subtotal { display: block; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-table .celda-cant { display: block; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-table .celda-precio { display: block; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-table td:nth-child(1) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Líneas de la venta (jTable): tamaño fijo igual si está vacío o con registros */
.line-scroll {
    height: calc(100vh - 330px);
    min-height: 150px;
}
.line-scroll .table thead th {
    position: sticky;
    top: 0;
    background: #e9edf2;
    z-index: 2;
    box-shadow: inset 0 -1px 0 #d5dbe3;
}

/* Acción de nueva venta siempre visible en la parte inferior de la pantalla */
.venta-actions {
    position: sticky;
    bottom: 0;
    background: linear-gradient(to top, #fff 85%, transparent);
    padding: 0.75rem 0 0.35rem;
    margin-top: 0.5rem;
    z-index: 20;
    gap: 0.75rem;
}
.venta-actions .btn { padding: 0.65rem 1.4rem; font-size: 1rem; }

.total-bar {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    align-items: center;
    font-size: 1.15rem;
    margin: 0;
}
.venta-left-head .total-bar strong { color: #188038; }

/* Tickets — formato ticketera térmica 80 mm */
.ticket-page { width: 80mm; margin: 0 auto; }

.ticket {
    width: 80mm;
    box-sizing: border-box;
    padding: 3mm 2mm;
    font-family: "Courier New", "DejaVu Sans Mono", monospace;
    font-size: 11px;
    line-height: 1.4;
    color: #000;
    background: #fff;
}

.ticket-center { text-align: center; }
.ticket-empresa { font-weight: 700; text-transform: uppercase; font-size: 15px; letter-spacing: 0.5px; }
.ticket-sub { font-size: 10px; }
.ticket-logo { max-height: 14mm; max-width: 72mm; }
.ticket-title { font-weight: 700; font-size: 14px; letter-spacing: 1px; }
.ticket-code { font-size: 13px; font-weight: 700; }
.ticket-game { font-weight: 700; font-size: 14px; margin: 1mm 0; }
.ticket-total { font-weight: 700; font-size: 13px; }
.ticket-free { font-size: 16px; letter-spacing: 1px; margin: 1mm 0; }
.ticket-payment { font-weight: 700; font-size: 15px; letter-spacing: 1px; margin: 1mm 0; }
.ticket-attended { font-weight: 700; font-size: 13px; margin-top: 1mm; }
.ticket-note { font-weight: 700; text-align: center; }

.barcode {
    display: flex;
    justify-content: center;
    align-items: stretch;
    height: 8mm;
    margin: 1.5mm auto 0;
}
.barcode span { display: block; height: 100%; flex-shrink: 0; }

.row { display: flex; justify-content: space-between; }
.dashed { border-top: 1px dashed #000; margin: 1.5mm 0; }

@media print {
    @page { size: 80mm auto; margin: 0; }
    body { background: #fff; }
    .sidebar, .no-print, .footer, .topbar { display: none !important; }
    .container { margin: 0; max-width: 100%; padding: 0; }
    .ticket { page-break-after: always; }
}
