:root {
    --primary: #7c3aed;
    --primary-light: #a78bfa;
    --primary-dark: #6d28d9;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-main: #faf5ff;
    --bg-card: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: #e9d5ff;
    --gradient-start: #fdf4ff;
    --gradient-end: #faf5ff;
}

* {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    color: var(--text-primary);
    min-height: 100vh;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, #c4b5fd 0%, #a78bfa 50%, #8b5cf6 100%);
    color: white;
    padding: 0.75rem 1.25rem;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.2);
}

.app-header h1 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.client-badge {
    background: rgba(255,255,255,0.25);
    padding: 0.2rem 0.6rem;
    border-radius: 16px;
    font-size: 0.8125rem;
    backdrop-filter: blur(10px);
}

/* Layout */
.main-container {
    display: flex;
    height: calc(100vh - 52px);
}

.sidebar {
    width: 260px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    min-width: 0;
    position: relative;
}

.cart-panel {
    width: 320px;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

/* Tabs */
.price-tabs {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.price-tab {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 0.375rem;
    transition: all 0.2s;
    border: 2px solid transparent;
    font-size: 0.8125rem;
}

.price-tab:hover {
    background: var(--bg-main);
}

.price-tab.active {
    background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
    border-color: var(--primary-light);
}

.price-tab .iconify {
    font-size: 1.25rem;
    margin-right: 0.5rem;
}

.price-tab-title {
    font-weight: 500;
    font-size: 0.8125rem;
}

.price-tab-desc {
    font-size: 0.6875rem;
    color: var(--text-secondary);
}

.price-tab-count {
    margin-left: auto;
    background: var(--bg-main);
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.price-tab.active .price-tab-count {
    background: var(--primary);
    color: white;
}

/* Global Search */
.global-search-box {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 0.875rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.08);
}

.search-input {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.625rem 0.875rem 0.625rem 2.5rem;
    width: 100%;
    font-size: 0.875rem;
}

.search-input.global-search {
    font-size: 0.9375rem;
    padding: 0.75rem 1rem 0.75rem 2.75rem;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.15);
}

.search-wrapper {
    position: relative;
}

.search-wrapper .iconify {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 1.125rem;
}

.search-mode-indicator {
    display: none;
    align-items: center;
    gap: 0.375rem;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--primary);
    padding: 0.25rem 0.5rem;
    background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
    border-radius: 6px;
}

.search-mode-indicator.visible {
    display: flex;
}

.search-mode-indicator .iconify {
    font-size: 0.875rem;
}

/* Category Filter */
.category-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 0.75rem 0.75rem;
}

.category-item {
    display: flex;
    align-items: center;
    padding: 0.375rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8125rem;
    transition: all 0.15s;
}

.category-item:hover {
    background: var(--bg-main);
}

.category-item.active {
    background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
    color: var(--primary);
    font-weight: 500;
}

.category-item .iconify {
    margin-right: 0.375rem;
    font-size: 0.9375rem;
}

.category-count {
    margin-left: auto;
    font-size: 0.6875rem;
    color: var(--text-secondary);
}

.category-pin {
    margin-left: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    opacity: 0;
    transition: all 0.15s;
    padding: 0.125rem;
    border-radius: 3px;
}

.category-item:hover .category-pin {
    opacity: 0.6;
}

.category-pin:hover {
    opacity: 1 !important;
    color: var(--primary);
    background: rgba(124, 58, 237, 0.08);
}

.category-pin.pinned {
    opacity: 1;
    color: var(--warning);
}

.category-more-btn {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 500;
    transition: all 0.15s;
    margin-top: 0.25rem;
    border: 1px dashed var(--border);
    justify-content: center;
    gap: 0.25rem;
}

.category-more-btn:hover {
    background: var(--bg-main);
    border-color: var(--primary-light);
}

/* Products Header */
.products-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.products-header h2 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

/* COMPACT PRODUCT LIST */
.products-list {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.product-row {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.15s;
    cursor: default;
}

.product-row:hover {
    border-color: var(--primary-light);
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.1);
}

.product-row.in-cart {
    border-color: var(--success);
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
}

.product-info {
    flex: 1;
    min-width: 0;
}

.product-name {
    font-weight: 500;
    font-size: 0.8125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-meta-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.6875rem;
    color: var(--text-secondary);
    margin-top: 0.125rem;
}

.product-code {
    font-family: monospace;
    background: var(--bg-main);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
}

.product-pricelist-tag {
    font-size: 0.625rem;
    background: #ede9fe;
    color: var(--primary-dark);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-weight: 500;
    white-space: nowrap;
}

.product-stock {
    display: flex;
    align-items: center;
    gap: 0.2rem;
}

.stock-ok { color: var(--success); }
.stock-low { color: var(--warning); }
.stock-none { color: var(--danger); }

.product-prices {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.price-badge {
    font-size: 0.625rem;
    padding: 0.1rem 0.375rem;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

.price-badge.sale {
    background: #fef2f2;
    color: var(--danger);
}

.price-badge.partner {
    background: #f0fdf4;
    color: var(--success);
}

.price-original {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-decoration: line-through;
}

.price-current {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

.product-unit {
    font-size: 0.6875rem;
    color: var(--text-secondary);
    font-weight: normal;
}

.add-btn {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}

.add-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.add-btn.in-cart {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
}

/* Cart Panel */
.cart-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
}

.cart-header h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.cart-count {
    background: var(--primary);
    color: white;
    padding: 0.1rem 0.4rem;
    border-radius: 8px;
    font-size: 0.6875rem;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
}

.cart-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-secondary);
}

.cart-empty .iconify {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.4;
}

.cart-item {
    background: var(--bg-main);
    border-radius: 8px;
    padding: 0.625rem;
    margin-bottom: 0.5rem;
}

.cart-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.375rem;
}

.cart-item-name {
    font-weight: 500;
    font-size: 0.8125rem;
    flex: 1;
    margin-right: 0.375rem;
    line-height: 1.3;
}

.cart-item-code {
    font-size: 0.6875rem;
    color: var(--text-secondary);
    font-family: monospace;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.cart-badge {
    font-size: 0.5625rem;
    padding: 0.1rem 0.25rem;
    border-radius: 3px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
}

.cart-badge.ic {
    background: #f0fdf4;
    color: var(--success);
}

.cart-badge.sale {
    background: #fef2f2;
    color: var(--danger);
}

.cart-item-remove {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.125rem;
    border-radius: 4px;
    transition: all 0.15s;
    line-height: 1;
}

.cart-item-remove:hover {
    background: #fef2f2;
    color: var(--danger);
}

.cart-item-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cart-item-qty {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.qty-btn {
    width: 24px;
    height: 24px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    font-size: 0.875rem;
}

.qty-btn:hover {
    border-color: var(--primary-light);
    color: var(--primary);
}

.qty-input {
    width: 40px;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.125rem;
    font-size: 0.8125rem;
}

.cart-item-price {
    text-align: right;
    font-weight: 600;
    color: var(--primary);
    font-size: 0.875rem;
}

.cart-item-unit-price {
    font-size: 0.6875rem;
    color: var(--text-secondary);
    font-weight: normal;
}

/* Cart Footer */
.cart-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
    background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
}

.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.cart-total-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.cart-total-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.cart-total-vat {
    font-size: 0.6875rem;
    color: var(--text-secondary);
    font-weight: normal;
}

.create-offer-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: 10px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
}

.create-offer-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

.create-offer-btn:disabled {
    background: var(--secondary);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Loader Overlay */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loader-overlay.hidden {
    display: none;
}

.loader-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loader-text {
    margin-top: 1.25rem;
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

.loader-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

/* Partner Matching Loader */
.matching-steps {
    text-align: left;
    margin-top: 1.5rem;
    min-width: 340px;
}

.matching-step {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: all 0.3s;
}

.matching-step.active {
    color: var(--text-primary);
    font-weight: 500;
}

.matching-step.success {
    color: var(--success);
}

.matching-step.error {
    color: var(--danger);
}

.matching-step.warning {
    color: var(--warning);
}

.matching-step-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    background: var(--bg-main);
    border: 2px solid var(--border);
}

.matching-step.active .matching-step-icon {
    border-color: var(--primary);
    background: #f5f0ff;
}

.matching-step.success .matching-step-icon {
    border-color: var(--success);
    background: #f0fdf4;
    color: var(--success);
}

.matching-step.error .matching-step-icon {
    border-color: var(--danger);
    background: #fef2f2;
    color: var(--danger);
}

.matching-step.warning .matching-step-icon {
    border-color: var(--warning);
    background: #fffbeb;
    color: var(--warning);
}

.matching-step-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.matching-step-text {
    flex: 1;
}

.matching-step-detail {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: normal;
}

/* Disambiguation cards */
.disambiguation-panel {
    margin-top: 1rem;
    max-width: 480px;
}

.disambiguation-title {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.disambiguation-cards {
    max-height: 280px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.disambiguation-card {
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
}

.disambiguation-card:hover {
    border-color: var(--primary-light);
    background: #faf5ff;
}

.disambiguation-card-name {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.125rem;
}

.disambiguation-card-detail {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    gap: 0.75rem;
}

/* Error overlay */
.matching-error {
    margin-top: 1.5rem;
    text-align: center;
    max-width: 400px;
}

.matching-error-icon {
    width: 56px;
    height: 56px;
    background: #fef2f2;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--danger);
    font-size: 1.5rem;
    margin: 0 auto 1rem;
}

.matching-error-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.matching-error-text {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 1rem;
}

.matching-error-btn {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    color: white;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.matching-error-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

/* Success State */
.success-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.98);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.success-overlay.hidden {
    display: none;
}

.success-icon {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2rem;
    margin-bottom: 1.25rem;
    animation: scaleIn 0.4s ease-out;
}

@keyframes scaleIn {
    0% { transform: scale(0); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.success-title {
    font-size: 1.375rem;
    font-weight: 600;
    margin-bottom: 0.375rem;
}

.success-text {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    text-align: center;
}

.close-window-btn {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    color: white;
    border: none;
    padding: 0.625rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.close-window-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.3);
}

.success-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

.switch-to-bc-btn {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white;
    border: none;
    padding: 0.625rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.switch-to-bc-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.3);
}

/* Address Selection Overlay (Step 2 - kept in DOM, not shown) */
.address-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.98);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.address-overlay.hidden {
    display: none;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-secondary);
}

.empty-state .iconify {
    font-size: 3rem;
    margin-bottom: 0.75rem;
    opacity: 0.3;
}

/* Categories Modal */
.modal-categories-search {
    margin-bottom: 1rem;
}

.modal-category-list {
    max-height: 400px;
    overflow-y: auto;
}

.modal-category-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8125rem;
    transition: all 0.15s;
}

.modal-category-item:hover {
    background: var(--bg-main);
}

.modal-category-item .iconify {
    margin-right: 0.375rem;
    font-size: 0.9375rem;
}

.modal-category-item .category-count {
    margin-left: auto;
}

.modal-category-item.child {
    padding-left: 2rem;
    font-size: 0.75rem;
}

/* Responsive */
@media (max-width: 992px) {
    .main-container {
        flex-direction: column;
        height: auto;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .cart-panel {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border);
    }
}
