/* ===== VARIABLES & RESET ===== */
:root {
    --primary-color: #2563eb;
    --secondary-color: #7c3aed;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --hot-color: #dc2626;
    --regular-color: #059669;
    --slow-color: #6b7280;
    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

/* ===== DARK MODE VARIABLES ===== */
[data-theme="dark"] {
    --primary-color: #3b82f6;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --hot-color: #ef4444;
    --regular-color: #10b981;
    --slow-color: #9ca3af;
    --bg-color: #0f172a;
    --surface-color: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
}

/* ===== CONTAINER ===== */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

/* ===== HEADER ===== */
.header {
    background: #f8fafb;
    border-left: 6px solid #3f6cb4;
    border-bottom: 4px solid transparent;
    border-image: linear-gradient(90deg, #3f6cb4 0%, #e9434d 100%) 1;
    border-image-slice: 0 0 1 0;
    padding: 35px 40px;
    border-radius: 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    position: relative;
    overflow: hidden;
}

[data-theme="dark"] .header {
    background: #1e293b;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.header::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 6px;
    background: #e9434d;
}

.header-content {
    position: relative;
    z-index: 1;
}

.header-actions {
    position: relative;
    z-index: 1;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3f6cb4 0%, #e9434d 100%);
    opacity: 0.9;
}

.header h1 {
    font-size: 2.2rem;
    margin-bottom: 8px;
    font-weight: 800;
    letter-spacing: -0.5px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    line-height: 1.2;
}

.title-prep {
    color: #3f6cb4;
    font-size: 1.1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0.95;
}

.title-brand {
    color: #e9434d;
    font-size: 2.4rem;
    font-weight: 800;
    letter-spacing: -1px;
    text-shadow: 0 2px 10px rgba(233, 67, 77, 0.15);
    background: linear-gradient(135deg, #e9434d 0%, #d63844 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: #64748b;
    font-size: 0.95rem;
    font-weight: 500;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

.last-update {
    font-size: 0.875rem;
    opacity: 0.9;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 15px;
    border-radius: 20px;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 15px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 25px;
    border: 1px solid rgba(63, 108, 180, 0.2);
}

.user-info > div {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #3f6cb4;
}

[data-theme="dark"] .user-name {
    color: #f1f5f9;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
}

/* ===== THEME TOGGLE BUTTON ===== */
.theme-toggle {
    background: linear-gradient(135deg, #3f6cb4 0%, #5380c4 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 1.2rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(63, 108, 180, 0.3);
}

.theme-toggle:hover {
    background: linear-gradient(135deg, #2f5ca4 0%, #4370b4 100%);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(63, 108, 180, 0.4);
}

.theme-toggle:active {
    transform: scale(0.98);
}

[data-theme="dark"] .theme-toggle {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .theme-toggle:hover {
    background: linear-gradient(135deg, #334155 0%, #475569 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

/* ===== BUTTONS ===== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, #3f6cb4 0%, #5380c4 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(63, 108, 180, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2f5ca4 0%, #4370b4 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(63, 108, 180, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: white;
    color: #3f6cb4;
    border: 2px solid #3f6cb4;
}

.btn-secondary:hover {
    background: #3f6cb4;
    color: white;
    border-color: #3f6cb4;
}

.btn-secondary:active {
    background: #2f5ca4;
    border-color: #2f5ca4;
}

.btn-danger {
    background: #ef4444;
    color: white;
    border: 2px solid #ef4444;
}

.btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
}

.btn-danger:active {
    background: #b91c1c;
    border-color: #b91c1c;
}

.icon {
    font-size: 1.1rem;
}

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--surface-color);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: var(--transition);
    position: relative;
}

[data-theme="dark"] .stat-card {
    background: var(--surface-color);
    box-shadow: var(--shadow-md);
}

.stat-card.hot-sales {
    background: linear-gradient(135deg, #fff5f5 0%, #ffffff 100%);
    border-left: 4px solid #dc2626;
    cursor: help;
}

[data-theme="dark"] .stat-card.hot-sales {
    background: linear-gradient(135deg, #3f1f1f 0%, #1e293b 100%);
}

.stat-card.regular-sales {
    background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
    border-left: 4px solid #059669;
    cursor: help;
}

[data-theme="dark"] .stat-card.regular-sales {
    background: linear-gradient(135deg, #1f3f2f 0%, #1e293b 100%);
}

.stat-card.slow-sales {
    background: linear-gradient(135deg, #f9fafb 0%, #ffffff 100%);
    border-left: 4px solid #6b7280;
    cursor: help;
}

[data-theme="dark"] .stat-card.slow-sales {
    background: linear-gradient(135deg, #2f2f2f 0%, #1e293b 100%);
}

.stat-card.total-sales {
    background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%);
    border-left: 4px solid #2563eb;
    cursor: help;
}

[data-theme="dark"] .stat-card.total-sales {
    background: linear-gradient(135deg, #1f2f4f 0%, #1e293b 100%);
}

.stat-card.clickable {
    cursor: pointer;
    user-select: none;
}

.stat-card.clickable:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.stat-card.clickable.active {
    border: 2px solid #3f6cb4;
    box-shadow: 0 0 0 3px rgba(63, 108, 180, 0.2);
    transform: translateY(-3px);
}

.stat-card.clickable.active::after {
    content: '✓';
    position: absolute;
    top: 10px;
    right: 10px;
    background: #3f6cb4;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: bold;
}

.stat-icon {
    font-size: 3rem;
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.stat-icon.hot {
    background: rgba(220, 38, 38, 0.1);
}

.stat-icon.regular {
    background: rgba(5, 150, 105, 0.1);
}

.stat-icon.slow {
    background: rgba(107, 114, 128, 0.1);
}

.stat-icon.total {
    background: rgba(37, 99, 235, 0.1);
}

.stat-content h3 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.stat-content p {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.stat-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* ===== AI ASSISTANT ===== */
.ai-assistant {
    background: linear-gradient(135deg, #f8fafb 0%, #ffffff 100%);
    border: 2px solid #e2e8f0;
    border-radius: var(--border-radius);
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-md);
}

[data-theme="dark"] .ai-assistant {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-color: var(--border-color);
}

.ai-assistant-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e2e8f0;
}

.ai-header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

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

.ai-assistant h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin: 0;
}

.toggle-icon {
    transition: transform 0.3s ease;
    display: inline-block;
}

.ai-assistant.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.ai-assistant.collapsed .ai-content,
.ai-assistant.collapsed .ai-loading {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    margin: 0;
    padding: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease, padding 0.3s ease;
}

.ai-content,
.ai-loading {
    max-height: 2000px;
    opacity: 1;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.ai-assistant.collapsed .ai-assistant-header {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.ai-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: #f1f5f9;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #334155;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    animation: pulse 2s infinite;
}

.ai-status.online .status-dot {
    background: #10b981;
}

.ai-status.offline .status-dot {
    background: #ef4444;
    animation: none;
}

.ai-status.analyzing .status-dot {
    background: #f59e0b;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.875rem;
}

.ai-loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.spinner-small {
    width: 30px;
    height: 30px;
    border: 3px solid #e2e8f0;
    border-top-color: #3f6cb4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

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

.ai-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ai-section {
    background: #ffffff;
    border-radius: var(--border-radius);
    padding: 20px;
    border-left: 4px solid transparent;
}

[data-theme="dark"] .ai-section {
    background: var(--surface-color);
}

.ai-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-critical {
    color: #dc2626;
    border-left-color: #dc2626;
}

.alert-recommendation {
    color: #3f6cb4;
    border-left-color: #3f6cb4;
}

.alert-insight {
    color: #059669;
    border-left-color: #059669;
}

.ai-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 15px;
    transition: var(--transition);
}

[data-theme="dark"] .ai-card {
    background: #0f172a;
    border-color: var(--border-color);
}

.ai-card:hover {
    border-color: #3f6cb4;
    box-shadow: var(--shadow-sm);
    transform: translateX(5px);
}

.ai-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.ai-card-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    flex: 1;
}

.ai-priority {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.priority-critical {
    background: #fee2e2;
    color: #dc2626;
}

.priority-high {
    background: #fef3c7;
    color: #d97706;
}

.priority-medium {
    background: #dbeafe;
    color: #3f6cb4;
}

.ai-card-message {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 10px;
}

.ai-card-action {
    color: #3f6cb4;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ai-card-action::before {
    content: '→';
    font-weight: 700;
}

.ai-card-products {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e2e8f0;
}

.ai-product-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 8px;
}

.ai-product-item {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding-left: 15px;
    position: relative;
}

.ai-product-item::before {
    content: '•';
    position: absolute;
    left: 5px;
    color: #3f6cb4;
    font-weight: 700;
}

.no-alerts {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.no-alerts-icon {
    font-size: 4rem;
    margin-bottom: 15px;
}

.no-alerts h3 {
    font-size: 1.3rem;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.no-alerts p {
    font-size: 0.95rem;
}

/* ===== FILTERS ===== */
.filters {
    background: var(--surface-color);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 30px;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: end;
    justify-content: space-between;
}

[data-theme="dark"] .filters {
    background: var(--surface-color);
    box-shadow: var(--shadow-md);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 0 1 auto;
    min-width: 120px;
    max-width: 160px;
}

/* Premier groupe (Recherche) - extensible pour remplir l'espace */
.filter-group:first-child {
    flex: 1 1 auto;
    max-width: none;
    min-width: 200px;
}

.filter-group label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.filter-group input,
.filter-group select {
    padding: 10px 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.95rem;
    transition: var(--transition);
    background-color: var(--surface-color);
}

[data-theme="dark"] .filter-group input,
[data-theme="dark"] .filter-group select {
    background-color: var(--surface-color);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Date Range Filter Styles */
.date-range-filter {
    min-width: auto;
    max-width: none;
    flex: 1 1 auto;
}

.date-range-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.date-input {
    width: 150px;
    padding: 8px 10px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    transition: var(--transition);
    background-color: var(--surface-color);
    color: var(--text-primary);
    cursor: pointer;
}

.date-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

[data-theme="dark"] .date-input {
    background-color: var(--surface-color);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.date-separator {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 600;
    padding: 0 2px;
}

/* Datetime Group (Date + Time) */
.datetime-group {
    display: flex;
    align-items: center;
    gap: 3px;
}

.time-input {
    width: 110px;
    padding: 8px 10px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    background-color: var(--bg-color);
    color: var(--text-primary);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.time-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

[data-theme="dark"] .time-input {
    background-color: var(--surface-color);
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* ===== LOADING & ERROR STATES ===== */
.loading-state {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
}

[data-theme="dark"] .loading-state {
    background: rgba(30, 41, 59, 0.95);
}

.loading-state p {
    margin-top: 20px;
    font-size: 1.1rem;
    color: var(--text-primary);
    font-weight: 500;
}

.error-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 30px;
}

[data-theme="dark"] .error-state {
    background: var(--surface-color);
    box-shadow: var(--shadow-md);
}

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

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-icon {
    font-size: 4rem;
    margin-bottom: 15px;
}

.error-state p {
    color: var(--danger-color);
    font-size: 1.1rem;
    margin-bottom: 20px;
}

/* ===== PRODUCTS SECTION ===== */
.products-section {
    background: var(--surface-color);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 30px;
}

[data-theme="dark"] .products-section {
    background: var(--surface-color);
    box-shadow: var(--shadow-md);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.product-count {
    background: var(--primary-color);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

/* ===== TABLE ===== */
.table-container {
    width: 100%;
}

.products-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.products-table thead {
    background: var(--bg-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

.products-table th {
    padding: 15px 8px;
    text-align: left;
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    word-wrap: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
}

.products-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.products-table th.sortable:hover {
    background: var(--border-color);
}

.sort-icon {
    font-size: 0.8rem;
    margin-left: 5px;
}

.products-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

.products-table tbody tr.product-row {
    cursor: pointer;
}

.products-table tbody tr.product-row:hover {
    background: var(--bg-color);
    transform: translateX(2px);
}

.products-table td {
    padding: 15px 8px;
    font-size: 0.9rem;
    word-wrap: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

/* ===== ORDER IDS LIST ===== */
.order-ids-list {
    max-height: 80px;
    overflow-y: auto;
    padding: 4px 0;
}

.order-id {
    padding: 2px 4px;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--primary-color);
}

.order-ids-list::-webkit-scrollbar {
    width: 6px;
}

.order-ids-list::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 3px;
}

.order-ids-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.order-ids-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge.badge-wrap {
    white-space: normal;
    text-align: center;
    line-height: 1.3;
}

.badge-hot {
    background: rgba(220, 38, 38, 0.1);
    color: var(--hot-color);
}

.badge-regular {
    background: rgba(5, 150, 105, 0.1);
    color: var(--regular-color);
}

.badge-slow {
    background: rgba(107, 114, 128, 0.1);
    color: var(--slow-color);
}

.trend-badge {
    font-size: 1.5rem;
}

.ai-badge {
    cursor: pointer;
    background: rgba(124, 58, 237, 0.1);
    color: var(--secondary-color);
    transition: var(--transition);
}

.ai-badge:hover {
    background: rgba(124, 58, 237, 0.2);
    transform: scale(1.05);
}

/* ===== AI PANEL ===== */
.ai-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 450px;
    height: 100vh;
    background: var(--surface-color);
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 1000;
    overflow-y: auto;
}

.ai-panel:not(.hidden) {
    transform: translateX(0);
}

.ai-panel-header {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
    color: white;
    padding: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.ai-panel-header h3 {
    font-size: 1.3rem;
    font-weight: 700;
}

.close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.ai-panel-content {
    padding: 25px;
}

.ai-insight-card {
    background: var(--bg-color);
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    border-left: 4px solid var(--secondary-color);
}

[data-theme="dark"] .ai-insight-card {
    background: #0f172a;
}

.ai-insight-card h4 {
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.ai-insight-card p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 10px;
}

.ai-insight-card ul {
    margin-left: 20px;
    color: var(--text-secondary);
}

.ai-insight-card ul li {
    margin-bottom: 8px;
}

/* ===== FOOTER ===== */
.footer {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.footer-info {
    margin-top: 10px;
    font-size: 0.85rem;
}

/* ===== ORDER DETAILS MODAL ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease;
}

[data-theme="dark"] .modal-content {
    background: var(--surface-color);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.8);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 25px;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.modal-body {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
}

.order-details-summary {
    background: var(--bg-color);
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
}

[data-theme="dark"] .order-details-summary {
    background: #0f172a;
}

.order-details-summary h4 {
    font-size: 1.2rem;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.order-details-summary p {
    margin: 8px 0;
    color: var(--text-secondary);
}

.order-details-divider {
    height: 2px;
    background: var(--border-color);
    margin: 20px 0;
}

.customer-order-group {
    margin-bottom: 20px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: var(--transition);
}

.customer-order-group:hover {
    border-color: var(--primary-color);
}

.customer-header {
    background: var(--bg-color);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: var(--transition);
}

[data-theme="dark"] .customer-header {
    background: #0f172a;
}

.customer-header:hover {
    background: var(--border-color);
}

.customer-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.customer-icon {
    font-size: 2rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-color);
    border-radius: 50%;
}

[data-theme="dark"] .customer-icon {
    background: #1e293b;
}

.customer-stats {
    display: flex;
    gap: 10px;
    align-items: center;
}

.toggle-icon {
    font-size: 1.2rem;
    margin-left: 10px;
    transition: transform 0.3s ease;
}

.customer-orders {
    padding: 20px;
    background: var(--surface-color);
}

.order-card {
    background: var(--bg-color);
    border-radius: var(--border-radius);
    padding: 18px;
    margin-bottom: 15px;
    border-left: 4px solid var(--primary-color);
    transition: var(--transition);
}

[data-theme="dark"] .order-card {
    background: #0f172a;
}

.order-card:hover {
    transform: translateX(5px);
    box-shadow: var(--shadow-md);
}

.order-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.order-date {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.order-card-body p {
    margin: 10px 0;
    color: var(--text-secondary);
}

.other-items {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed var(--border-color);
}

.other-items p {
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.other-items-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.other-item-tooltip {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    margin: 5px 0;
    background: var(--surface-color);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    cursor: help;
    transition: var(--transition);
}

[data-theme="dark"] .other-item-tooltip {
    background: #0f172a;
    border-color: var(--border-color);
}

.other-item-tooltip:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateX(5px);
}

.item-quantity {
    font-weight: 700;
    color: var(--primary-color);
}

.other-item-tooltip:hover .item-quantity {
    color: white;
}

.tooltip-content {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.95);
    color: white;
    padding: 15px;
    border-radius: 8px;
    font-size: 0.85rem;
    line-height: 1.6;
    white-space: nowrap;
    z-index: 3000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

.tooltip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.95);
}

.other-item-tooltip:hover .tooltip-content {
    visibility: visible;
    opacity: 1;
}

.text-secondary {
    color: var(--text-secondary);
    font-style: italic;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1400px) {
    .products-table th {
        padding: 12px 6px;
        font-size: 0.8rem;
    }

    .products-table td {
        padding: 12px 6px;
        font-size: 0.85rem;
    }
}

@media (max-width: 1024px) {
    .ai-panel {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }

    .products-table th {
        padding: 10px 5px;
        font-size: 0.75rem;
    }

    .products-table td {
        padding: 10px 5px;
        font-size: 0.8rem;
    }

    .badge {
        padding: 5px 10px;
        font-size: 0.75rem;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        text-align: center;
        padding: 25px 20px;
    }

    .header h1 {
        font-size: 1.5rem;
        align-items: center;
    }

    .title-prep {
        font-size: 0.9rem;
    }

    .title-brand {
        font-size: 1.8rem;
    }
    
    .filters {
        flex-direction: column;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .section-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .products-table th {
        padding: 10px 4px;
        font-size: 0.7rem;
        letter-spacing: 0.1px;
    }

    .products-table td {
        padding: 10px 4px;
        font-size: 0.75rem;
    }

    .badge {
        padding: 4px 8px;
        font-size: 0.7rem;
    }

    .ai-badge {
        padding: 4px 6px;
        font-size: 0.7rem;
    }
}

/* ===== UTILITIES ===== */
.hidden {
    display: none !important;
}

.no-data {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.no-data-icon {
    font-size: 4rem;
    margin-bottom: 15px;
}
/* ===== PRINT STYLES ===== */
.print-view {
    display: none;
}

@media print {
    /* Optimisation pour éviter les pages blanches */
    @page {
        margin: 10mm;
        size: A4;
    }

    /* Reset complet */
    body {
        margin: 0;
        padding: 0;
    }

    /* Cacher TOUT sauf print-view avec display pour ne pas garder l'espace */
    body > *:not(.print-view) {
        display: none !important;
    }

    /* Afficher uniquement print-view */
    .print-view {
        display: block !important;
        width: 100%;
        margin: 0;
        padding: 0;
        background: white;
        font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    }

    /* Document wrapper - simplifié */
    .print-document {
        margin: 0;
        padding: 0;
    }

    /* Print Header - Compact */
    .print-header {
        text-align: center;
        margin-bottom: 12px;
        padding: 12px 0;
        padding-bottom: 10px;
        border-bottom: 3px double #2c3e50;
        background: linear-gradient(to bottom, #f8f9fa 0%, #ffffff 100%);
    }

    .print-header h1 {
        font-size: 22px;
        margin: 0 0 6px 0;
        color: #2c3e50;
        font-weight: 700;
        letter-spacing: 1.5px;
        text-transform: uppercase;
    }

    .print-header .print-date {
        font-size: 11px;
        color: #555;
        margin: 3px 0;
        font-weight: 500;
    }

    .print-header .print-date:first-of-type {
        font-size: 13px;
        color: #2c3e50;
        font-weight: 600;
        margin-top: 5px;
    }

    /* Summary Box - Compact */
    .print-summary {
        display: flex;
        justify-content: space-around;
        margin-bottom: 12px;
        padding: 10px;
        background: #ecf0f1;
        border: 2px solid #34495e;
        border-radius: 0;
    }

    .print-summary div {
        text-align: center;
        padding: 6px 15px;
        position: relative;
    }

    .print-summary div:not(:last-child)::after {
        content: '';
        position: absolute;
        right: -1px;
        top: 15%;
        height: 70%;
        width: 2px;
        background: #95a5a6;
    }

    .print-summary strong {
        display: block;
        font-size: 20px;
        color: #2c3e50;
        margin-bottom: 3px;
        font-weight: 700;
    }

    .print-summary span {
        font-size: 10px;
        color: #555;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    /* Table Styles - Compact */
    .print-table {
        width: 100%;
        border-collapse: separate;
        border-spacing: 0;
        margin-bottom: 10px;
        border: 2px solid #2c3e50;
    }

    .print-table thead {
        background: #34495e;
    }

    .print-table th {
        background: #34495e;
        color: white;
        padding: 8px 6px;
        text-align: left;
        font-size: 11px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        border-bottom: 2px solid #2c3e50;
    }

    .print-table th:first-child {
        text-align: center;
    }

    .print-table tbody tr {
        border-bottom: 1px solid #bdc3c7;
    }

    .print-table tbody tr:nth-child(odd) {
        background: #ffffff;
    }

    .print-table tbody tr:nth-child(even) {
        background: #f8f9fa;
    }

    .print-table tbody tr:hover {
        background: #e8f4f8;
    }

    .print-table td {
        padding: 6px 5px;
        font-size: 10px;
        color: #2c3e50;
        line-height: 1.3;
    }

    .print-table .qty-cell {
        text-align: center;
        font-weight: 700;
        font-size: 12px;
        color: #e74c3c;
        background: #fff5f5;
    }

    .print-table .ref-cell {
        font-weight: 700;
        font-family: 'Courier New', monospace;
        color: #2980b9;
        font-size: 9px;
    }

    .print-table .product-cell {
        font-weight: 500;
        color: #2c3e50;
    }

    .print-table .size-cell {
        text-align: center;
        font-weight: 600;
        color: #27ae60;
        font-size: 10px;
    }

    .print-table .orders-cell {
        text-align: center;
        color: #8e44ad;
        font-weight: 600;
    }

    /* Checkbox styling - Compact */
    .checkbox-cell {
        text-align: center;
        padding: 6px 5px !important;
    }

    .print-checkbox {
        width: 20px;
        height: 20px;
        border: 2px solid #2c3e50;
        display: inline-block;
        border-radius: 3px;
        background: white;
        vertical-align: middle;
    }

    /* Footer - Compact */
    .print-footer {
        margin-top: 15px;
        padding: 10px 0;
        border-top: 2px double #2c3e50;
        background: #f8f9fa;
    }

    .print-footer-content {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 8px;
    }

    .print-instructions {
        flex: 1;
        padding-right: 20px;
    }

    .print-instructions h3 {
        font-size: 11px;
        color: #2c3e50;
        margin: 0 0 5px 0;
        font-weight: 700;
        text-transform: uppercase;
    }

    .print-instructions p {
        font-size: 9px;
        color: #555;
        margin: 2px 0;
        line-height: 1.4;
    }

    .print-signature {
        width: 200px;
        border: 1px solid #bdc3c7;
        padding: 8px;
        background: white;
    }

    .print-signature-label {
        font-size: 9px;
        color: #555;
        font-weight: 600;
        margin-bottom: 5px;
        text-transform: uppercase;
    }

    .print-signature-line {
        border-top: 1px solid #2c3e50;
        margin-top: 25px;
        padding-top: 3px;
        text-align: center;
        font-size: 8px;
        color: #7f8c8d;
    }

    .print-footer-info {
        text-align: center;
        font-size: 8px;
        color: #7f8c8d;
        padding-top: 8px;
        border-top: 1px solid #ddd;
        font-style: italic;
    }

    /* Page breaks */
    .page-break {
        page-break-after: always;
    }

    /* Avoid breaking rows */
    .print-table tr {
        page-break-inside: avoid;
    }

    .print-table tbody {
        orphans: 3;
        widows: 3;
    }

    /* Éviter qu'un header seul sur une page */
    .print-header {
        page-break-after: avoid;
    }

    /* Éviter que le footer crée une page vide */
    .print-footer {
        page-break-before: avoid;
        page-break-inside: avoid;
    }

    /* S'assurer qu'au moins 3 lignes restent ensemble */
    .print-table thead {
        page-break-after: avoid;
    }

    /* Brand Section Styles */
    .brand-section {
        margin-bottom: 20px;
        page-break-inside: avoid;
    }

    .brand-header {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        padding: 10px 15px;
        margin-bottom: 5px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-radius: 0;
        page-break-after: avoid;
    }

    .brand-header h2 {
        font-size: 16px;
        margin: 0;
        font-weight: 700;
        letter-spacing: 1px;
        text-transform: uppercase;
    }

    .brand-count {
        font-size: 11px;
        font-weight: 600;
        background: rgba(255, 255, 255, 0.2);
        padding: 4px 12px;
        border-radius: 12px;
    }

    .order-cell {
        text-align: left;
        font-size: 9px;
        font-family: 'Courier New', monospace;
        color: #8e44ad;
        font-weight: 600;
    }
}

/* ===== NOTIFICATIONS ===== */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 24px;
    border-radius: var(--border-radius);
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-weight: 600;
    font-size: 0.95rem;
    z-index: 10000;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
    max-width: 400px;
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification-success {
    border-left: 4px solid var(--success-color);
    color: var(--success-color);
}

.notification-error {
    border-left: 4px solid var(--danger-color);
    color: var(--danger-color);
}

.notification-info {
    border-left: 4px solid var(--primary-color);
    color: var(--primary-color);
}

/* ===== ADVANCED STATS ===== */
.advanced-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.advanced-stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 15px;
    color: white;
    transition: var(--transition);
}

[data-theme="dark"] .advanced-stat-card {
    background: linear-gradient(135deg, #4c5fb8 0%, #5a3870 100%);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.6);
}

.advanced-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.advanced-stat-icon {
    font-size: 2.5rem;
    opacity: 0.9;
}

.advanced-stat-content {
    flex: 1;
}

.advanced-stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 4px;
    line-height: 1;
}

.advanced-stat-label {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-bottom: 4px;
}

.advanced-stat-change {
    font-size: 0.75rem;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-arrow {
    font-size: 0.9rem;
}

@media (max-width: 1024px) {
    .advanced-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .advanced-stats {
        grid-template-columns: 1fr;
    }

    .advanced-stat-card {
        padding: 15px;
    }

    .advanced-stat-value {
        font-size: 1.5rem;
    }
}

/* ===== CHARTS SECTION ===== */
.charts-section {
    background: white;
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    margin-bottom: 30px;
}

[data-theme="dark"] .charts-section {
    background: var(--surface-color);
}

.charts-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.chart-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 25px;
}

.chart-card {
    background: var(--bg-color);
    padding: 20px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .chart-card {
    background: #0f172a;
    border-color: var(--border-color);
}

.chart-card-wide {
    grid-column: span 2;
}

.chart-card h3 {
    font-size: 1rem;
    margin-bottom: 15px;
    color: var(--text-primary);
    font-weight: 600;
}

.chart-card canvas {
    max-height: 300px;
}

/* Chart Header with Expand Button */
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.chart-header h3 {
    margin-bottom: 0;
    flex: 1;
}

.btn-icon {
    background: none;
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 6px;
    font-size: 1.2rem;
    color: var(--text-secondary);
    transition: var(--transition);
    min-width: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--border-color);
    color: var(--text-primary);
    transform: scale(1.1);
}

/* Bouton icône avec style primary */
.btn-icon.btn-primary {
    background: linear-gradient(135deg, #3f6cb4 0%, #5380c4 100%);
    color: white;
    border: none;
    box-shadow: 0 2px 8px rgba(63, 108, 180, 0.3);
}

.btn-icon.btn-primary:hover {
    background: linear-gradient(135deg, #2f5ca4 0%, #4370b4 100%);
    box-shadow: 0 4px 12px rgba(63, 108, 180, 0.4);
}

/* Bouton icône avec style secondary */
.btn-icon.btn-secondary {
    background: white;
    color: #3f6cb4;
    border: 2px solid #3f6cb4;
}

.btn-icon.btn-secondary:hover {
    background: #3f6cb4;
    color: white;
}

[data-theme="dark"] .btn-icon:hover {
    background: var(--surface-color);
}

/* Expanded Chart Modal */
.modal-content-large {
    max-width: 95vw;
    width: 95vw;
    max-height: 90vh;
}

.chart-expanded-container {
    height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-expanded-container canvas {
    max-height: 100%;
    width: 100% !important;
}

/* ===== TOP PRODUCTS TABLE ===== */
.top-products-table {
    width: 100%;
    overflow-x: auto;
}

.top-products-table-content {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.top-products-table-content thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.top-products-table-content th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.top-product-row {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
}

.top-product-row.expandable {
    cursor: pointer;
}

.top-product-row.expandable:hover {
    background-color: var(--bg-color);
}

[data-theme="dark"] .top-product-row.expandable:hover {
    background-color: #1e293b;
}

.top-product-row td {
    padding: 12px;
    color: var(--text-primary);
}

.expand-icon {
    text-align: center;
    color: #667eea;
    font-weight: bold;
}

.expand-btn {
    display: inline-block;
    transition: transform 0.3s;
}

.product-ref {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: #2563eb;
}

[data-theme="dark"] .product-ref {
    color: #60a5fa;
}

.product-name {
    font-weight: 500;
}

.variant-count {
    margin-left: 8px;
    font-size: 0.8rem;
    color: #6b7280;
    font-weight: 400;
}

.product-quantity {
    text-align: center;
}

.quantity-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 1rem;
}

.product-status {
    text-align: center;
}

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

.status-badge.hot {
    background: #fee2e2;
    color: #dc2626;
}

.status-badge.regular {
    background: #d1fae5;
    color: #059669;
}

.status-badge.slow {
    background: #f3f4f6;
    color: #6b7280;
}

[data-theme="dark"] .status-badge.hot {
    background: #7f1d1d;
    color: #fca5a5;
}

[data-theme="dark"] .status-badge.regular {
    background: #064e3b;
    color: #6ee7b7;
}

[data-theme="dark"] .status-badge.slow {
    background: #374151;
    color: #d1d5db;
}

/* Variant Details */
.variant-details {
    background-color: #f9fafb;
}

[data-theme="dark"] .variant-details {
    background-color: #0f172a;
}

.variants-container {
    padding: 15px 20px;
}

.variants-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

[data-theme="dark"] .variants-table {
    background: #1e293b;
}

.variants-table thead {
    background: #f3f4f6;
}

[data-theme="dark"] .variants-table thead {
    background: #334155;
}

.variants-table th {
    padding: 10px;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    color: #374151;
}

[data-theme="dark"] .variants-table th {
    color: #e5e7eb;
}

.variants-table td {
    padding: 10px;
    border-bottom: 1px solid #e5e7eb;
    color: var(--text-primary);
}

[data-theme="dark"] .variants-table td {
    border-bottom-color: #334155;
}

.variant-size {
    text-align: center;
    font-weight: 600;
    color: #8b5cf6;
}

.variant-qty {
    text-align: center;
    font-weight: 700;
    font-size: 1rem;
}

/* Export Buttons */
.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

/* ===== NOTIFICATION CONTAINER ===== */
.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.notification-item {
    background: white;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 300px;
    max-width: 400px;
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
    pointer-events: all;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

[data-theme="dark"] .notification-item {
    background: var(--surface-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

.notification-item.show {
    opacity: 1;
    transform: translateX(0);
}

.notification-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
}

.notification-item.success::before {
    background: var(--success-color);
}

.notification-item.error::before {
    background: var(--danger-color);
}

.notification-item.warning::before {
    background: var(--warning-color);
}

.notification-item.info::before {
    background: var(--primary-color);
}

.notification-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.notification-content {
    flex: 1;
}

.notification-title {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 2px;
    color: var(--text-primary);
}

.notification-message {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.notification-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.notification-close:hover {
    background: var(--bg-color);
    color: var(--text-primary);
}

/* ===== EMAIL PREPARATION SECTION ===== */
.email-preparation-section {
    background: white;
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    margin-bottom: 30px;
}

[data-theme="dark"] .email-preparation-section {
    background: var(--surface-color);
    box-shadow: var(--shadow-md);
}

.email-preparation-section .section-header {
    margin-bottom: 25px;
}

.email-config-container {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 25px;
}

.email-config-card,
.email-status-card {
    background: var(--bg-color);
    padding: 25px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .email-config-card,
[data-theme="dark"] .email-status-card {
    background: #0f172a;
    border-color: var(--border-color);
}

.email-config-card h3,
.email-status-card h3 {
    font-size: 1.1rem;
    margin-bottom: 20px;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

.config-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.form-input,
.form-select {
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-family: inherit;
    background: white;
    transition: var(--transition);
}

[data-theme="dark"] .form-input,
[data-theme="dark"] .form-select {
    background: var(--surface-color);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.checkbox-group {
    flex-direction: row;
    align-items: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.button-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.status-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

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

[data-theme="dark"] .status-item {
    background: var(--surface-color);
    border-color: var(--border-color);
}

.status-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.status-value {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
}

.status-value.active {
    color: #10b981;
}

.status-value.inactive {
    color: #6b7280;
}

.status-value.error {
    color: #ef4444;
}

/* SMTP Configuration Styles */
.smtp-config-container {
    margin-top: 25px;
}

.smtp-config-card {
    background: var(--bg-color);
    padding: 25px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .smtp-config-card {
    background: #0f172a;
    border-color: var(--border-color);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.smtp-info {
    background: #f0f9ff;
    border-left: 4px solid #3b82f6;
    padding: 15px;
    border-radius: var(--border-radius);
    margin: 15px 0;
}

[data-theme="dark"] .smtp-info {
    background: #1e3a5f;
    border-color: #3b82f6;
}

.smtp-info p {
    margin: 0 0 10px 0;
    color: #1e40af;
}

.smtp-info ul {
    margin: 0;
    padding-left: 20px;
    color: #1e3a8a;
}

.smtp-info li {
    margin: 5px 0;
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border: none;
}

.btn-warning:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

/* ===== RESPONSIVE DESIGN ===== */

/* Tablets (≤ 1024px) */
@media (max-width: 1024px) {
    .container {
        padding: 15px;
    }

    .header {
        padding: 25px 20px;
    }

    .header h1 {
        font-size: 1.8rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .chart-card-wide {
        grid-column: span 1;
    }

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

    .table-container {
        overflow-x: auto;
    }

    .products-table {
        min-width: 1000px;
    }

    .email-config-container {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Mobile (≤ 768px) */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
        flex-wrap: wrap;
        gap: 10px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

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

    .stat-card {
        padding: 15px;
    }

    .charts-section {
        padding: 20px 15px;
    }

    .charts-section .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .chart-actions {
        width: 100%;
    }

    .chart-actions button {
        flex: 1;
    }

    .filters {
        padding: 15px;
    }

    .btn {
        font-size: 0.85rem;
        padding: 8px 12px;
    }

    .ai-assistant {
        padding: 15px;
    }

    .modal-content {
        width: 95%;
        margin: 20px auto;
        padding: 15px;
    }

    .ai-panel {
        width: 100%;
    }

    .notification-item {
        min-width: auto;
        max-width: calc(100vw - 40px);
    }

    .notification-container {
        right: 10px;
        left: 10px;
    }

    /* Make table scrollable on mobile */
    .table-container {
        overflow-x: scroll;
        -webkit-overflow-scrolling: touch;
    }

    .products-table {
        font-size: 0.85rem;
    }

    .products-table th,
    .products-table td {
        padding: 8px;
    }

    .email-preparation-section {
        padding: 20px;
    }

    .button-group {
        flex-direction: column;
    }

    .button-group .btn {
        width: 100%;
    }
}

/* Small Mobile (≤ 480px) */
@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

    .header {
        padding: 20px 15px;
    }

    .header h1 {
        font-size: 1.3rem;
    }

    .stat-card h3 {
        font-size: 1.5rem;
    }

    .chart-card {
        padding: 15px;
    }

    .chart-card h3 {
        font-size: 0.9rem;
    }

    .btn-sm {
        font-size: 0.75rem;
        padding: 6px 10px;
    }

    .user-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        width: 100%;
    }

    .filter-group label {
        font-size: 0.85rem;
    }

    .filter-group input,
    .filter-group select {
        font-size: 0.85rem;
    }
}

/* ===== TABS NAVIGATION ===== */
.tabs-nav {
    display: flex;
    gap: 4px;
    background: var(--surface-color);
    padding: 6px;
    border-radius: var(--border-radius);
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow-x: auto;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: var(--transition);
    white-space: nowrap;
}

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

.tab-btn.active {
    background: var(--primary-color);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.tab-content {
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.tab-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ===== SUPPLIER SECTIONS ===== */
.supplier-section {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 12px;
    overflow: hidden;
}

.supplier-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    cursor: pointer;
    transition: var(--transition);
    flex-wrap: wrap;
    gap: 8px;
}

.supplier-header:hover {
    background: var(--bg-color);
}

.supplier-info {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

.supplier-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.supplier-items {
    border-top: 1px solid var(--border-color);
    padding: 0;
}

.supplier-items .products-table {
    margin: 0;
    border: none;
    box-shadow: none;
}

/* ===== FRANCO PROGRESS ===== */
.franco-progress {
    width: 100%;
    margin-top: 6px;
    padding: 0 18px 10px;
}

.franco-progress-bar {
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.franco-progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.franco-progress-fill.franco-low { background: #ef4444; }
.franco-progress-fill.franco-mid { background: #f59e0b; }
.franco-progress-fill.franco-high { background: #22c55e; }

.franco-progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 3px;
}

/* ===== ALERT THRESHOLDS ===== */
.alert-thresholds {
    margin-bottom: 16px;
}

.alert-threshold-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
}

.alert-threshold-row input {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.85rem;
    background: var(--surface-color);
    color: var(--text-primary);
}

.alert-threshold-row select {
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.85rem;
    background: var(--surface-color);
    color: var(--text-primary);
}

.alert-threshold-row .btn-remove-threshold {
    padding: 4px 8px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.btn-add-threshold {
    padding: 6px 12px;
    background: var(--surface-color);
    border: 1px dashed var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.btn-add-threshold:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* ===== ORDER DETAIL (RECAP) ===== */
.order-link {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

.order-link:hover {
    text-decoration: underline;
    color: #2563eb;
}

.order-detail-products {
    margin-top: 12px;
}

.order-detail-products table {
    width: 100%;
}

.order-detail-summary {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.order-detail-summary .detail-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.order-detail-summary .detail-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.order-detail-summary .detail-value {
    font-weight: 600;
    font-size: 0.95rem;
}

/* ===== RECAP FILTERS ===== */
.recap-filters {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.recap-search-input {
    flex: 1;
    min-width: 250px;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    background: var(--surface-color);
    color: var(--text-primary);
    transition: var(--transition);
}

.recap-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.recap-filters select {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    background: var(--surface-color);
    color: var(--text-primary);
    cursor: pointer;
}

/* ===== RESPONSIVE TABS ===== */
@media (max-width: 768px) {
    .tabs-nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tab-btn {
        font-size: 0.8rem;
        padding: 8px 14px;
    }

    .supplier-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .supplier-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .recap-filters {
        flex-direction: column;
    }

    .recap-search-input {
        min-width: 100%;
    }
}
