/* --- DESIGN SYSTEM & CSS VARIABLES --- */
:root {
    --bg-primary: #0b0f17;
    --bg-secondary: #121824;
    --bg-tertiary: #1a2336;
    --bg-input: #151d2c;
    
    --accent: #6366f1;
    --accent-light: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --accent-glow: rgba(99, 102, 241, 0.3);
    
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --info: #3b82f6;
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dark: #6b7280;
    
    --border: rgba(255, 255, 255, 0.07);
    --border-hover: rgba(255, 255, 255, 0.15);
    --glass-bg: rgba(18, 24, 36, 0.75);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 32px rgba(0, 0, 0, 0.4);
    
    --font-sans: 'Inter', sans-serif;
    --font-heading: 'Outfit', sans-serif;
}

/* --- RESET & BASIC STYLES --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.hidden {
    display: none !important;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-main);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
}

button, input, select, textarea {
    font-family: inherit;
    color: inherit;
    border: none;
    outline: none;
    background: none;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-dark);
}

/* --- APP LAYOUT SHELL --- */
#app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

#app-container.login-mode #app-sidebar,
#app-container.login-mode #widget-tasa,
#app-container.login-mode #widget-server-status,
#app-container.login-mode #menu-hamburger {
    display: none !important;
}

#app-container.login-mode #app-main {
    width: 100%;
}

#app-container.login-mode .app-header {
    display: none;
}

/* --- SIDEBAR --- */
.sidebar {
    width: 260px;
    min-width: 260px;
    max-width: 260px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-x: hidden;
}

.sidebar.collapsed {
    width: 80px;
    min-width: 80px;
    max-width: 80px;
}

.sidebar-header {
    height: 70px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
}

.logo-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: 0 0 15px var(--accent-glow);
}

.logo-area h1 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    white-space: nowrap;
    transition: opacity 0.2s;
}

.sidebar.collapsed .logo-area h1 {
    opacity: 0;
    width: 0;
    pointer-events: none;
}

.btn-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: transparent;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--text-main);
}

/* User Profile Badge */
.user-profile-badge {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
}

.sidebar.collapsed .user-profile-badge {
    padding: 15px 12px;
    justify-content: center;
}

.avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    border: 2px solid var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
}

.user-info {
    display: flex;
    flex-direction: column;
    transition: opacity 0.2s;
}

.sidebar.collapsed .user-info {
    opacity: 0;
    width: 0;
    pointer-events: none;
    display: none;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    max-width: 140px;
}

.user-role {
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Sidebar Menu */
.sidebar-menu {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
}

.sidebar-menu ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.nav-item:hover, .nav-item.active {
    color: var(--text-main);
    background-color: var(--bg-tertiary);
}

.nav-item.active {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.25);
}

.sidebar.collapsed .nav-item span {
    opacity: 0;
    width: 0;
    display: none;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px 0;
}

.sidebar-footer {
    padding: 15px;
    border-top: 1px solid var(--border);
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--danger);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:hover {
    background-color: var(--danger-bg);
}

.sidebar.collapsed .btn-logout {
    justify-content: center;
    padding: 12px 0;
}

.sidebar.collapsed .btn-logout span {
    display: none;
}

/* --- MAIN WORKSPACE --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Top App Bar */
.app-header {
    height: 70px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 90;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-left h2 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.status-pill {
    padding: 8px 14px;
    border-radius: var(--radius-full);
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-rate {
    border-color: rgba(245, 158, 11, 0.2);
}

.text-gold {
    color: var(--warning);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.online {
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-dot.offline {
    background-color: var(--warning);
    box-shadow: 0 0 8px var(--warning);
}

/* Workspace Body */
.workspace-body {
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* --- LOGIN SCREEN --- */
.login-screen {
    display: flex;
    width: 100%;
    height: 100vh;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.1) 0%, transparent 40%),
                radial-gradient(circle at 90% 80%, rgba(139, 92, 246, 0.1) 0%, transparent 40%),
                var(--bg-primary);
}

.login-card {
    width: 420px;
    background: var(--glass-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    gap: 25px;
    animation: fadeInUp 0.5s ease;
}

.login-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.login-logo .logo-icon {
    width: 50px;
    height: 50px;
    font-size: 1.6rem;
}

.login-logo h2 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(to right, var(--text-main), var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-logo p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.input-container {
    position: relative;
    width: 100%;
}

.input-container i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dark);
    font-size: 1rem;
    pointer-events: none;
}

.input-container input, .input-container select, .input-container textarea, .form-control {
    width: 100%;
    padding: 12px 15px 12px 45px;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 0.95rem;
    transition: all 0.2s;
}

.form-control {
    padding: 12px 15px; /* Overrides the 45px left padding from input-container which has an icon */
}

option {
    background-color: var(--bg-secondary);
    color: var(--text-main);
}

.input-container input:focus, .input-container select:focus, .input-container textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    background-color: var(--bg-tertiary);
}

/* Button style */
.btn-primary {
    background: var(--accent-gradient);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    transition: all 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background-color: var(--bg-input);
    border-color: var(--text-dark);
}

.demo-credentials {
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 15px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.demo-credentials p {
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--text-main);
}

.demo-credentials ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* --- SPLIT PANE VIEW (APPSHEET STYLE) --- */
.split-layout {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Left Pane (List) */
.list-pane {
    width: 380px;
    border-right: 1px solid var(--border);
    background-color: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: width 0.3s ease;
}

/* Catalog Mode Grid */
.split-layout.catalog-mode:not(.item-selected) .list-pane {
    width: 100%;
    border-right: none;
}
.split-layout.catalog-mode:not(.item-selected) .detail-pane {
    display: none;
}
.split-layout.catalog-mode:not(.item-selected) .scrollable-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    align-content: start;
    grid-auto-rows: max-content;
    gap: 15px;
}

.pane-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.search-bar-row {
    display: flex;
    gap: 10px;
}

.search-input-wrapper {
    position: relative;
    flex: 1;
}

.search-input-wrapper i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dark);
    font-size: 0.9rem;
}

.search-input-wrapper input {
    width: 100%;
    padding: 9px 12px 9px 36px;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 0.85rem;
}

.search-input-wrapper input:focus {
    border-color: var(--accent);
    background-color: var(--bg-tertiary);
}

.filter-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
}

.filter-chip {
    padding: 5px 12px;
    border-radius: var(--radius-full);
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.filter-chip:hover {
    color: var(--text-main);
    border-color: var(--text-dark);
}

.filter-chip.active {
    background-color: var(--accent-glow);
    border-color: var(--accent);
    color: var(--text-main);
}

.scrollable-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Cards */
.card-item {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    min-height: 200px;
}

.card-item.inactive {
    opacity: 0.5;
    filter: grayscale(100%);
}

.card-item:hover {
    transform: translateY(-2px);
    border-color: var(--accent-light);
    box-shadow: var(--shadow-sm);
}

.card-item.active {
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.15);
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, rgba(99, 102, 241, 0.05) 100%);
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.card-title {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
    line-height: 1.3;
    margin-bottom: 2px;
}

.card-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
}

.badge-entrada {
    background-color: var(--success-bg);
    color: var(--success);
}

.badge-despacho {
    background-color: var(--danger-bg);
    color: var(--danger);
}

.card-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.card-details-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 5px;
}

.card-value {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--success);
    font-size: 1.05rem;
}

/* Right Pane (Detail) */
.detail-pane {
    flex: 1;
    background-color: var(--bg-primary);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
}

.empty-detail-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    color: var(--text-dark);
}

.empty-detail-state i {
    font-size: 3.5rem;
}

.detail-header-actions {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border);
    background-color: var(--bg-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.detail-title-area h3 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
}

.detail-title-area p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 3px;
}

.detail-actions-buttons {
    display: flex;
    gap: 10px;
}

.detail-body {
    flex: 1;
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

/* Data blocks */
.detail-section-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.section-title {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
}

.data-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.data-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-dark);
    text-transform: uppercase;
}

.data-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
}

.data-value.highlight {
    color: var(--accent-light);
}

.data-value.price {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--success);
}

/* --- INVENTORY CATALOG SPECIFICS --- */
.product-hero {
    display: flex;
    gap: 25px;
}

.product-image-container {
    width: 220px;
    height: 220px;
    border-radius: var(--radius-md);
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.product-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.swal-enlarged-img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: var(--radius-md);
}

.swal-gallery-popup {
    position: relative !important;
}

.product-image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-dark);
}

.product-image-placeholder i {
    font-size: 2rem;
}

.product-image-placeholder span {
    font-size: 0.7rem;
}

.product-meta-quick {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
}

.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 20px;
    overflow-y: auto;
    height: 100%;
}

.product-catalog-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}

.product-catalog-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
}

.catalog-img-wrapper {
    height: 180px;
    background-color: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
}

.catalog-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.catalog-info {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.catalog-category {
    font-size: 0.7rem;
    color: var(--accent);
    font-weight: 600;
    text-transform: uppercase;
}

.catalog-title {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.3;
}

.catalog-price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.catalog-price {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--success);
    font-size: 1.1rem;
}

.catalog-stock {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.catalog-stock strong {
    color: var(--text-main);
}

/* Tablas de Historial y Relacionados */
.detail-table-wrapper {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

.detail-table th {
    background-color: var(--bg-tertiary);
    padding: 10px 15px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.detail-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
}

.detail-table tr:last-child td {
    border-bottom: none;
}

.detail-table tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

.color-entrada {
    color: var(--success);
    font-weight: 600;
}

.color-despacho {
    color: var(--danger);
    font-weight: 600;
}

/* --- BILLING (FACTURACIÓN) DESIGN --- */
.billing-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    height: 100%;
    overflow: hidden;
}

.billing-workspace {
    flex: 1;
    overflow-y: auto;
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.billing-sidebar-panel {
    background-color: var(--bg-secondary);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.client-section {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.client-search-box {
    display: flex;
    gap: 10px;
}

.search-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}

.search-result-item {
    padding: 10px 15px;
    cursor: pointer;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
}

.search-result-item:hover {
    background-color: var(--bg-tertiary);
}

.search-result-item:last-child {
    border-bottom: none;
}

.client-info-display {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 10px 15px;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.client-info-display p strong {
    color: var(--text-muted);
}

/* Cart Items Table */
.cart-items-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.cart-table-wrapper {
    flex: 1;
    overflow: visible;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.cart-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

.cart-table th {
    background-color: var(--bg-tertiary);
    padding: 12px 15px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
}

.cart-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border);
}

.qty-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.qty-btn {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    background-color: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.8rem;
    border: 1px solid var(--border);
}

.qty-btn:hover {
    background-color: var(--bg-input);
    color: var(--accent);
}

.cart-qty-val {
    width: 25px;
    text-align: center;
    font-weight: 600;
}

.btn-remove-item {
    color: var(--danger);
    cursor: pointer;
    transition: color 0.2s;
}

.btn-remove-item:hover {
    color: #ff6b6b;
}

/* Billing Side Panel / Totales */
.billing-side-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.15rem;
}

.billing-side-body {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.summary-row.total-usd {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-main);
    border-top: 1px dashed var(--border);
    padding-top: 15px;
    margin-top: 10px;
}

.summary-row.total-usd .val-usd {
    color: var(--success);
}

.summary-row.total-bs {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--info);
}

.billing-side-footer {
    padding: 20px;
    border-top: 1px solid var(--border);
}

/* Status Badges for Invoices */
.invoice-status-pill {
    padding: 5px 12px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.status-en-proceso {
    background-color: var(--warning-bg);
    color: var(--warning);
}

.status-embalaje {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--info);
}

.status-facturado {
    background-color: var(--success-bg);
    color: var(--success);
}

.status-guia-enviada {
    background-color: rgba(139, 92, 246, 0.1);
    color: var(--accent-light);
}

.status-anulado {
    background-color: var(--danger-bg);
    color: var(--danger);
}

/* --- DASHBOARD --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    padding: 25px;
}

.stat-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent-light);
}

.stat-icon-wrapper {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.icon-blue {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--info);
}

.icon-green {
    background-color: var(--success-bg);
    color: var(--success);
}

.icon-purple {
    background-color: rgba(139, 92, 246, 0.1);
    color: var(--accent-light);
}

.icon-orange {
    background-color: var(--warning-bg);
    color: var(--warning);
}

.stat-data {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 800;
}

.dashboard-sections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    padding: 0 25px 25px 25px;
}

.dashboard-block {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* --- MODAL DIALOGS --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.25s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 550px;
    max-width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: zoomIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.hidden .modal-card {
    transform: scale(0.95);
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 700;
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-body form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 10px;
}

/* Custom Upload Styling */
.file-upload-wrapper {
    width: 100%;
}

.file-upload-btn {
    border: 1px dashed var(--text-dark);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    background-color: rgba(255, 255, 255, 0.01);
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
}

.file-upload-btn:hover {
    border-color: var(--accent);
    color: var(--text-main);
    background-color: rgba(99, 102, 241, 0.02);
}

.file-upload-btn i {
    font-size: 1.8rem;
}

.file-upload-btn span {
    font-size: 0.8rem;
}

.file-upload-preview {
    margin-top: 10px;
    max-height: 150px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    display: none;
    border: 1px solid var(--border);
}

.file-upload-preview img {
    width: 100%;
    height: 150px;
    object-fit: contain;
}

/* --- TOAST NOTIFICATIONS --- */
.toast {
    position: fixed;
    top: 25px;
    right: 25px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 15px 20px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 2000;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.hidden {
    transform: translateX(120%);
    opacity: 0;
    pointer-events: none;
}

.toast.toast-success {
    border-left: 4px solid var(--success);
}

.toast.toast-success i {
    color: var(--success);
}

.toast.toast-error {
    border-left: 4px solid var(--danger);
}

.toast.toast-error i {
    color: var(--danger);
}

/* Action Quick Links Row */
.action-icon-bar {
    display: flex;
    justify-content: space-around;
    padding: 15px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.action-bar-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
}

.action-bar-btn i {
    font-size: 1.25rem;
    color: var(--accent-light);
    background-color: rgba(139, 92, 246, 0.1);
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.action-bar-btn:hover i {
    background-color: var(--accent);
    color: white;
    transform: translateY(-3px);
}

/* --- FILTER BUTTONS --- */
.btn-filter {
    background-color: var(--bg-secondary);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.btn-filter:hover {
    background-color: var(--border-hover);
    color: var(--text-main);
}

.btn-filter.active {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

/* --- ANIMATIONS --- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

/* --- PRINT MEDIA QUERY (OPTIMIZED FOR TICKERA) --- */
@media print {
    body * {
        visibility: hidden;
    }
    #print-ticket-area, #print-ticket-area * {
        visibility: visible;
    }
    #print-ticket-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 80mm; /* standard ticket size */
        font-family: monospace;
        font-size: 12px;
        line-height: 1.4;
        color: black;
        background: white;
        padding: 5px;
    }
    .no-print {
        display: none !important;
    }
}

#print-ticket-area {
    display: none; /* hidden normally */
}

/* --- MOBILE RESPONSIVENESS & ANDROID ADAPTATIONS --- */
.mobile-only {
    display: none;
}

@media (max-width: 992px) {
    .billing-layout {
        grid-template-columns: 1fr;
        height: auto;
        overflow-y: auto;
    }
    .billing-sidebar-panel {
        border-left: none;
        border-top: 1px solid var(--border);
        height: auto;
    }
    .dashboard-sections {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .mobile-only {
        display: flex;
    }
    
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        box-shadow: var(--shadow-lg);
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .sidebar.collapsed {
        left: -260px;
    }
    
    .split-layout {
        flex-direction: column;
    }
    
    .list-pane {
        width: 100%;
        height: 50%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    .detail-pane {
        width: 100%;
        height: 50%;
    }
    
    /* Toggle active pane style for mobile */
    .split-layout.mobile-active-detail .list-pane {
        display: none;
    }
    
    .split-layout.mobile-active-detail .detail-pane {
        display: flex;
        height: 100%;
    }
    
    .detail-header-actions {
        padding: 15px;
    }
    
    .detail-body {
        padding: 15px;
    }
    
    .app-header {
        padding: 0 15px;
    }
    
    .status-pill {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
    
    .status-rate {
        display: none; /* Hide exchange rate badge on smaller viewports */
    }
}

/* --- ADDITIONAL CUSTOM STYLES FOR VARIANTS & PROFITS --- */
.badge-input-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-height: 42px;
}

.barcode-badge-pill {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--accent);
    color: var(--text-main);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.barcode-badge-pill i {
    cursor: pointer;
    color: var(--danger);
}

.variant-manager-box {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background-color: var(--bg-secondary);
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.variant-editor-row {
    display: grid;
    grid-template-columns: 2fr 1fr auto;
    gap: 10px;
    align-items: center;
}

.financial-dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.financial-kpi-card {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: var(--shadow-sm);
}

.financial-kpi-card.profit-positive {
    border-left: 5px solid var(--success);
}

.financial-kpi-card.profit-positive .kpi-val {
    color: var(--success);
}

.financial-kpi-card .kpi-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.financial-kpi-card .kpi-val {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
}

.tech-sheet-container {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
}

.tech-sheet-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: var(--accent-light);
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

.tech-sheet-text {
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
    color: var(--text-main);
}

@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}

.shake {
    animation: shake 0.4s ease-in-out;
}

/* --- MOBILE RESPONSIVE DESIGN --- */
.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-only {
        display: inline-flex !important;
    }
    
    #app-container {
        flex-direction: column;
    }
    
    #app-sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        max-width: 320px;
        height: 100vh;
        z-index: 9999;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: var(--shadow-lg);
    }
    
    #app-sidebar.mobile-open {
        left: 0;
    }
    
    #sidebar-toggle {
        display: none !important;
    }
    
    .main-content {
        width: 100vw;
        height: 100vh;
    }
    
    .app-header {
        padding: 15px;
    }
    
    .header-left {
        gap: 15px;
    }
    
    /* Grids & Panels */
    .dashboard-stats, .gestion-grid {
        grid-template-columns: 1fr;
    }
    
    #inventory-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    /* Tables */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -10px; /* Let it bleed to edges slightly */
        border-radius: 0;
    }
    
    table {
        min-width: 700px; /* Ensure content doesn't squeeze */
    }
    
    /* Modals */
    .modal-content {
        width: 95%;
        margin: 10px auto;
        max-height: 95vh;
        padding: 20px;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .filters-bar, .actions-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .search-box, .search-box input {
        width: 100%;
    }
    
    .prod-card-img-wrap {
        height: 120px;
    }
    
    .print-tags-container {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Backdrop for mobile sidebar */
    .sidebar-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0,0,0,0.5);
        backdrop-filter: blur(4px);
        z-index: 9998;
        display: none;
        opacity: 0;
        transition: opacity 0.3s;
    }
    
    .sidebar-backdrop.active {
        display: block;
        opacity: 1;
    }
    
    /* Fix Split Layout (Inventario / Facturación) */
    .split-layout {
        flex-direction: column !important;
    }
    
    .list-pane {
        width: 100% !important;
        height: 40% !important;
        border-right: none !important;
        border-bottom: 2px solid var(--border);
    }
    
    .detail-pane {
        width: 100% !important;
        height: 60% !important;
        display: flex !important;
        flex-direction: column !important;
        overflow-y: auto !important;
    }
    
    .detail-pane * {
        max-width: 100%;
    }
    
    .scrollable-list {
        height: 100%;
        overflow-y: auto;
    }
}
