/* ============================================
   SYSTEM SPACE - APP LAYOUT STYLES
   Layout and page-specific styles
   ============================================ */

/* App Layout */

.app-layout {
    display: flex;
    height: 100vh;
    background: #000000;
    overflow: hidden;
    padding: 1rem;
    gap: 1rem;
}

.sidebar {
    width: var(--sidebar-width);
    background: #0A0A0A;
    border-radius: 1.5rem;
    display: flex;
    flex-direction: column;
    transition: width var(--transition-base);
    z-index: var(--z-nav);
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.05);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 var(--space-6);
    border-bottom: 1px solid rgba(255,255,255,0.02);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #000000;
    border-radius: 1.5rem;
    position: relative;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 80px;
    padding: 0 2rem 0 1rem;
    background: transparent;
    border: none;
    z-index: var(--z-header);
}

/* Page content scrolls inside main */
.page-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 2rem 2rem 1rem;
}


/* Page Visibility */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* Dashboard Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-6);
    margin-bottom: var(--space-6);
}

.dashboard-section {
    margin-bottom: var(--space-8);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-5);
}

.section-title {
    font-size: var(--font-size-2xl);
    font-weight: 600;
}

.alerts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-6);
}

.alert-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
}

.alert-section-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* Finanzas Layout */
.tab-container {
    margin-bottom: var(--space-6);
}

.tabs {
    display: flex;
    gap: var(--space-2);
    border-bottom: 2px solid var(--border-color);
    margin-bottom: var(--space-6);
}

.tab {
    padding: var(--space-3) var(--space-6);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    top: 2px;
}

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

.tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn var(--transition-base);
}

.two-column-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
}

/* Form Layout */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-5);
}

.form-grid .form-group.full-width {
    grid-column: span 2;
}

.form-actions {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
    margin-top: var(--space-6);
    padding-top: var(--space-6);
    border-top: 1px solid var(--border-color);
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    text-align: center;
}

.summary-label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.summary-value {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--text-primary);
}

/* Product Grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-5);
}

.product-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    transition: all var(--transition-base);
}

.product-card:hover {
    border-color: var(--color-primary);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.product-code {
    display: inline-block;
    padding: var(--space-1) var(--space-3);
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: var(--space-3);
}

.product-name {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--space-4);
}

.product-details {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.product-detail-row {
    display: flex;
    justify-content: space-between;
    font-size: var(--font-size-sm);
}

.product-detail-label {
    color: var(--text-secondary);
}

.product-detail-value {
    font-weight: 600;
}

.product-margin {
    padding: var(--space-3);
    background: rgba(34, 197, 94, 0.1);
    border-radius: var(--radius-md);
    text-align: center;
    margin-bottom: var(--space-4);
}

.product-margin-label {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}

.product-margin-value {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--color-success);
}

.product-actions {
    display: flex;
    gap: var(--space-2);
}

.product-actions .btn {
    flex: 1;
}

/* Inventory Table */
.inventory-row.low-stock {
    background: rgba(239, 68, 68, 0.05);
}

.inventory-row.low-stock td {
    border-left: 3px solid var(--color-danger);
}

.stock-indicator {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

.stock-bar {
    width: 100px;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.stock-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-success), var(--color-accent));
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

.stock-bar-fill.low {
    background: linear-gradient(90deg, var(--color-danger), var(--color-warning));
}

/* Facturas Upload Area */
.upload-area {
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-12);
    text-align: center;
    background: var(--bg-card);
    cursor: pointer;
    transition: all var(--transition-base);
}

.upload-area:hover {
    border-color: var(--color-primary);
    background: var(--bg-hover);
}

.upload-area.dragover {
    border-color: var(--color-primary);
    background: rgba(79, 70, 229, 0.1);
}

.upload-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--space-4);
    color: var(--text-muted);
}

.upload-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    margin-bottom: var(--space-2);
}

.upload-subtitle {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-4);
}

.upload-input {
    display: none;
}

.extracted-data {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    margin-top: var(--space-6);
}

.extracted-data-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--space-5);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* Report Filters */
.report-filters {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    margin-bottom: var(--space-6);
}

.filter-row {
    display: flex;
    gap: var(--space-4);
    align-items: flex-end;
}

.filter-group {
    flex: 1;
}

/* Settings Section */
.settings-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    margin-bottom: var(--space-6);
}

.settings-header {
    font-size: var(--font-size-xl);
    font-weight: 600;
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-color);
}

.profile-photo-upload {
    display: flex;
    align-items: center;
    gap: var(--space-5);
    margin-bottom: var(--space-6);
}

.profile-photo {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--border-light);
}

.photo-upload-btn {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

/* Stats Overview */
.stats-row {
    display: flex;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.stat-item {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    text-align: center;
}

.stat-value {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.stat-label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

/* Responsive Adjustments */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .alerts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .main-content {
        margin-left: 0;
    }

    .dashboard-grid,
    .two-column-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }

    .product-grid {
        grid-template-columns: 1fr;
    }

    .page-content {
        padding: var(--space-4);
    }

    .stats-row {
        flex-direction: column;
    }
}

@media (max-width: 640px) {
    .app-header {
        padding: 0 var(--space-4);
    }

    .header-left h2 {
        font-size: var(--font-size-xl);
    }

    .user-menu span {
        display: none;
    }
}

/* Animation for refresh icon */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* ==========================================================================
   AI Chat Widget Styles
   ========================================================================== */

@keyframes pulse-glow {
    0% { box-shadow: 0 0 0 0 rgba(184, 147, 74, 0.4); }
    70% { box-shadow: 0 0 0 15px rgba(184, 147, 74, 0); }
    100% { box-shadow: 0 0 0 0 rgba(184, 147, 74, 0); }
}

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

@keyframes status-pulse {
    0% { transform: scale(0.95); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.5; }
}

.ai-chat-widget {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    display: none;
}

.ai-toggle-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    cursor: pointer;
}

.ai-toggle-btn.pulse {
    animation: pulse-glow 2s infinite;
}

.ai-toggle-btn:hover {
    transform: scale(1.1);
}

.ai-toggle-btn.active {
    transform: scale(1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.ai-toggle-btn svg {
    transition: transform 0.3s ease;
}

.ai-toggle-btn.active svg {
    transform: rotate(90deg);
}

.ai-chat-panel {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 380px;
    height: 550px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform-origin: bottom right;
}

.ai-chat-panel.hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

.ai-chat-header {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 16px;
    margin: 1rem;
    margin-bottom: 0;
}

.ai-status-dot {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    opacity: 0.9;
}

.ai-status-dot::before {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #4ade80;
    animation: status-pulse 2s infinite;
}

.ai-chat-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
}

.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}
.ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.ai-chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.ai-message {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.ai-message strong {
    font-weight: 600;
}

.ai-message ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.ai-message li {
    margin-bottom: 0.25rem;
}

.ai-message.system {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    border-bottom-left-radius: 4px;
}

.ai-message.user {
    align-self: flex-end;
    background: rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    border-bottom-right-radius: 4px;
}

.ai-typing {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem !important;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background-color: currentColor;
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

.ai-chat-chips {
    padding: 0 1rem 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ai-chip {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.ai-chip:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.ai-chat-input-area {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    background: var(--bg-primary);
}

#ai-chat-input {
    flex: 1;
    padding: 0.75rem 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: white;
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    max-height: 80px;
    min-height: 44px;
    line-height: 1.4;
}

#ai-chat-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

#ai-chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

#ai-chat-send {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15) !important;
    color: white !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    appearance: none;
    -webkit-appearance: none;
    position: relative;
}

#ai-chat-send::after {
    content: '';
    width: 20px;
    height: 20px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='22' x2='11' y1='2' y2='13'/%3E%3Cpolygon points='22 2 15 22 11 13 2 9 22 2'/%3E%3C/svg%3E") no-repeat center center;
    background-size: contain;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: block !important;
    z-index: 10;
}

#ai-chat-send svg,
#ai-chat-send i {
    display: none !important;
}

#ai-chat-send:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

#ai-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#ai-chat-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15) !important;
    color: white !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    appearance: none;
    -webkit-appearance: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1) !important;
}

#ai-chat-close:hover {
    background: rgba(255, 255, 255, 0.25) !important;
    transform: scale(1.05);
}

@media (max-width: 480px) {
    .ai-chat-widget {
        bottom: 1rem;
        right: 1rem;
    }
    
    .ai-chat-panel {
        position: fixed;
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100dvh;
        border-radius: 0;
        z-index: 1001;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ai-toggle-btn,
    .ai-chat-panel,
    .ai-chip,
    .typing-dots span {
        transition: none !important;
        animation: none !important;
    }
}


.ambient-glow {
    position: fixed;
    top: -150px;
    right: -150px;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, rgba(0,0,0,0) 70%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
}

.pill, .pill-btn, .pill-active {
    border-radius: 9999px !important;
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.08) !important;
    border-radius: 9999px !important;
    color: white !important;
    border-left: none !important;
    position: relative !important;
}

.nav-item.active::after {
    content: "" !important;
    position: absolute !important;
    left: 20% !important;
    right: 20% !important;
    bottom: -10px !important;
    height: 20px !important;
    background: radial-gradient(ellipse at center, rgba(255,255,255,0.25), transparent 70%) !important;
    filter: blur(12px) !important;
    z-index: -1 !important;
    opacity: 1 !important;
    pointer-events: none !important;
}


.nav-item {
    margin: 0.2rem 1rem !important;
    border-radius: 9999px !important;
    padding: 0.75rem 1rem !important;
    transition: all 0.2s ease !important;
    position: relative !important;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.03) !important;
}

.sidebar {
    background: rgba(25, 25, 25, 0.5) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
    border-radius: 24px !important;
    margin: 1rem 0 1rem 1rem !important;
    height: calc(100vh - 2rem) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 10px 40px 0 rgba(0, 0, 0, 0.8), inset 0 0 0 1px rgba(255, 255, 255, 0.05), inset 0 1px 1px rgba(255, 255, 255, 0.2) !important;
}

.app-layout {
    background: #111111 !important;
    padding: 0 !important;
    gap: 0 !important;
}

.main-content {
    background: transparent !important;
    height: 100vh !important;
    overflow-y: auto !important;
}

/* FIX LAYOUT CONTAINER FLEX */
.layout-container {
    display: flex !important;
    width: 100% !important;
    height: 100vh !important;
    gap: 1rem !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    background: #111111 !important;
    position: relative !important;
    overflow: hidden !important;
}

.layout-container::before {
    content: '' !important;
    position: absolute !important;
    top: -30vh !important;
    right: -20vw !important;
    width: 80vw !important;
    height: 80vh !important;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.04) 0%, rgba(17, 17, 17, 0) 65%) !important;
    pointer-events: none !important;
    z-index: 0 !important;
    border-radius: 50% !important;
}
}

/* FINANZAS TABS GLOWING EFFECT */
.finanzas-tab-container {
    border-bottom: 1px solid rgba(255,255,255,0.05);
    margin-bottom: 2rem;
    padding: 0 1rem;
}

.finanzas-tabs {
    display: flex;
    gap: 2rem;
}

.finanzas-tab {
    background: transparent;
    color: #9CA3AF;
    font-weight: 600;
    font-size: 1.05rem;
    padding: 1rem 1.5rem;
    position: relative;
    cursor: pointer;
    border: none;
    outline: none;
    transition: color 0.3s;
}

.finanzas-tab:hover {
    color: #E5E7EB;
}

.finanzas-tab.active {
    color: white;
}

.finanzas-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 12px;
    border: 1px solid transparent;
    border-bottom: 2px solid white;
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
    box-shadow: 0 6px 12px -2px rgba(255, 255, 255, 0.4);
    pointer-events: none;
}

/* SIDEBAR SCROLLBAR & REFINEMENTS */
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}
.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}
.sidebar-nav:hover::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

.nav-item {
    color: white !important;
    font-weight: 500 !important;
}
.nav-item i {
    color: white;
    transition: color 0.3s ease;
}
.nav-item:hover i {
    color: white;
}
.nav-item.active i {
    color: white !important;
}


/* DASHBOARD CARDS HOVER GLOW */
.dashboard-card-glow {
    position: relative;
    transition: transform 0.3s ease;
    border-color: rgba(255, 255, 255, 0.15) !important;
}

.dashboard-card-glow:hover {
    transform: translateY(-2px);
}

.dashboard-card-glow::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 20%;
    width: 60%;
    height: 3px;
    background: rgba(255, 255, 255, 0);
    box-shadow: 0 5px 25px 5px rgba(255, 255, 255, 0);
    opacity: 0;
    transition: opacity 0.4s ease, box-shadow 0.4s ease, background 0.4s ease;
    pointer-events: none;
    z-index: -1;
    border-radius: 50%;
}

.dashboard-card-glow:hover::after {
    opacity: 1;
    background: rgba(255, 255, 255, 0.5);
    box-shadow: 0 10px 40px 10px rgba(255, 255, 255, 0.25);
}

/* CARD ICON INTERACTIVE */
.card-icon-interactive {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, filter 0.3s ease;
}

.dashboard-card-glow:hover .card-icon-interactive {
    transform: scale(1.2);
    filter: brightness(1.3);
    box-shadow: 0 0 20px currentColor;
}

/* GLASS INPUTS & SELECTS */
.glass-input {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: white !important;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.glass-input:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.25) !important;
}

.glass-input:focus {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
    outline: none !important;
}

.glass-input::placeholder {
    color: rgba(255, 255, 255, 0.5) !important;
}

select.glass-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='rgba(255,255,255,0.7)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 1rem center !important;
    background-size: 1em !important;
    padding-right: 2.5rem !important;
    -webkit-appearance: none;
    appearance: none;
}

/* Make calendar icon visible on dark backgrounds */
.glass-input::-webkit-calendar-picker-indicator {
    filter: invert(1) brightness(0.8);
    cursor: pointer;
}

/* Persistent glow effect */
.dashboard-card-glow.glow-active {
    transform: translateY(-2px);
}
.dashboard-card-glow.glow-active::after {
    opacity: 1;
    background: rgba(255, 255, 255, 0.5);
    box-shadow: 0 10px 40px 10px rgba(255, 255, 255, 0.25);
}


/* =========================================================================
   RESPONSIVE FIXES (Pantallas Móviles, Monitores Grandes y Menú Hamburguesa)
   ========================================================================= */

@media (min-width: 769px) {
    #mobile-menu-btn, #mobile-sidebar-overlay {
        display: none !important;
    }
}

/* --- PANTALLAS MÓVILES (iPhone / Smartphones) --- */
@media (max-width: 768px) {
    /* Evitar desbordamiento horizontal de toda la pantalla */
    body {
        overflow-x: hidden !important;
    }
    
    /* Forzar todos los layouts de cuadrícula a 1 sola columna fluida */
    [style*="display: grid"],
    .pos-grid, 
    .dashboard-grid,
    .premium-grid,
    .form-grid,
    .cards-grid {
        grid-template-columns: 1fr !important;
    }

    /* Tablas y reportes con scroll horizontal interno para no romper la pantalla */
    table,
    .table-responsive,
    .table-container,
    .data-table-wrapper {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Botón Hamburguesa Móvil */
    #mobile-menu-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.05) !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        color: #ffffff !important;
        border-radius: 8px !important;
        width: 42px !important;
        height: 42px !important;
        margin-right: 0.75rem !important;
        cursor: pointer;
        z-index: 1000 !important;
        flex-shrink: 0;
        padding: 0 !important;
    }
    
    #mobile-menu-btn svg {
        stroke: #ffffff !important;
    }
    
    .header-left {
        display: flex !important;
        align-items: center !important;
    }
    
    /* Panel lateral superpuesto cuando está abierto */
    #sidebar.mobile-open {
        left: 0 !important;
        transform: translateX(0) !important;
        z-index: 1000000 !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        box-shadow: 10px 0 30px rgba(0,0,0,0.8);
    }
    
    /* Fondo oscuro desenfocado detrás del menú */
    #mobile-sidebar-overlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        background: rgba(0,0,0,0.6) !important;
        backdrop-filter: blur(4px) !important;
        z-index: 999998 !important;
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
}

/* --- PANTALLAS GRANDES DE ESCRITORIO (Monitores anchos / TVs) --- */
@media (min-width: 1440px) {
    #app,
    .app-layout,
    .layout-container {
        max-width: 1440px !important;
        margin: 0 auto !important;
        position: relative;
    }
}


/* =========================================================================
   POS MODULE RESPONSIVE & LAYOUT FIXES (Catálogo y Carrito)
   ========================================================================= */

/* --- 1. Contenedor General del POS --- */
#pos-wrapper.pos-container,
.pos-container {
    height: calc(100vh - 110px) !important;
    max-height: calc(100vh - 110px) !important;
    overflow: hidden !important;
}

/* --- 2. Panel Izquierdo: Catálogo de Productos --- */
.pos-container .pos-products-area {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    max-height: 100% !important;
    overflow: hidden !important;
}

/* Cuadrícula de Productos */
.pos-container .pos-grid,
#pos-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)) !important;
    gap: 1.25rem !important;
    overflow-y: auto !important;
    max-height: calc(100vh - 240px) !important;
    padding-right: 8px !important;
    padding-bottom: 1rem !important;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

/* Scroll estilizado oscuro */
.pos-container .pos-grid::-webkit-scrollbar,
#pos-grid::-webkit-scrollbar,
.pos-container .cart-items::-webkit-scrollbar {
    width: 6px;
}

.pos-container .pos-grid::-webkit-scrollbar-track,
#pos-grid::-webkit-scrollbar-track,
.pos-container .cart-items::-webkit-scrollbar-track {
    background: transparent;
}

.pos-container .pos-grid::-webkit-scrollbar-thumb,
#pos-grid::-webkit-scrollbar-thumb,
.pos-container .cart-items::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 99px;
}

.pos-container .pos-grid::-webkit-scrollbar-thumb:hover,
#pos-grid::-webkit-scrollbar-thumb:hover,
.pos-container .cart-items::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* Tarjetas de Producto */
.pos-container .product-card,
.pos-container .premium-hover-card {
    min-height: 230px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    box-sizing: border-box !important;
}

/* --- 3. Panel Derecho: Carrito y Resumen --- */
.pos-container .pos-cart-area {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    max-height: 100% !important;
    justify-content: space-between !important;
    overflow: hidden !important;
}

.pos-container .cart-header {
    flex-shrink: 0 !important;
}

/* Lista de Items con Scroll Interno */
.pos-container .cart-items,
#pos-cart-items {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    min-height: 0 !important;
    margin-bottom: 1rem !important;
    padding-right: 6px !important;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

/* Totales y Botón Cobrar Fijos en la Base */
.pos-container .cart-footer {
    flex-shrink: 0 !important;
    margin-top: auto !important;
}

/* Adaptación para pantallas móviles */
@media (max-width: 768px) {
    #pos-wrapper.pos-container,
    .pos-container {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 1.5rem !important;
    }

    .pos-container .pos-products-area {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .pos-container .pos-grid,
    #pos-grid {
        max-height: 60vh !important;
    }

    .pos-container .pos-cart-area {
        height: auto !important;
        max-height: none !important;
    }

    .pos-container .cart-items,
    #pos-cart-items {
        max-height: 35vh !important;
    }
}



/* =========================================================================
   POS PRODUCT CARDS - ESTRUCTURA DEFINITIVA EN 3 BLOQUES
   ========================================================================= */

.pos-product-card {
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    min-height: 290px !important;
    height: 100% !important;
    background: rgba(255, 255, 255, 0.02) !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    border-radius: 20px !important;
    padding: 16px !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    position: relative !important;
    overflow: hidden !important;
    cursor: pointer !important;
    box-sizing: border-box !important;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease !important;
}

.pos-product-card:hover {
    transform: translateY(-2px) !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5) !important;
}

/* 1. Bloque Superior */
.pos-product-card .card-top {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    flex-shrink: 0 !important;
}

.pos-product-card .product-icon {
    width: 48px !important;
    height: 48px !important;
    border-radius: 12px !important;
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: rgba(255, 255, 255, 0.6) !important;
}

.pos-product-card .product-icon i {
    width: 24px !important;
    height: 24px !important;
}

.pos-product-card .product-name {
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    color: #ffffff !important;
    line-height: 1.3 !important;
    margin: 4px 0 0 0 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
}

.pos-product-card .stock-badge {
    align-self: flex-start !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    padding: 2px 8px !important;
    border-radius: 99px !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: rgba(255, 255, 255, 0.8) !important;
}

.pos-product-card .stock-badge.low {
    background: rgba(239, 68, 68, 0.1) !important;
    border-color: rgba(239, 68, 68, 0.2) !important;
    color: var(--color-danger, #ef4444) !important;
}

.pos-product-card .stock-badge.service {
    background: rgba(96, 165, 250, 0.1) !important;
    border-color: rgba(96, 165, 250, 0.2) !important;
    color: #60a5fa !important;
}

/* 2. Bloque Medio (Absorbe el espacio sobrante con elegancia) */
.pos-product-card .card-mid {
    flex-grow: 1 !important;
    display: flex !important;
    align-items: center !important;
    margin: 12px 0 !important;
}

.pos-product-card .product-ref {
    font-size: 0.75rem !important;
    color: rgba(255, 255, 255, 0.5) !important;
    font-family: monospace !important;
    letter-spacing: 0.5px !important;
}

/* 3. Bloque Inferior (Horizontal puro, CERO position: absolute) */
.pos-product-card .card-bottom {
    display: flex !important;
    justify-content: space-between !important;
    align-items: flex-end !important;
    width: 100% !important;
    flex-shrink: 0 !important;
    gap: 8px !important;
    box-sizing: border-box !important;
}

.pos-product-card .price-group {
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
}

.pos-product-card .price-usd {
    font-size: 1.1rem !important;
    font-weight: 800 !important;
    color: var(--color-primary, #10b981) !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
}

.pos-product-card .price-bs-row {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    white-space: nowrap !important;
}

.pos-product-card .price-bs {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: rgba(255, 255, 255, 0.9) !important;
    line-height: 1 !important;
    white-space: nowrap !important;
}

.pos-product-card .tasa-badge {
    font-size: 9px !important;
    font-weight: 700 !important;
    padding: 2px 5px !important;
    border-radius: 4px !important;
    background: rgba(255, 255, 255, 0.12) !important;
    color: rgba(255, 255, 255, 0.9) !important;
    line-height: 1 !important;
    flex-shrink: 0 !important;
    letter-spacing: 0.5px !important;
    text-transform: uppercase !important;
    white-space: nowrap !important;
}

.pos-product-card .btn-add-product {
    flex-shrink: 0 !important;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: #ffffff !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

.pos-product-card .btn-add-product:hover {
    background: var(--color-primary, #10b981) !important;
    border-color: var(--color-primary, #10b981) !important;
    color: #000000 !important;
    transform: scale(1.05) !important;
}

.pos-product-card .btn-add-product i {
    width: 18px !important;
    height: 18px !important;
}


/* =========================================================================
   RESTAURACIÓN GLOBAL DE TARJETAS (Dashboard, Cotizaciones, Pedidos, etc.)
   ========================================================================= */
.premium-hover-card {
    min-height: auto !important;
}

/* =========================================================================
   POS PRODUCT CARDS - ENCAPSULADO ESTRICTO EXCLUSIVO A #pos-grid
   ========================================================================= */

/* 1. Tarjeta completa ÚNICAMENTE dentro del catálogo de productos del POS */
#pos-grid .premium-hover-card,
.pos-container #pos-grid .premium-hover-card {
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    min-height: 300px !important;
    padding: 16px !important;
    position: relative !important;
    box-sizing: border-box !important;
}

/* 2. Zona central (Ref:) absorbe el espacio vertical sobrante */
#pos-grid .premium-hover-card > div:nth-child(2),
.pos-container #pos-grid .premium-hover-card > div:nth-child(2) {
    margin: auto 0 !important;
}

/* 3. Contenedor inferior de precios (Padre directo de .add-btn) */
#pos-grid .premium-hover-card > div:last-child,
.pos-container #pos-grid .premium-hover-card > div:last-child,
#pos-grid .premium-hover-card div:has(> .add-btn),
.pos-container #pos-grid .premium-hover-card div:has(> .add-btn) {
    position: relative !important;
    width: 100% !important;
    padding-right: 44px !important;
    box-sizing: border-box !important;
}

/* 4. Botón '+' en el catálogo POS */
#pos-grid .premium-hover-card .add-btn,
.pos-container #pos-grid .premium-hover-card .add-btn {
    position: absolute !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 34px !important;
    height: 34px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    z-index: 10 !important;
}

/* 5. Ocultar etiqueta 'TASA POS' ÚNICAMENTE dentro del catálogo del POS */
#pos-grid .premium-hover-card .bcv-badge,
#pos-grid .premium-hover-card .tasa-badge,
.pos-container #pos-grid .premium-hover-card .bcv-badge,
.pos-container #pos-grid .premium-hover-card .tasa-badge {
    display: none !important;
}

/* 6. Alinear precio en Bs en una sola línea continua en el POS */
#pos-grid .premium-hover-card .currency-bs,
#pos-grid .premium-hover-card .price-bs,
.pos-container #pos-grid .premium-hover-card .currency-bs,
.pos-container #pos-grid .premium-hover-card .price-bs {
    white-space: nowrap !important;
    font-size: 13px !important;
    line-height: 1.2 !important;
    display: block !important;
    margin-top: 2px !important;
}

#pos-grid .premium-hover-card .currency-usd,
#pos-grid .premium-hover-card .price-usd,
.pos-container #pos-grid .premium-hover-card .currency-usd,
.pos-container #pos-grid .premium-hover-card .price-usd {
    white-space: nowrap !important;
    line-height: 1.2 !important;
}

/* =========================================================================
   TABLAS DE DATOS - CONTRASTE Y ALINEACIÓN DE PRECIOS (Cotizaciones, Pedidos, Ventas)
   ========================================================================= */

/* Contraste de texto: blanco legible en celdas de tabla */
table tbody td,
.table tbody td,
.glass-table tbody td {
    color: #f1f5f9 !important;
}

/* Asegurar que las cifras numéricas y símbolos nunca quiebren línea */
table tbody td[style*="text-align: right"],
table th[style*="text-align: right"],
table tbody td:nth-child(5),
table tbody td:nth-child(6) {
    white-space: nowrap !important;
}

.table-currency-nowrap,
table tbody td .currency-amount {
    white-space: nowrap !important;
    display: inline-flex !important;
    align-items: baseline !important;
    gap: 4px !important;
}

/* =========================================================================
   POS CART PANEL - COMPACT TOTALS & EXPANDED CART ITEMS (STRICTLY SCOPED)
   ========================================================================= */

/* 1. Liberar el contenedor de la lista de productos del carrito */
.pos-container .pos-cart-area .cart-items,
.pos-container #pos-cart-items,
#pos-wrapper .pos-cart-area .cart-items,
#pos-cart-items {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    min-height: 0 !important;
    max-height: calc(100vh - 280px) !important;
}

/* 2. Reducir padding general del pie del carrito */
.pos-container .pos-cart-area .cart-footer,
#pos-wrapper .pos-cart-area .cart-footer,
.pos-cart-area .cart-footer {
    padding: 0.85rem 1.25rem !important;
    flex-shrink: 0 !important;
}

/* 3. Compactar la tarjeta de totales al mínimo indispensable */
.pos-container .pos-cart-area .cart-footer > div:first-child,
#pos-wrapper .pos-cart-area .cart-footer > div:first-child,
.pos-cart-area .cart-footer > div:first-child {
    padding: 0.6rem 0.85rem !important;
    margin-bottom: 0.65rem !important;
    border-radius: 12px !important;
}

/* 4. Ocultar las filas de Subtotal e IVA (y otros recargos intermedios) */
.pos-container .pos-cart-area .totals-row:not(.total-highlight),
#pos-wrapper .pos-cart-area .totals-row:not(.total-highlight),
.pos-cart-area .totals-row:not(.total-highlight) {
    display: none !important;
}

/* 5. Fila del Total visible, limpia y alineada */
.pos-container .pos-cart-area .totals-row.total-highlight,
#pos-wrapper .pos-cart-area .totals-row.total-highlight,
.pos-cart-area .totals-row.total-highlight {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
}

.pos-container .pos-cart-area .totals-row.total-highlight span:first-child,
#pos-wrapper .pos-cart-area .totals-row.total-highlight span:first-child,
.pos-cart-area .totals-row.total-highlight span:first-child {
    font-size: 1rem !important;
    font-weight: 700 !important;
}

.pos-container .pos-cart-area .totals-row.total-highlight .tabular-nums,
#pos-wrapper .pos-cart-area .totals-row.total-highlight .tabular-nums,
.pos-cart-area .totals-row.total-highlight .tabular-nums {
    font-size: 1.15rem !important;
    line-height: 1.2 !important;
}

/* 6. Botón Cobrar ergonómico y compacto */
.pos-container .pos-cart-area .cart-footer button.btn-primary,
#pos-wrapper .pos-cart-area .cart-footer button.btn-primary,
.pos-cart-area .cart-footer button.btn-primary {
    padding: 0.75rem 1.25rem !important;
    font-size: 1.05rem !important;
    border-radius: 14px !important;
}

/* =========================================================================
   POS CHECKOUT / VISTA DE COBRO - SCROLL INTERNO Y ANTI-DESBORDE (SCOPED)
   ========================================================================= */

/* 1. Contenedor principal de la vista de cobro */
#pos-wrapper:has(> div[style*="1.5fr 1fr"]) {
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
}

#pos-wrapper > div[style*="1.5fr 1fr"] {
    padding-bottom: 2rem !important;
    box-sizing: border-box !important;
    max-height: calc(100vh - 110px) !important;
    overflow-y: auto !important;
}

/* 2. Tarjetas de Checkout: Esquinas redondeadas garantizadas */
#pos-wrapper > div[style*="1.5fr 1fr"] > div {
    border-radius: 20px !important;
    box-sizing: border-box !important;
}

/* 3. Panel Izquierdo (Resumen de Venta): Contenedor con altura delimitada */
#pos-wrapper > div[style*="1.5fr 1fr"] > div:first-child {
    max-height: calc(100vh - 120px) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow-y: auto !important;
    border-radius: 20px !important;
    padding: 1.5rem !important;
    box-sizing: border-box !important;
}

/* Espaciados optimizados para no robarle altura a los productos */
#pos-wrapper > div[style*="1.5fr 1fr"] > div:first-child > div:nth-child(2),
#pos-wrapper > div[style*="1.5fr 1fr"] > div:first-child > div:nth-child(3) {
    margin-bottom: 1rem !important;
    flex-shrink: 0 !important;
}

/* Lista de productos del checkout: NUNCA colapsar a 1 solo producto */
#pos-wrapper > div[style*="1.5fr 1fr"] > div:first-child > div[style*="flex: 1"],
#pos-wrapper > div[style*="1.5fr 1fr"] > div:first-child > div:nth-child(4) {
    flex: 1 1 auto !important;
    flex-shrink: 0 !important;
    min-height: 220px !important;
    max-height: 380px !important;
    overflow-y: auto !important;
    margin-bottom: 1rem !important;
    padding-bottom: 1rem !important;
    padding-right: 8px !important;
    scrollbar-width: thin !important;
    scrollbar-color: rgba(255, 255, 255, 0.4) rgba(255, 255, 255, 0.05) !important;
}

/* Scroll estilizado y claramente visible para la lista de productos */
#pos-wrapper > div[style*="1.5fr 1fr"] > div:first-child > div:nth-child(4)::-webkit-scrollbar,
#pos-wrapper > div[style*="1.5fr 1fr"] > div:first-child > div[style*="flex: 1"]::-webkit-scrollbar {
    width: 6px !important;
    display: block !important;
}

#pos-wrapper > div[style*="1.5fr 1fr"] > div:first-child > div:nth-child(4)::-webkit-scrollbar-track,
#pos-wrapper > div[style*="1.5fr 1fr"] > div:first-child > div[style*="flex: 1"]::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05) !important;
    border-radius: 99px !important;
}

#pos-wrapper > div[style*="1.5fr 1fr"] > div:first-child > div:nth-child(4)::-webkit-scrollbar-thumb,
#pos-wrapper > div[style*="1.5fr 1fr"] > div:first-child > div[style*="flex: 1"]::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.35) !important;
    border-radius: 99px !important;
}

#pos-wrapper > div[style*="1.5fr 1fr"] > div:first-child > div:nth-child(4)::-webkit-scrollbar-thumb:hover,
#pos-wrapper > div[style*="1.5fr 1fr"] > div:first-child > div[style*="flex: 1"]::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.6) !important;
}

/* Filas de Subtotal, IVA y Total compactas y fijas al pie */
#pos-wrapper > div[style*="1.5fr 1fr"] > div:first-child > div:nth-child(5),
#pos-wrapper > div[style*="1.5fr 1fr"] > div:first-child > div:nth-child(6) {
    margin-bottom: 0.6rem !important;
    flex-shrink: 0 !important;
}

#pos-wrapper > div[style*="1.5fr 1fr"] > div:first-child > div:nth-child(7) {
    margin-bottom: 1rem !important;
    flex-shrink: 0 !important;
}

/* Área de Observaciones compacta para no desplazar los productos */
#pos-wrapper > div[style*="1.5fr 1fr"] > div:first-child > div:last-child {
    flex-shrink: 0 !important;
}

#pos-wrapper > div[style*="1.5fr 1fr"] > div:first-child > div:last-child label {
    margin-bottom: 0.35rem !important;
}

#pos-wrapper > div[style*="1.5fr 1fr"] #co-notes {
    min-height: 55px !important;
    height: 55px !important;
    padding: 0.6rem 0.85rem !important;
}

/* 4. Panel Derecho (Pago): Cero scroll vertical, distribución vertical y botón visible */
#pos-wrapper > div[style*="1.5fr 1fr"] > div:last-child {
    max-height: calc(100vh - 100px) !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    border-radius: 20px !important;
    padding: 1.5rem !important;
    box-sizing: border-box !important;
    overflow-y: hidden !important;
}

/* Espaciados compactos dentro del panel de pago */
#pos-wrapper > div[style*="1.5fr 1fr"] > div:last-child label {
    font-size: 0.85rem !important;
    margin-bottom: 0.4rem !important;
}

/* 1. Los 6 botones de método de pago compactados al máximo */
#pos-wrapper > div[style*="1.5fr 1fr"] > div:last-child div[style*="grid-template-columns: 1fr 1fr"] button {
    padding: 4px 10px !important;
    min-height: 32px !important;
    font-size: 0.8rem !important;
    margin: 2px !important;
    box-sizing: border-box !important;
}

/* 2. Los bloques de '+ CARGOS EXTRAS' y '+ DESCUENTO' */
#pos-wrapper > div[style*="1.5fr 1fr"] .pos-adj-card,
#pos-wrapper > div[style*="1.5fr 1fr"] > div:last-child div[style*="grid-template-columns: 1fr 1fr"] > div {
    padding: 4px 8px !important;
    margin-bottom: 8px !important;
    border-radius: 12px !important;
    box-sizing: border-box !important;
}

#pos-wrapper > div[style*="1.5fr 1fr"] .pos-adj-card label,
#pos-wrapper > div[style*="1.5fr 1fr"] > div:last-child div[style*="grid-template-columns: 1fr 1fr"] label {
    font-size: 0.75rem !important;
    margin-bottom: 2px !important;
}

#pos-wrapper > div[style*="1.5fr 1fr"] .pos-adj-input,
#pos-wrapper > div[style*="1.5fr 1fr"] > div:last-child div[style*="grid-template-columns: 1fr 1fr"] input {
    height: 32px !important;
    padding: 4px 8px !important;
    font-size: 0.9rem !important;
    box-sizing: border-box !important;
}

#pos-wrapper > div[style*="1.5fr 1fr"] select#pos-payment-method,
#pos-wrapper > div[style*="1.5fr 1fr"] select.custom-pos-select {
    padding: 0.75rem 1rem !important;
    font-size: 0.95rem !important;
    border-radius: 12px !important;
    color: white !important;
    background: rgba(255,255,255,0.05) !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* 3. Botón 'Finalizar Pedido' armónico, centrado y con gap */
#pos-wrapper > div[style*="1.5fr 1fr"] > div:last-child button[onclick*="processPOSSaleView"],
#pos-wrapper > div[style*="1.5fr 1fr"] > div:last-child button[onclick*="processSaleView"] {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 1.5rem !important;
    padding: 0.85rem 1.5rem !important;
    margin-top: 10px !important;
    width: 100% !important;
    border-radius: 16px !important;
    font-size: 1.05rem !important;
    box-sizing: border-box !important;
}



/* --- ANTIGRAVITY STRUCTURAL SIDEBAR NESTED MENUS --- */

/* 1. Reset button styles for nav-group-btn */
.nav-group-btn {
    display: flex;
    align-items: center;
    gap: var(--space-3, 0.75rem);
    padding: 0.75rem 1rem !important;
    margin: 0 1rem !important;
    border-radius: 9999px !important;
    color: white !important;
    font-weight: 500 !important;
    background: transparent !important;
    border: none !important;
    width: calc(100% - 2rem) !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    font-size: 0.95rem;
    font-family: inherit;
}

.nav-group-btn i {
    color: white !important;
    transition: color 0.3s ease;
    width: 20px;
    height: 20px;
}

.nav-group-btn:hover {
    background: rgba(255, 255, 255, 0.03) !important;
    color: white !important;
}

.nav-group-chevron {
    margin-left: auto;
    margin-right: 0 !important;
    transition: transform 0.2s ease;
}

.nav-group-btn.expanded .nav-group-chevron {
    transform: rotate(90deg);
}
.nav-group-btn.expanded, .nav-group-btn.expanded i {
    color: white !important;
}

.nav-group-items {
    display: none;
    flex-direction: column;
    margin-left: 3.2rem;
    padding-left: 0.5rem;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 0.2rem;
    margin-bottom: 0.5rem;
}

.nav-sub-item {
    display: flex;
    align-items: center;
    padding: 0.6rem 1rem;
    margin: 0.1rem 0;
    color: white !important;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none !important;
    transition: all 0.2s ease;
    border-radius: 8px;
    position: relative;
    border: none !important;
    outline: none !important;
}

.nav-sub-item:hover {
    color: white !important;
    background: rgba(255, 255, 255, 0.03);
}

.nav-sub-item.active {
    color: white !important;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.08) !important;
}

.nav-sub-item.active::before {
    content: '';
    position: absolute;
    left: -0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: white;
    box-shadow: 0 0 8px rgba(255,255,255,0.8);
}

/* --- FULL HEIGHT SIDEBAR SPACING & PERFECT COLLAPSED CENTERING --- */
.sidebar {
    display: flex !important;
    flex-direction: column !important;
}

.sidebar-nav {
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    flex: 1 !important;
    padding-bottom: 1rem !important;
}

.nav-item, .nav-group-btn {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}



/* Collapsed Sidebar Centering */
.sidebar.collapsed {
    width: 80px !important;
}

.sidebar.collapsed .sidebar-section-label,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-group-btn span,
.sidebar.collapsed .nav-group-chevron,
.sidebar.collapsed .nav-group-btn svg.nav-group-chevron,
.sidebar.collapsed .nav-group-items,
.sidebar.collapsed .logo {
    display: none !important;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center !important;
    padding: 1.5rem 0 1rem 0 !important;
}

.sidebar.collapsed #sidebar-toggle-btn {
    margin: 0 auto !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}

.sidebar.collapsed .sidebar-nav {
    justify-content: space-between !important;
    align-items: center !important;
}

.sidebar.collapsed .nav-item,
.sidebar.collapsed .nav-group-btn {
    justify-content: center !important;
    align-items: center !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    border-radius: 50% !important;
    display: flex !important;
}

.sidebar.collapsed .nav-item i,
.sidebar.collapsed .nav-group-btn i,
.sidebar.collapsed .nav-item svg,
.sidebar.collapsed .nav-group-btn svg {
    margin: 0 !important;
    width: 22px !important;
    height: 22px !important;
    min-width: 22px !important;
    min-height: 22px !important;
    display: block !important;
}

.sidebar.collapsed .nav-item.active,
.sidebar.collapsed .nav-group-btn.expanded {
    background: rgba(255, 255, 255, 0.1) !important;
    border-left: none !important;
}

.sidebar.collapsed .nav-item.active::before,
.sidebar.collapsed .nav-item.active::after,
.sidebar.collapsed .nav-group-btn.expanded::before {
    display: none !important;
}


/* Dashboard Top Bar Layout */
.dashboard-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    margin-top: 1rem;
    position: relative;
    z-index: 10;
}

.dashboard-top-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    z-index: 10;
}

@media (max-width: 768px) {
    .dashboard-top-bar {
        flex-direction: column;
        align-items: stretch !important;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .dashboard-top-actions {
        flex-direction: row;
        justify-content: space-between;
        width: 100%;
        gap: 0.5rem;
    }
    
    #caja-status-btn-container {
        flex: 1;
    }
    
    #btn-caja-action {
        width: 100%;
        justify-content: center;
    }
    
    /* Improve Global search width on mobile to fill remaining space or hide if it gets too tight */
    #global-search-input {
        width: 130px !important; 
    }
}


.sidebar-section-label {
    font-family: inherit !important;
    font-size: 0.7rem;
    color: #6B7280;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    margin-top: 0.5rem !important;
    margin-bottom: 0.5rem !important;
    margin-left: 1rem !important;
    padding-left: 1rem !important;
}


/* --- UNIFY FONT SIZES --- */
.nav-item, .nav-group-btn, .nav-sub-item {
    font-size: 0.9rem !important;
}


/* --- AI PANEL PREMIUM GLASSMORPHISM --- */
.ai-chat-panel {
    background: #000000 !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    border: 1px solid rgba(255,255,255,0.5) !important;
    border-radius: 16px !important;
    box-shadow: 0 20px 50px rgba(0,0,0,0.85) !important;
}

@media (max-width: 768px) {
    .ai-chat-panel {
        border-radius: 0 !important;
        border: none !important;
    }
}


/* --- POS UI REFINEMENTS --- */
#pos-grid {
    padding: 6px !important; /* Prevent hover clipping at top */
}

#pos-grid .pos-product-card .card-bottom {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
}

#pos-grid .pos-product-card .price-group {
    width: 100% !important;
}

#pos-grid .pos-product-card .price-bs-row {
    white-space: normal !important;
    flex-wrap: wrap !important;
}

#pos-grid .pos-product-card .btn-add-product {
    align-self: flex-end !important;
    margin-top: -30px !important; /* Pull it up next to the price if there's space, or just let it sit nicely */
}

/* Actually, a cleaner layout is just standard flex row, but let price group wrap its contents if needed, and give add button fixed space */
#pos-grid .pos-product-card .card-bottom {
    flex-direction: row !important;
    align-items: flex-end !important;
    justify-content: space-between !important;
}
#pos-grid .pos-product-card .price-group {
    flex: 1 !important;
    max-width: calc(100% - 40px) !important; /* Ensure it leaves room for the button */
}
#pos-grid .pos-product-card .price-bs-row {
    flex-wrap: wrap !important;
    white-space: normal !important;
}
#pos-grid .pos-product-card .btn-add-product {
    margin-top: 0 !important;
    align-self: flex-end !important;
}

/* =========================================================================
   AJUSTES v257 - 29/Sep/2026
   ========================================================================= */

/* DETALLE 1: POS Categories - alinear y color del botón Todos */
#pos-categories {
    gap: 0.5rem !important;
    padding: 0.25rem 0 0.75rem 0 !important;
    margin-top: 0.75rem !important;
    align-items: center !important;
}
#pos-categories button {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
}

/* DETALLE 2: Inventario table - prevent last column cutoff */
#inventario-content .table-container {
    overflow-x: auto !important;
}
#inventario-content table {
    min-width: 900px !important;
    table-layout: auto !important;
}
#inventario-content table th:last-child,
#inventario-content table td:last-child {
    min-width: 220px !important;
    white-space: nowrap !important;
}

/* DETALLE 3: Compras product cards - match POS card style */
.compras-grid .premium-hover-card,
#compras-grid .premium-hover-card {
    min-height: 260px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    padding: 1.25rem !important;
    box-sizing: border-box !important;
    position: relative !important;
    overflow: hidden !important;
}

/* The price+button bottom row in compras cards */
.compras-grid .premium-hover-card > div:last-child,
#compras-grid .premium-hover-card > div:last-child {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 0.5rem !important;
    margin-top: auto !important;
    padding-top: 0.75rem !important;
    flex-wrap: nowrap !important;
    flex-shrink: 0 !important;
}

/* DETALLE 4 & 5: Cliente & Proveedor modal cards - premium dark glassmorphism */
.modal-minimal-dark {
    background: rgba(8, 8, 8, 0.97) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255,255,255,0.03) !important;
    border-radius: 20px !important;
    position: relative !important;
    overflow: hidden !important;
}
.modal-minimal-dark::before {
    content: '';
    position: absolute;
    top: -30px;
    right: -30px;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255,255,255,0.08), transparent);
    filter: blur(25px);
    pointer-events: none;
    z-index: 0;
}

.minimal-card {
    background: rgba(13, 13, 13, 0.95) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    border-radius: 16px !important;
    backdrop-filter: blur(8px) !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.04) !important;
    transition: box-shadow 0.25s ease, border-color 0.25s ease !important;
    position: relative !important;
    overflow: hidden !important;
}
.minimal-card::after {
    content: '';
    position: absolute;
    top: -20px;
    right: -20px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255,255,255,0.06), transparent);
    filter: blur(15px);
    pointer-events: none;
}
.minimal-card:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255,255,255,0.08), inset 0 1px 0 rgba(255,255,255,0.06) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

/* Buttons hover depth in modal */
.modal-minimal-dark .minimal-input:hover,
.modal-minimal-dark .minimal-input:focus {
    border-color: rgba(255, 255, 255, 0.25) !important;
    box-shadow: 0 0 18px rgba(255,255,255,0.06) !important;
    background: rgba(255, 255, 255, 0.06) !important;
}

/* Premium silver gradient buttons */
.btn-white {
    background: linear-gradient(135deg, #f5f5f5 0%, #d4d4d8 100%) !important;
    color: #111 !important;
    border: none !important;
    box-shadow: 0 4px 15px rgba(255,255,255,0.12) !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
}
.btn-white:hover {
    background: linear-gradient(135deg, #ffffff 0%, #e4e4e7 100%) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 22px rgba(255,255,255,0.18) !important;
}
.btn-outline {
    background: rgba(255,255,255,0.04) !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    transition: all 0.2s ease !important;
}
.btn-outline:hover {
    background: rgba(255,255,255,0.09) !important;
    border-color: rgba(255,255,255,0.22) !important;
    transform: translateY(-1px) !important;
}

/* =========================================================================
   🔥 CORE MOBILE-FIRST LAYOUT FIX (Anti-Overflow) - INJECTED AUTOMATICALLY
   ========================================================================= */

/* 1. BLOQUEO RADICAL DE DESBORDAMIENTO RAÍZ */
html, body {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    margin: 0;
    padding: 0;
    position: relative;
}

.app-layout, .layout-container {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
}

/* 2. TABLAS Y LISTAS RESPONSIVAS (Scroll Interno Estricto) */
.table-container, 
.table-responsive, 
.data-table-wrapper {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    display: block !important;
    border-radius: 12px;
}

.table-container table, 
.table-responsive table {
    width: 100% !important;
    min-width: max-content !important; 
    border-collapse: collapse !important;
}

/* 3. ESTRUCTURA CONDICIONAL PARA PANTALLAS MÓVILES (< 768px) */
@media (max-width: 768px) {
    
    .main-content {
        width: 100% !important;
        max-width: 100vw !important;
        margin-left: 0 !important;
        padding: 1rem !important;
        flex: 1 1 100% !important;
    }

    .sidebar {
        position: fixed !important;
        left: -150% !important; /* Totalmente fuera */
        top: 0 !important;
        height: 100dvh !important;
        z-index: 999999 !important;
        transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
        margin: 0 !important;
        border-radius: 0 24px 24px 0 !important;
        background: rgba(25, 25, 25, 0.85) !important;
        backdrop-filter: blur(25px) saturate(200%) !important;
        -webkit-backdrop-filter: blur(25px) saturate(200%) !important;
        box-shadow: none !important;
    }

    .sidebar.mobile-open {
        left: 0 !important;
        box-shadow: 20px 0 50px rgba(0,0,0,0.9) !important;
    }

    /* MATAR ANCHOS FIJOS GLOBALES */
    [style*="width: 600px"], 
    [style*="min-width: 800px"],
    [style*="min-width: 900px"],
    .modal-content,
    .form-container,
    .card,
    .pos-product-card {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .grid, 
    [style*="display: grid"],
    .pos-grid,
    .dashboard-grid,
    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .form-group.row, 
    .filter-row,
    .dashboard-top-actions {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
    }
}
