:root {
    --primary: #1a237e;
    --primary-light: #283593;
    --success: #2e7d32;
    --warning: #f57f17;
    --danger: #d32f2f;
    --info: #0277bd;
    --bg-body: #f5f6fa;
    --sidebar-width: 260px;
}

* { box-sizing: border-box; }

body {
    background: var(--bg-body);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #2c3e50;
    margin: 0;
}

/* ── NAVBAR ── */
.navbar-top {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
.navbar-brand {
    color: #fff !important;
    font-size: 1.25rem;
    font-weight: 700;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}
.navbar-user {
    color: rgba(255,255,255,0.85);
    font-size: 0.875rem;
    margin-left: auto;
    margin-right: 12px;
}
.btn-logout {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: #fff;
    padding: 5px 14px;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-logout:hover { background: rgba(255,255,255,0.25); }

/* ── SIDEBAR ── */
.sidebar {
    width: var(--sidebar-width);
    height: calc(100vh - 60px);
    background: linear-gradient(180deg, var(--primary) 0%, #0d1454 100%);
    position: fixed;
    top: 60px; left: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 0;
    z-index: 900;
    transition: transform 0.3s;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

.sidebar-section {
    padding: 6px 16px 2px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.4);
    margin-top: 8px;
}
.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.8) !important;
    text-decoration: none;
    font-size: 0.9rem;
    border-radius: 0;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}
.sidebar .nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: #fff !important;
    border-left-color: rgba(255,255,255,0.5);
}
.sidebar .nav-link.active {
    background: rgba(255,255,255,0.15);
    color: #fff !important;
    border-left-color: #4fc3f7;
    font-weight: 600;
}
.sidebar .nav-link i { width: 18px; text-align: center; font-size: 0.95rem; }

/* ── CONTENIDO PRINCIPAL ── */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: 60px;
    padding: 28px;
    min-height: calc(100vh - 60px);
}

/* ── PAGE HEADER ── */
.page-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #fff;
    padding: 18px 24px;
    border-radius: 14px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 15px rgba(26,35,126,0.3);
}
.page-header h4 { margin: 0; font-weight: 700; font-size: 1.2rem; }
.page-header .subtitle { font-size: 0.8rem; opacity: 0.8; margin-top: 2px; }

/* ── CARDS ── */
.card {
    border: none !important;
    border-radius: 14px !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.07);
    transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(0,0,0,0.1); }

.stat-card {
    border-radius: 14px;
    padding: 20px;
    color: #fff;
    position: relative;
    overflow: hidden;
}
.stat-card .icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2.5rem;
    opacity: 0.2;
}
.stat-card .label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; opacity: 0.9; }
.stat-card .value { font-size: 1.8rem; font-weight: 700; line-height: 1.2; }

.stat-primary { background: linear-gradient(135deg, #4e73df, #224abe); }
.stat-success { background: linear-gradient(135deg, #1cc88a, #13855c); }
.stat-info    { background: linear-gradient(135deg, #36b9cc, #258391); }
.stat-warning { background: linear-gradient(135deg, #f6c23e, #d4a017); }

/* ── TABLAS ── */
.table-card { border-radius: 14px; overflow: hidden; box-shadow: 0 4px 20px rgba(0,0,0,0.07); }
.table { margin: 0; }
.table thead th {
    background: #f8f9fa;
    border-bottom: 3px solid var(--primary) !important;
    color: #495057;
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 16px;
    white-space: nowrap;
}
.table tbody td { padding: 12px 16px; vertical-align: middle; border-color: #f0f0f0; }
.table tbody tr:hover { background: #f8f9ff; }

/* ── BADGES ── */
.badge-success  { background: #e8f5e9; color: var(--success); border-radius: 8px; padding: 4px 10px; font-size: 0.78rem; font-weight: 600; }
.badge-warning  { background: #fff3e0; color: var(--warning); border-radius: 8px; padding: 4px 10px; font-size: 0.78rem; font-weight: 600; }
.badge-danger   { background: #ffebee; color: var(--danger);  border-radius: 8px; padding: 4px 10px; font-size: 0.78rem; font-weight: 600; }
.badge-info     { background: #e3f2fd; color: var(--info);    border-radius: 8px; padding: 4px 10px; font-size: 0.78rem; font-weight: 600; }
.badge-primary  { background: #e8eaf6; color: var(--primary); border-radius: 8px; padding: 4px 10px; font-size: 0.78rem; font-weight: 600; }

/* ── BOTONES DE ACCIÓN ── */
.btn-action {
    width: 32px; height: 32px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: all 0.2s;
    text-decoration: none;
}
.btn-view   { background: #e3f2fd; color: var(--info); }
.btn-edit   { background: #fff3e0; color: var(--warning); }
.btn-delete { background: #ffebee; color: var(--danger); }
.btn-green  { background: #e8f5e9; color: var(--success); }
.btn-action:hover { filter: brightness(0.9); transform: scale(1.05); }

/* ── FORMULARIOS ── */
.form-control, .form-select {
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,35,126,0.12);
    outline: none;
}
.form-label { font-weight: 600; font-size: 0.85rem; color: #495057; margin-bottom: 6px; }

/* ── BOTONES PRINCIPALES ── */
.btn { border-radius: 10px; font-weight: 500; transition: all 0.2s; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-light); border-color: var(--primary-light); }
.btn-success { background: var(--success); border-color: var(--success); }
.btn-danger  { background: var(--danger);  border-color: var(--danger); }
.btn-info    { background: var(--info);    border-color: var(--info); }

/* ── POS ── */
.pos-wrapper {
    display: flex;
    height: calc(100vh - 60px);
    margin: -28px;
}
.pos-products {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e0e0e0;
    overflow: hidden;
}
@media (max-width: 768px) {
    .pos-wrapper { flex-direction: column; height: auto; }
    .pos-products { border-right: none; border-bottom: 1px solid #e0e0e0; flex: 0 0 auto; min-height: 350px; }
    .pos-cart { width: 100%; flex: 0 0 auto; min-height: 350px; }
    .pos-cart-header { padding: 12px 16px; font-size: 0.9rem; }
    .pos-cart-items { padding: 10px; }
    .pos-total { padding: 12px 16px; }
    .pos-form-fields { gap: 2px; }
    .pos-form-fields .mb-2 { margin-bottom: 8px !important; }
    .btn-cobrar, .btn-limpiar { font-size: 0.85rem; padding: 10px; }
}
.pos-categories {
    background: #fff;
    padding: 12px 16px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.cat-btn {
    background: #f0f2ff;
    color: var(--primary);
    border: 1px solid #c5cae9;
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.cat-btn:hover, .cat-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.pos-grid {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--bg-body);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    align-content: start;
}
@media (max-width: 768px) {
    .pos-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 12px; }
}
@media (max-width: 480px) {
    .pos-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px; }
    .product-tile { padding: 12px 8px; }
    .product-tile .name { font-size: 0.75rem; margin-bottom: 4px; }
    .product-tile .price { font-size: 0.9rem; }
}
.product-tile {
    background: #fff;
    border-radius: 12px;
    padding: 16px 12px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    transition: all 0.2s;
    border: 2px solid transparent;
}
.product-tile:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(26,35,126,0.15);
}
.product-tile .name { font-size: 0.85rem; font-weight: 600; color: #2c3e50; margin-bottom: 6px; }
.product-tile .price { font-size: 1rem; font-weight: 700; color: var(--primary); }

.pos-cart {
    width: 340px;
    display: flex;
    flex-direction: column;
    background: #fff;
    overflow-y: auto;
}
.pos-cart-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #fff;
    padding: 16px 20px;
    font-weight: 700;
    font-size: 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
}
.pos-cart-items {
    padding: 12px;
}
.cart-item {
    background: #f8f9ff;
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    border-left: 3px solid var(--primary);
}
.cart-item .item-name { font-weight: 600; font-size: 0.85rem; }
.cart-item .item-sub  { font-size: 0.8rem; color: #666; }
.cart-extra-item {
    background: #f0fdf4;
    border-left-color: var(--success);
}
.qty-controls { display: flex; align-items: center; gap: 6px; }
.qty-btn {
    width: 24px; height: 24px;
    border-radius: 6px;
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
    font-size: 1rem;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.qty-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

.pos-extras {
    padding: 10px 12px;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
    background: #fafafa;
}
.pos-extras .label { font-size: 0.75rem; font-weight: 600; color: #666; margin-bottom: 6px; }
.extra-btn {
    background: #e8f5e9;
    color: var(--success);
    border: 1px solid #c8e6c9;
    border-radius: 16px;
    padding: 4px 12px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    margin: 2px;
    transition: all 0.2s;
}
.extra-btn:hover { background: var(--success); color: #fff; }

.pos-total {
    padding: 16px 20px;
    background: #fff;
    position: sticky;
    bottom: 0;
    border-top: 2px solid #e0e0e0;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
}
.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 0.9rem;
}
.total-row.final {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    border-top: 2px solid #e0e0e0;
    padding-top: 10px;
    margin-top: 6px;
}
.btn-cobrar {
    width: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 14px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 12px;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(26,35,126,0.3);
}
.btn-cobrar:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(26,35,126,0.4); }
.btn-limpiar {
    width: 100%;
    background: transparent;
    color: #999;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 8px;
    font-size: 0.82rem;
    cursor: pointer;
    margin-top: 6px;
    transition: all 0.2s;
}
.btn-limpiar:hover { border-color: var(--danger); color: var(--danger); }

/* ── LOGIN ── */
.login-wrapper {
    min-height: 100vh;
    background: linear-gradient(135deg, #1a237e 0%, #283593 50%, #3949ab 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-card {
    background: rgba(255,255,255,0.97);
    border-radius: 20px;
    width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
}
.login-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    padding: 28px;
    text-align: center;
}
.login-header h3 { margin: 0; font-weight: 700; font-size: 1.4rem; }
.login-header p  { margin: 4px 0 0; opacity: 0.8; font-size: 0.85rem; }
.login-body { padding: 32px; }

/* ── ALERTAS ── */
.alert {
    border-radius: 10px;
    border: none;
    border-left: 4px solid;
    padding: 12px 16px;
    font-size: 0.88rem;
}
.alert-success { border-color: var(--success); background: #e8f5e9; color: #1b5e20; }
.alert-danger   { border-color: var(--danger);  background: #ffebee; color: #b71c1c; }
.alert-warning  { border-color: var(--warning); background: #fff8e1; color: #e65100; }

/* ── SIDEBAR USER INFO ── */
.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 16px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    margin-bottom: 8px;
}
.sidebar-avatar {
    font-size: 2.2rem;
    color: rgba(255,255,255,0.7);
    flex-shrink: 0;
}
.sidebar-user-details { min-width: 0; }
.sidebar-user-name {
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-shop-name {
    color: rgba(255,255,255,0.55);
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}
.sidebar-footer {
    padding: 16px;
    margin-top: auto;
    border-top: 1px solid rgba(255,255,255,0.1);
    position: sticky;
    bottom: 0;
}

/* ── ROLE BADGES ── */
.role-badge {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 10px;
    display: inline-block;
}
.role-developer { background: rgba(255,193,7,0.25); color: #ffd54f; border: 1px solid rgba(255,193,7,0.3); }
.role-admin     { background: rgba(79,195,247,0.2);  color: #81d4fa; border: 1px solid rgba(79,195,247,0.3); }
.role-supervisor{ background: rgba(165,214,167,0.2); color: #a5d6a7; border: 1px solid rgba(165,214,167,0.3); }

/* ── SIDEBAR TOGGLE ── */
.sidebar-toggle {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    color: #fff;
    width: 36px; height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    transition: background 0.2s;
    flex-shrink: 0;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.25); }

/* ── OVERLAY MÓVIL ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 850;
}
.sidebar-overlay.show { display: block; }

/* ── SIDEBAR COLLAPSED (desktop) ── */
.sidebar-collapsed .sidebar { transform: translateX(-100%); }
.sidebar-collapsed .main-content { margin-left: 0; }

/* ── TOGGLE SWITCH ── */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #ccc;
    border-radius: 24px;
    transition: 0.3s;
}
.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px; width: 18px;
    left: 3px; bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.3s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--success); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(20px); }

/* ── CHART AREA ── */
.chart-card {
    background: #fff;
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.07);
}
.chart-card h6 {
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 16px;
}

/* ── PAGINATION ── */
.pagination .page-link {
    border-radius: 8px !important;
    margin: 0 2px;
    color: var(--primary);
    border-color: #dee2e6;
    font-size: 0.85rem;
    padding: 6px 12px;
}
.pagination .page-link:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .page-item.active .page-link { background: var(--primary); border-color: var(--primary); }
.pagination .page-item.disabled .page-link { color: #aaa; }

/* ── POS FORM FIELDS ── */
.pos-form-fields {
    padding: 12px 16px;
    border-top: 1px solid #eee;
    background: #fafafa;
}
.pos-form-fields .form-label { font-size: 0.78rem; font-weight: 600; color: #666; margin-bottom: 4px; }
.pos-form-fields .form-control, .pos-form-fields .form-select {
    font-size: 0.85rem;
    padding: 7px 10px;
    border-radius: 8px;
}
.extra-charge-input {
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 0.8rem;
    width: 80px;
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 16px; }
    .pos-cart { width: 100%; }
}
