/* =============================================
   SISTEMA POS - Estilos Globales
   Moderno, Minimalista, Responsive, Táctil
   ============================================= */

:root {
    --primary:     #2563eb;
    --primary-dark:#1d4ed8;
    --secondary:   #64748b;
    --success:     #16a34a;
    --danger:      #dc2626;
    --warning:     #d97706;
    --light:       #f8fafc;
    --dark:        #1e293b;
    --border:      #e2e8f0;
    --radius:      12px;
    --radius-sm:   8px;
    --shadow:      0 2px 12px rgba(0,0,0,.08);
    --shadow-md:   0 4px 24px rgba(0,0,0,.12);
    --transition:  .18s ease;
    --font:        'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
    font-family: var(--font);
    background: #f1f5f9;
    color: var(--dark);
    min-height: 100vh;
    line-height: 1.5;
}

/* ─── NAVBAR ─────────────────────────────── */
.navbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .75rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    min-width: 130px;
}

.nav-icon { font-size: 1.5rem; }

.nav-links {
    display: flex;
    gap: .25rem;
    flex: 1;
}

.nav-links a {
    text-decoration: none;
    color: var(--secondary);
    padding: .6rem 1.1rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: .95rem;
    transition: background var(--transition), color var(--transition);
}

.nav-links a:hover,
.nav-links a.active {
    background: #eff6ff;
    color: var(--primary);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: .75rem;
    font-size: .9rem;
    color: var(--secondary);
}

.btn-logout {
    text-decoration: none;
    background: #fee2e2;
    color: var(--danger);
    padding: .45rem .9rem;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    font-weight: 600;
    transition: background var(--transition);
}
.btn-logout:hover { background: #fecaca; }

/* ─── MAIN CONTENT ────────────────────────── */
.main-content {
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* ─── FOOTER ──────────────────────────────── */
.footer {
    text-align: center;
    padding: 1rem;
    color: var(--secondary);
    font-size: .8rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

/* ─── LOGIN ───────────────────────────────── */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 1rem;
}

.login-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow-md);
    text-align: center;
}

.login-logo { font-size: 3rem; margin-bottom: .75rem; }

.login-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: .25rem;
}

.login-subtitle {
    color: var(--secondary);
    margin-bottom: 1.75rem;
    font-size: .95rem;
}

.login-hint {
    margin-top: 1.25rem;
    color: var(--secondary);
    font-size: .82rem;
}

/* ─── FORMS ───────────────────────────────── */
.form-group {
    margin-bottom: 1.1rem;
    text-align: left;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: .4rem;
    font-size: .9rem;
    color: var(--dark);
}

.form-control {
    width: 100%;
    padding: .75rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: var(--font);
    color: var(--dark);
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
    -webkit-appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

select.form-control { cursor: pointer; }

/* ─── BUTTONS ─────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .7rem 1.4rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: .95rem;
    font-family: var(--font);
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    min-height: 44px; /* táctil */
}

.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }

.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }

.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #b91c1c; }

.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { background: #475569; }

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--dark);
}
.btn-outline:hover { background: var(--light); }

.btn-sm { padding: .4rem .85rem; font-size: .85rem; min-height: 36px; }
.btn-lg { padding: .95rem 2rem; font-size: 1.1rem; min-height: 52px; }
.btn-block { width: 100%; }

/* ─── ALERTS ──────────────────────────────── */
.alert {
    padding: .85rem 1.1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-weight: 500;
    font-size: .95rem;
}

.alert-success { background: #dcfce7; color: #166534; border-left: 4px solid var(--success); }
.alert-error   { background: #fee2e2; color: #991b1b; border-left: 4px solid var(--danger); }
.alert-warning { background: #fef3c7; color: #92400e; border-left: 4px solid var(--warning); }

/* ─── CARDS ───────────────────────────────── */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
}

.card-header h2, .card-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--dark);
}

.card-body { padding: 1.25rem; }

/* ─── PAGE HEADER ─────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem;
    margin-bottom: 1.25rem;
}

.page-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--dark);
}

/* ─── TABLE ───────────────────────────────── */
.table-responsive { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .92rem;
}

thead th {
    background: var(--light);
    color: var(--secondary);
    font-weight: 600;
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: .75rem 1rem;
    text-align: left;
    border-bottom: 2px solid var(--border);
}

tbody td {
    padding: .8rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

/* ─── BADGES ──────────────────────────────── */
.badge {
    display: inline-block;
    padding: .25rem .6rem;
    border-radius: 50px;
    font-size: .78rem;
    font-weight: 600;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }

/* ─── POS LAYOUT ──────────────────────────── */
.pos-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.25rem;
    align-items: start;
}

.pos-products { }

.pos-search {
    display: flex;
    gap: .5rem;
    margin-bottom: 1.1rem;
}

.pos-search .form-control { flex: 1; }

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: .75rem;
}

.product-card {
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem .75rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
}

.product-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 16px rgba(37,99,235,.12);
    transform: translateY(-2px);
}

.product-card:active { transform: scale(.97); }

.product-card.sin-stock {
    opacity: .5;
    cursor: not-allowed;
}

.product-img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 8px;
    margin: 0 auto .4rem;
    display: block;
}

.product-avatar {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    margin: 0 auto .4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 1.6rem;
}

.product-name {
    font-weight: 600;
    font-size: .88rem;
    color: var(--dark);
    margin-bottom: .3rem;
    line-height: 1.3;
}

.product-price {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
}

.product-stock {
    font-size: .75rem;
    color: var(--secondary);
    margin-top: .2rem;
}

/* ─── CARRITO ─────────────────────────────── */
.cart-panel {
    position: sticky;
    top: 80px;
}

.cart-items { max-height: 40vh; overflow-y: auto; }

.cart-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 0;
    border-bottom: 1px solid var(--border);
}

.cart-item:last-child { border-bottom: none; }

.cart-item-name {
    flex: 1;
    font-weight: 500;
    font-size: .9rem;
}

.cart-qty {
    display: flex;
    align-items: center;
    gap: .3rem;
}

.qty-btn {
    width: 30px;
    height: 30px;
    border: 1.5px solid var(--border);
    background: var(--light);
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background var(--transition);
}

.qty-btn:hover { background: var(--border); }

.qty-num {
    min-width: 28px;
    text-align: center;
    font-weight: 700;
    font-size: .95rem;
}

.cart-item-sub {
    font-weight: 700;
    color: var(--primary);
    min-width: 70px;
    text-align: right;
    font-size: .92rem;
}

.cart-remove {
    background: none;
    border: none;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 1.1rem;
    padding: .2rem;
    transition: color var(--transition);
}
.cart-remove:hover { color: var(--danger); }

.cart-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--secondary);
    font-size: .9rem;
}

.cart-totals {
    border-top: 2px solid var(--border);
    padding-top: 1rem;
    margin-top: .5rem;
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .3rem 0;
    font-size: .95rem;
}

.total-row.grand {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--dark);
    padding-top: .5rem;
    border-top: 1px solid var(--border);
    margin-top: .3rem;
}

.total-row.cambio {
    color: var(--success);
    font-weight: 700;
    font-size: 1.05rem;
}

/* ─── MODAL ───────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 500;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.open { display: flex; }

.modal {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp .2s ease;
}

@keyframes slideUp {
    from { transform: translateY(24px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 1.1rem; font-weight: 700; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--secondary);
    line-height: 1;
    padding: .2rem;
}

.modal-body { padding: 1.5rem; }

.modal-footer {
    display: flex;
    gap: .75rem;
    justify-content: flex-end;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

/* ─── TICKET IMPRESIÓN ────────────────────── */
@media print {
    .navbar, .footer, .no-print { display: none !important; }
    body { background: #fff; }
    .ticket { max-width: 300px; margin: 0 auto; font-size: 12px; }
}

/* ─── RESPONSIVE ──────────────────────────── */
@media (max-width: 900px) {
    .pos-layout {
        grid-template-columns: 1fr;
    }
    .cart-panel { position: static; }
    .cart-items { max-height: 35vh; }
}

@media (max-width: 600px) {
    .navbar { padding: .65rem 1rem; }
    .nav-brand span { display: none; }
    .main-content { padding: 1rem .75rem; }
    .product-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
    .page-header { flex-direction: column; align-items: flex-start; }
    thead { display: none; }
    tbody tr { display: block; margin-bottom: .75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }
    tbody td { display: flex; justify-content: space-between; padding: .5rem .75rem; border-bottom: 1px solid var(--border); font-size: .88rem; }
    tbody td::before { content: attr(data-label); font-weight: 600; color: var(--secondary); }
    tbody tr:last-child { margin-bottom: 0; }
}