@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Space+Mono&display=swap');

:root {
    --bg-primary: #0b0f19;
    --bg-secondary: rgba(20, 27, 45, 0.7);
    --bg-card: rgba(30, 41, 69, 0.4);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(0, 242, 254, 0.25);
    
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --text-dark: #0f172a;
    
    /* Curated HSL Accent Colors */
    --accent-teal: hsl(187, 100%, 45%);
    --accent-teal-glow: rgba(0, 242, 254, 0.4);
    --accent-purple: hsl(262, 83%, 58%);
    --accent-purple-glow: rgba(139, 92, 246, 0.4);
    --accent-orange: hsl(25, 95%, 53%);
    --accent-orange-glow: rgba(249, 115, 22, 0.4);
    --accent-red: hsl(350, 89%, 60%);
    
    --gradient-primary: linear-gradient(135deg, var(--accent-teal), var(--accent-purple));
    --gradient-hover: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
    --gradient-orange: linear-gradient(135deg, #f97316, #f43f5e);
    
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-glow: 0 0 15px var(--accent-teal-glow);
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    background-image: 
        radial-gradient(at 0% 0%, rgba(139, 92, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(0, 242, 254, 0.15) 0px, transparent 50%);
}

/* --- APP LAYOUT --- */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px 24px 12px;
    border-bottom: 1px solid var(--border-color);
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: var(--gradient-primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
}

.brand-icon svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

.brand-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: linear-gradient(to right, #00f2fe, #fff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.menu-list {
    list-style: none;
    margin-top: 24px;
    flex-grow: 1;
}

.menu-item {
    margin-bottom: 8px;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 12px;
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
}

.menu-link svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    transition: var(--transition-smooth);
}

.menu-link:hover, .menu-item.active .menu-link {
    color: #fff;
    background: var(--bg-card);
    border-color: rgba(0, 242, 254, 0.15);
    box-shadow: inset 0 0 10px rgba(0, 242, 254, 0.05);
}

.menu-item.active .menu-link {
    background: var(--gradient-primary);
    border-color: transparent;
    box-shadow: var(--shadow-glow);
}

.menu-item.active .menu-link svg {
    stroke: #fff;
}

.sidebar-footer {
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.session-info {
    background: rgba(30, 41, 69, 0.3);
    border: 1px solid var(--border-color);
    padding: 12px;
    border-radius: 12px;
    font-size: 0.85rem;
}

.session-user {
    font-weight: 600;
    color: #fff;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.session-user::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    display: inline-block;
}

.session-role {
    color: var(--text-muted);
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Top Header Bar */
.top-header {
    height: 70px;
    background: rgba(11, 15, 25, 0.5);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
}

.header-title {
    font-size: 1.5rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Button UI */
.btn {
    padding: 10px 18px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-smooth);
}

.btn-primary {
    background: var(--gradient-primary);
    color: #fff;
    border: none;
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    background: var(--gradient-hover);
    transform: translateY(-1px);
    box-shadow: 0 0 20px rgba(0, 242, 254, 0.6);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
    background: var(--accent-red);
    color: #fff;
    border: none;
}

.btn-danger:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Vistas Principales */
.view-panel {
    display: none;
    flex-grow: 1;
    padding: 24px 32px;
    overflow-y: auto;
}

.view-panel.active {
    display: flex;
}

/* --- VISTA POS (Punto de Venta) --- */
.pos-workspace {
    display: flex;
    gap: 24px;
    width: 100%;
    height: 100%;
}

.pos-catalog-section {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
    overflow: hidden;
}

/* Categorias */
.category-bar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.category-tab {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition-smooth);
}

.category-tab:hover, .category-tab.active {
    background: rgba(0, 242, 254, 0.1);
    border-color: var(--accent-teal);
    color: #fff;
}

/* Grid de Productos */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    overflow-y: auto;
    padding-right: 4px;
    flex-grow: 1;
}

.product-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.product-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-glow);
    background: rgba(30, 41, 69, 0.6);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.product-card.service-type {
    border-left: 3px solid var(--accent-purple);
}

.product-card.product-type {
    border-left: 3px solid var(--accent-teal);
}

.product-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.product-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 12px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
}

.service-type .product-badge {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
}

.product-name {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-info-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.product-price {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
}

.product-stock {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.product-stock.low {
    color: var(--accent-red);
    font-weight: 600;
}

/* POS Sidebar (Carrito de compras y deudores) */
.pos-checkout-section {
    width: 380px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.checkout-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.checkout-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.clear-cart {
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    background: none;
    border: none;
}

.clear-cart:hover {
    color: var(--accent-red);
}

.cart-items-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    gap: 12px;
}

.cart-empty svg {
    width: 48px;
    height: 48px;
    stroke: rgba(255, 255, 255, 0.1);
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 12px;
    border-radius: 12px;
}

.cart-item-info {
    flex-grow: 1;
    margin-right: 12px;
}

.cart-item-name {
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 4px;
}

.cart-item-price {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.cart-item-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cart-qty-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.cart-qty-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.cart-item-qty {
    font-size: 1rem;
    font-weight: 600;
    width: 30px;
    text-align: center;
}

.cart-item-subtotal {
    font-size: 0.9rem;
    font-weight: 600;
    width: 70px;
    text-align: right;
}

/* Totales y Cobro */
.checkout-summary {
    padding: 20px;
    background: rgba(11, 15, 25, 0.3);
    border-top: 1px solid var(--border-color);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.summary-row.total {
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
    margin-bottom: 20px;
}

.checkout-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-pay {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
    border-radius: 12px;
    justify-content: center;
}

.btn-pay-pending {
    width: 100%;
    padding: 12px;
    font-size: 0.9rem;
    background: rgba(249, 115, 22, 0.1);
    color: var(--accent-orange);
    border: 1px solid rgba(249, 115, 22, 0.2);
    border-radius: 12px;
    justify-content: center;
}

.btn-pay-pending:hover {
    background: rgba(249, 115, 22, 0.2);
}

/* --- PENDIENTES SIDEBAR TAB --- */
.pending-bills-widget {
    margin-top: 16px;
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
    max-height: 250px;
    overflow-y: auto;
}

.widget-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
}

.widget-count {
    background: rgba(249, 115, 22, 0.15);
    color: var(--accent-orange);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.75rem;
}

.pending-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pending-item-card {
    background: rgba(249, 115, 22, 0.03);
    border: 1px solid rgba(249, 115, 22, 0.15);
    border-radius: 10px;
    padding: 10px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.pending-item-card:hover {
    background: rgba(249, 115, 22, 0.08);
    border-color: var(--accent-orange);
}

.pending-item-header {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    color: #fff;
    margin-bottom: 4px;
}

.pending-item-desc {
    color: var(--text-muted);
}

/* --- TABLAS Y CRUD PANELS --- */
.crud-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-input {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 10px 16px;
    border-radius: 10px;
    color: #fff;
    font-family: inherit;
    font-size: 0.9rem;
    width: 300px;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-teal);
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.1);
}

/* Tablas Modernas */
.table-wrapper {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

.data-table th {
    background: rgba(255, 255, 255, 0.02);
    padding: 16px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.01);
}

.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

/* --- MODAL DIALOGS --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(11, 15, 25, 0.75);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

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

.modal-content {
    background: #141b2d;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    width: 500px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px;
    box-shadow: var(--shadow-lg), 0 0 40px rgba(0, 242, 254, 0.05);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.3rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-close:hover {
    color: #fff;
}

/* Formularios */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.form-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-control {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 12px;
    border-radius: 10px;
    color: #fff;
    font-family: inherit;
    font-size: 0.95rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-teal);
}

.form-control option {
    background-color: #141b2d;
    color: #fff;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

/* Métodos de Pago Grid */
.payment-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 10px;
}

.payment-btn {
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    padding: 16px 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: var(--transition-smooth);
}

.payment-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--accent-teal);
    color: #fff;
}

.payment-btn.active {
    background: rgba(0, 242, 254, 0.08);
    border-color: var(--accent-teal);
    color: #fff;
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.1);
}

.payment-btn svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
}

/* --- TICKET PREVIEW REALISTA --- */
.ticket-preview-box {
    background: #f5f5f5;
    border: 1px solid #ddd;
    color: #222;
    font-family: 'Space Mono', monospace;
    font-size: 0.8rem;
    line-height: 1.3;
    padding: 20px;
    border-radius: 8px;
    white-space: pre-wrap;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.05);
    max-height: 400px;
    overflow-y: auto;
}

/* --- DASHBOARD / REPORTES --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    width: 100%;
}

.dashboard-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card-title-row {
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.card-value {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff, var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.report-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
}

.report-filters {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 16px;
    display: flex;
    gap: 16px;
    align-items: flex-end;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Product Card Images */
.product-card-img-wrapper {
    width: 100%;
    height: 120px;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 6px;
    border: 1px solid var(--border-color);
}
.product-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition-smooth);
}
.product-card:hover .product-card-img {
    transform: scale(1.05);
}

/* Table scroll support */
.table-wrapper {
    max-height: calc(100vh - 280px);
    overflow-y: auto;
}

/* --- GLOWING TOGGLE SWITCHES --- */
.switch-toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.switch-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.08) !important;
    border: 1.5px solid var(--border-color);
    transition: all 0.3s ease;
    border-radius: 34px;
}

.switch-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 4px;
    top: 3px;
    background-color: #cbd5e0;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
    z-index: 2;
}

.switch-toggle input:checked + .switch-slider {
    background-color: rgba(0, 242, 254, 0.15) !important;
    border-color: #00f2fe;
    box-shadow: 0 0 8px rgba(0, 242, 254, 0.25);
}

.switch-toggle input:checked + .switch-slider:before {
    transform: translateX(20px);
    background-color: #00f2fe;
    box-shadow: 0 0 8px #00f2fe;
}
