/**
 * Commercial Module Styles
 *
 * Combines:
 * - Kanban board / Opportunities pipeline (kanban-*, opp-*)
 * - Devis Builder (devis-*, catalog-*, cart-*, margin-*)
 * - Commercial container & sub-tab layout
 *
 * @version 2.0.0
 * @date 2026-03-03
 */

/* =========================================================================
   CSS Variables — Orders/Commercial Theme
   ========================================================================= */

:root, [data-theme="dark"] {
    --orders-bg: #0f1419;
    --orders-surface: #1a1f26;
    --orders-surface-hover: #252b33;
    --orders-border: #2d3640;
    --orders-text: #e7e9ea;
    --orders-text-muted: #8b98a5;
    --orders-accent: #6366f1;
    --orders-accent-hover: #818cf8;
    --orders-success: #10b981;
    --orders-warning: #f59e0b;
    --orders-danger: #ef4444;
    --orders-radius: 8px;
    --orders-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

[data-theme="light"] {
    --orders-bg: #f8fafc;
    --orders-surface: #ffffff;
    --orders-surface-hover: #f1f5f9;
    --orders-border: #e2e8f0;
    --orders-text: #1e293b;
    --orders-text-muted: #64748b;
    --orders-accent: #6366f1;
    --orders-accent-hover: #4f46e5;
    --orders-success: #10b981;
    --orders-warning: #f59e0b;
    --orders-danger: #ef4444;
    --orders-radius: 8px;
    --orders-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* =========================================================================
   Commercial Tab — Container & Sub-tabs
   Unified layout: .commercial-container wraps sub-tabs + sub-content panels.
   Each sub-content manages its own overflow.
   ========================================================================= */

.commercial-container { display: flex; flex-direction: column; height: 100%; padding: 1.5rem; }
.commercial-container .sub-tabs {
    display: flex; gap: 0.375rem; padding: 0.375rem;
    background: var(--bg-tertiary, #2a2a3e); border-radius: 10px;
    width: fit-content; margin-bottom: 1.25rem; flex-shrink: 0;
}
.commercial-container .sub-tab {
    padding: 0.5rem 1.25rem; border: none; background: transparent;
    border-radius: 8px; color: var(--text-muted, #888); cursor: pointer;
    font-size: 0.875rem; font-weight: 500; transition: all 0.2s ease;
}
.commercial-container .sub-tab.active {
    background: var(--accent-color, #6366f1); color: #fff;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
}
.commercial-container .sub-tab:hover:not(.active) {
    color: var(--text-primary, #e0e0e0); background: var(--bg-hover, #333);
}
.commercial-container .sub-content { display: none; flex: 1; overflow-y: auto; min-height: 0; }
.commercial-container .sub-content.active { display: flex; flex-direction: column; }

/* Opportunities sub-tab — overrides for kanban layout */
#subtab-opportunities.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    min-height: 0;
    padding: 1rem;
}

#subtab-opportunities .opp-toolbar {
    flex-shrink: 0;
    margin-bottom: 1rem;
}

#subtab-opportunities .kanban-board {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    min-height: 300px;
    padding-bottom: 1rem;
}

#subtab-opportunities .kanban-column {
    min-height: calc(100vh - 280px);
}

/* =========================================================================
   Kanban Board — Horizontal Columns Layout
   ========================================================================= */

.kanban-board {
    display: flex;
    flex-direction: row;
    gap: 1rem;
    min-height: 100%;
}

.kanban-column {
    flex: 0 0 280px;
    background: var(--orders-surface);
    border-radius: var(--orders-radius);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 180px);
}

.kanban-column-header {
    padding: 1rem;
    border-bottom: 1px solid var(--orders-border);
}

.column-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.column-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.column-count {
    background: var(--orders-bg);
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    color: var(--orders-text-muted);
    margin-left: auto;
}

.column-total {
    font-size: 0.8rem;
    color: var(--orders-text-muted);
    margin-top: 0.25rem;
}

.kanban-column-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.empty-column {
    text-align: center;
    color: var(--orders-text-muted);
    font-size: 0.8rem;
    padding: 2rem 1rem;
    font-style: italic;
}

/* =========================================================================
   Kanban Cards
   ========================================================================= */

.kanban-card {
    background: var(--orders-bg);
    border: 1px solid var(--orders-border);
    border-radius: var(--orders-radius);
    padding: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.kanban-card:hover {
    border-color: var(--orders-accent);
    transform: translateY(-2px);
    box-shadow: var(--orders-shadow);
}

.kanban-card.is-local {
    border-left: 3px solid var(--orders-warning);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.card-ref {
    font-size: 0.75rem;
    color: var(--orders-text-muted);
    font-family: 'Fira Code', monospace;
}

.card-badge {
    font-size: 0.65rem;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

.card-badge.local {
    background: rgba(245, 158, 11, 0.2);
    color: var(--orders-warning);
}

.card-badge.num-affaire {
    background: rgba(37, 99, 235, 0.15);
    color: #2563eb;
    text-transform: none;
    font-family: 'Fira Code', monospace;
    letter-spacing: 0.02em;
}

.card-title {
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.card-client {
    font-size: 0.8rem;
    color: var(--orders-text-muted);
    margin-bottom: 0.5rem;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
}

.card-amount {
    font-weight: 600;
    color: var(--orders-success);
}

.card-user {
    color: var(--orders-text-muted);
}

/* =========================================================================
   Opportunities Kanban — Toolbar
   ========================================================================= */

.opp-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
    flex-wrap: wrap;
}

.opp-filters {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.opp-search-input {
    background: var(--orders-surface);
    border: 1px solid var(--orders-border);
    border-radius: var(--orders-radius);
    padding: 0.5rem 0.75rem;
    color: var(--orders-text);
    font-size: 0.85rem;
    width: 180px;
}

.opp-stage-filter {
    background: var(--orders-surface);
    border: 1px solid var(--orders-border);
    border-radius: var(--orders-radius);
    padding: 0.5rem 0.75rem;
    color: var(--orders-text);
    font-size: 0.85rem;
}

/* =========================================================================
   Opportunities Kanban — Drag & Drop
   ========================================================================= */

.kanban-column-body.drag-over {
    border: 2px dashed var(--orders-accent);
    background: rgba(99, 102, 241, 0.05);
    border-radius: var(--orders-radius);
}

.opp-card[draggable="true"] { cursor: grab; }
.opp-card[draggable="true"]:active { cursor: grabbing; }
.opp-card.dragging { opacity: 0.4; transform: scale(0.95); }

/* =========================================================================
   Opportunities Kanban — Probability Badge
   ========================================================================= */

.opp-probability {
    margin-left: auto;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
}

.opp-probability.high { background: rgba(16, 185, 129, 0.2); color: #10b981; }
.opp-probability.mid { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.opp-probability.low { background: rgba(239, 68, 68, 0.2); color: #ef4444; }

/* =========================================================================
   Opportunities — Modal Base (shared by create + stage-change)
   ========================================================================= */

.opp-create-modal,
.opp-stage-modal {
    width: 90%;
    max-width: 500px;
    background: var(--bg-secondary, #1a1f26);
    border-radius: var(--radius-lg, 12px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.opp-stage-modal { max-width: 480px; }

/* Close button inside modal header */
.opp-create-modal .close-btn,
.opp-stage-modal .close-btn {
    background: none;
    border: none;
    color: var(--text-muted, #888);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}
.opp-create-modal .close-btn:hover,
.opp-stage-modal .close-btn:hover { color: var(--text-primary, #e0e0e0); }

/* =========================================================================
   Opportunities — Create Modal: Client Search Dropdown
   ========================================================================= */

.opp-client-dropdown {
    display: none;
    position: absolute;
    left: 0; right: 0;
    top: 100%;
    max-height: 200px;
    overflow-y: auto;
    background: var(--bg-tertiary, #2a2a3e);
    border: 1px solid var(--border-color, #333);
    border-radius: var(--radius-md, 6px);
    z-index: 10;
    margin-top: 4px;
}

/* Parent form-group must be positioned for dropdown */
.opp-create-modal .form-group { position: relative; }

.opp-client-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-primary, #e0e0e0);
    transition: background 0.15s;
}
.opp-client-item:hover { background: var(--bg-hover, #333); }
.opp-client-item .client-name { font-weight: 500; }
.opp-client-item .client-id { font-size: 0.75rem; color: var(--text-muted, #888); font-family: monospace; }
.opp-client-item.loading {
    justify-content: center;
    color: var(--text-muted, #888);
    font-style: italic;
    cursor: default;
}

/* =========================================================================
   Opportunities Kanban — Stage Change Modal (specific)
   ========================================================================= */

.opp-stage-change-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--orders-surface);
    border-radius: var(--orders-radius);
    margin-bottom: 1rem;
    justify-content: center;
}

.stage-from, .stage-to { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; }
.stage-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.stage-arrow { font-size: 1.25rem; color: var(--orders-text-muted); }

.opp-modal-detail {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--orders-bg);
    border-radius: var(--orders-radius);
}

.opp-graduation-notice {
    padding: 0.75rem;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--orders-radius);
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: #10b981;
}

/* =========================================================================
   Opportunities Kanban — Toast Notifications
   ========================================================================= */

.opp-toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--orders-radius);
    font-size: 0.85rem;
    z-index: 10000;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.opp-toast.visible { opacity: 1; transform: translateY(0); }
.opp-toast-success { background: rgba(16, 185, 129, 0.9); color: white; }
.opp-toast-error { background: rgba(239, 68, 68, 0.9); color: white; }

/* =========================================================================
   Devis Builder — Layout & Toolbar
   ========================================================================= */

.devis-layout { display: flex; flex-direction: column; height: calc(100vh - 120px); overflow-y: auto; }

.devis-toolbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.75rem 1rem; background: var(--bg-secondary, #1e1e2e);
    border-bottom: 1px solid var(--border-color, #333); flex-shrink: 0; gap: 1rem; flex-wrap: wrap;
}
.toolbar-left { display: flex; align-items: center; gap: 0.75rem; flex: 1; }
.toolbar-right { display: flex; gap: 0.5rem; }
.view-toggle { display: flex; background: var(--bg-tertiary, #2a2a3e); border-radius: var(--radius-md, 6px); overflow: hidden; }
.toggle-btn {
    padding: 0.4rem 0.75rem; border: none; background: transparent;
    color: var(--text-secondary, #999); cursor: pointer; font-size: 0.85rem; transition: all 0.2s; white-space: nowrap;
}
.toggle-btn.active { background: var(--accent-color, #4f8fff); color: white; }
.cart-badge {
    display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px;
    padding: 0 4px; border-radius: 9px; background: var(--accent-color, #4f8fff);
    color: white; font-size: 0.7rem; font-weight: 600; margin-left: 4px;
}
.catalog-search {
    padding: 0.4rem 0.75rem; background: var(--bg-input, #1a1a2e);
    border: 1px solid var(--border-color, #333); border-radius: var(--radius-md, 6px);
    color: var(--text-primary, #e0e0e0); font-size: 0.85rem; width: 200px; max-width: 100%;
}
.catalog-search:focus { outline: none; border-color: var(--accent-color, #4f8fff); }

/* =========================================================================
   Devis Builder — Main Content & Panels
   ========================================================================= */

.devis-main { display: flex; flex: 1; min-height: 0; overflow-y: auto; }
.devis-panel { overflow-y: auto; padding: 1rem; }
.devis-panel.active { display: block; }
#devis-catalog-panel { flex: 65; min-width: 0; }
#devis-cart-panel {
    flex: 35; min-width: 280px; border-left: 1px solid var(--border-color, #333);
    background: var(--bg-secondary, #1e1e2e); display: flex; flex-direction: column;
}

/* =========================================================================
   Devis Builder — Breadcrumb
   ========================================================================= */

.catalog-breadcrumb {
    display: flex; align-items: center; gap: 0.4rem; padding: 0.5rem 0;
    font-size: 0.85rem; color: var(--text-muted, #888); margin-bottom: 0.5rem;
}
.bc-link { color: var(--accent-color, #4f8fff); cursor: pointer; transition: color 0.2s; }
.bc-link:hover { color: var(--accent-hover, #6aa0ff); text-decoration: underline; }
.bc-sep { color: var(--text-muted, #666); }
.bc-current, .bc-home { color: var(--text-primary, #e0e0e0); font-weight: 500; }

/* =========================================================================
   Devis Builder — Catalog Grid & Tiles
   ========================================================================= */

.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.75rem; padding-bottom: 1rem; }
.catalog-loading, .catalog-empty {
    grid-column: 1 / -1; text-align: center; padding: 3rem 1rem;
    color: var(--text-muted, #888); font-size: 0.95rem;
}

.catalog-tile {
    background: var(--bg-tertiary, #2a2a3e); border: 1px solid var(--border-color, #333);
    border-radius: var(--radius-md, 6px); padding: 1rem; cursor: pointer; transition: all 0.2s;
    display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.5rem;
}
.catalog-tile:hover {
    border-color: var(--accent-color, #4f8fff); transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.tile-icon { color: var(--accent-color, #4f8fff); opacity: 0.8; }
.tile-name { font-weight: 600; color: var(--text-primary, #e0e0e0); font-size: 0.9rem; line-height: 1.2; word-break: break-word; }
.tile-meta { font-size: 0.75rem; color: var(--text-muted, #888); }
.catalog-all { border-style: dashed; }

/* Product Tiles */
.catalog-product { position: relative; padding: 0; overflow: hidden; }
.product-image {
    width: 100%; height: 140px; overflow: hidden; background: var(--bg-input, #1a1a2e);
    display: flex; align-items: center; justify-content: center;
}
.product-image img { max-width: 100%; max-height: 100%; object-fit: contain; }
.product-info { padding: 0.5rem 0.75rem; text-align: left; width: 100%; }
.product-name {
    font-weight: 600; font-size: 0.8rem; color: var(--text-primary, #e0e0e0);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 0.15rem;
}
.product-code { font-size: 0.7rem; color: var(--text-muted, #888); font-family: monospace; margin-bottom: 0.25rem; }
.product-price { font-weight: 600; color: var(--accent-color, #4f8fff); font-size: 0.85rem; }
.product-stock { font-size: 0.7rem; margin-top: 0.15rem; }
.product-stock.in-stock { color: #4caf50; }
.product-stock.no-stock { color: #f44336; }
.btn-add-to-cart {
    width: 100%; padding: 0.45rem; border: none; background: var(--accent-color, #4f8fff);
    color: white; font-size: 0.8rem; font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.btn-add-to-cart:hover { background: var(--accent-hover, #3a7ae0); }
.btn-add-to-cart.added { background: #4caf50; }

/* Type Tiles */
.catalog-type { min-height: 120px; }
.catalog-type .tile-icon { color: #e67e22; opacity: 0.9; }
.catalog-type:hover .tile-icon { opacity: 1; }

/* =========================================================================
   Devis Builder — Cart Panel
   ========================================================================= */

.cart-title {
    margin: 0 0 0.75rem 0; font-size: 1rem; color: var(--text-primary, #e0e0e0);
    display: flex; justify-content: space-between; align-items: center;
}
.cart-count { font-size: 0.75rem; color: var(--text-muted, #888); font-weight: 400; }
.overhead-control {
    margin-bottom: 1rem; padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary, #2a2a3e); border-radius: var(--radius-md, 6px);
}
.overhead-control label { font-size: 0.75rem; color: var(--text-muted, #888); display: block; margin-bottom: 0.25rem; }
.overhead-row { display: flex; align-items: center; gap: 0.5rem; }
.overhead-row input[type="range"] { flex: 1; accent-color: var(--accent-color, #4f8fff); }
.overhead-row span { font-weight: 600; font-size: 0.85rem; color: var(--text-primary, #e0e0e0); min-width: 40px; text-align: right; }
.cart-lines { flex: 1; overflow-y: auto; }
.cart-empty { text-align: center; padding: 2rem 1rem; color: var(--text-muted, #888); font-size: 0.85rem; }

/* Cart Lines */
.cart-line {
    background: var(--bg-tertiary, #2a2a3e); border: 1px solid var(--border-color, #333);
    border-radius: var(--radius-md, 6px); padding: 0.6rem 0.75rem; margin-bottom: 0.5rem;
}
.cart-line-header { display: flex; justify-content: space-between; align-items: flex-start; }
.cart-line-name {
    font-weight: 600; font-size: 0.8rem; color: var(--text-primary, #e0e0e0);
    flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-right: 0.5rem;
}
.btn-remove-line {
    border: none; background: transparent; color: var(--text-muted, #888);
    font-size: 1.1rem; cursor: pointer; padding: 0; line-height: 1;
}
.btn-remove-line:hover { color: #f44336; }
.cart-line-code { font-size: 0.7rem; color: var(--text-muted, #888); font-family: monospace; margin-bottom: 0.4rem; }
.cart-line-fields { display: flex; gap: 0.5rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 0.4rem; }
.field-group { display: flex; flex-direction: column; flex: 1; min-width: 60px; }
.field-group label { font-size: 0.65rem; color: var(--text-muted, #888); margin-bottom: 0.15rem; }
.field-group label small { font-style: italic; }
.field-group input {
    padding: 0.25rem 0.4rem; background: var(--bg-input, #1a1a2e);
    border: 1px solid var(--border-color, #333); border-radius: var(--radius-sm, 4px);
    color: var(--text-primary, #e0e0e0); font-size: 0.8rem; width: 100%;
}
.field-group input:focus { outline: none; border-color: var(--accent-color, #4f8fff); }
.pa-display { font-size: 0.8rem; color: var(--text-secondary, #aaa); padding: 0.25rem 0; }
.cart-line-margin { display: flex; align-items: center; gap: 0.5rem; font-size: 0.75rem; color: var(--text-secondary, #aaa); }

/* =========================================================================
   Devis Builder — Margin Bars & Summary
   ========================================================================= */

.margin-bar-container { display: flex; align-items: center; gap: 0.4rem; width: 100%; }
.margin-bar { flex: 1; background: var(--bg-input, #1a1a2e); border-radius: 4px; overflow: hidden; }
.margin-bar-fill { height: 100%; border-radius: 4px; transition: width 0.3s ease; }
.margin-green { background: #4caf50; }
.margin-orange { background: #ff9800; }
.margin-red { background: #f44336; }
.margin-bar-label { font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.margin-text-green { color: #4caf50; }
.margin-text-orange { color: #ff9800; }
.margin-text-red { color: #f44336; }

.cart-summary { border-top: 1px solid var(--border-color, #333); padding-top: 0.75rem; margin-top: 0.5rem; flex-shrink: 0; }
.devis-summary { background: var(--bg-tertiary, #2a2a3e); border-radius: var(--radius-md, 6px); padding: 0.75rem; }
.summary-row { display: flex; justify-content: space-between; padding: 0.25rem 0; font-size: 0.8rem; color: var(--text-secondary, #aaa); }
.summary-value { font-weight: 600; color: var(--text-primary, #e0e0e0); }
.summary-divider { border-top: 1px solid var(--border-color, #333); margin: 0.4rem 0; }
.summary-total { font-size: 0.9rem; font-weight: 600; }

/* =========================================================================
   Devis Builder — Placeholder & Notifications
   ========================================================================= */

.placeholder-message {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 4rem 2rem; color: var(--text-muted, #888); text-align: center;
}
.placeholder-message h3 { margin-bottom: 0.5rem; color: var(--text-primary, #e0e0e0); }

.devis-notification {
    position: fixed; bottom: 2rem; right: 2rem; padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md, 6px); color: white; font-size: 0.85rem;
    z-index: 9999; opacity: 0; transform: translateY(10px); transition: all 0.3s;
}
.devis-notification.show { opacity: 1; transform: translateY(0); }
.devis-notification.success { background: #4caf50; }
.devis-notification.error { background: #f44336; }

/* =========================================================================
   Devis Builder — NL Search
   ========================================================================= */

.nl-search-wrapper { display: flex; align-items: center; gap: 0.4rem; }
.catalog-nl-search {
    padding: 0.4rem 0.75rem; background: var(--bg-input, #1a1a2e);
    border: 1px solid #e67e22; border-radius: var(--radius-md, 6px);
    color: var(--text-primary, #e0e0e0); font-size: 0.85rem; width: 260px; max-width: 100%;
}
.catalog-nl-search:focus { outline: none; border-color: #f39c12; box-shadow: 0 0 0 2px rgba(243, 156, 18, 0.2); }
.catalog-nl-search::placeholder { color: var(--text-muted, #888); font-style: italic; }
.btn-nl-search {
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border: 1px solid #e67e22; border-radius: var(--radius-md, 6px);
    background: #e67e22; color: white; cursor: pointer; transition: background 0.2s; flex-shrink: 0;
}
.btn-nl-search:hover { background: #d35400; }
.nl-search-thinking { animation: nlPulse 1.5s ease-in-out infinite; color: #e67e22 !important; }
@keyframes nlPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* =========================================================================
   Card Detail Modal
   ========================================================================= */

.opp-detail-modal {
    width: 90%;
    max-width: 520px;
    background: var(--bg-secondary, #1a1f26);
    border-radius: var(--radius-lg, 12px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.opp-detail-expanded {
    max-width: 680px;
}

.opp-detail-scroll {
    max-height: 70vh;
    overflow-y: auto;
}

/* Attachment list in detail modal */
.detail-attachments {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.detail-attachment-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.5rem;
    background: var(--orders-bg);
    border-radius: 4px;
    font-size: 0.8rem;
}

.att-category {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--orders-accent);
    flex-shrink: 0;
}

.att-filename {
    color: var(--orders-accent);
    text-decoration: none;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.att-filename:hover {
    text-decoration: underline;
}

.att-size {
    font-size: 0.7rem;
    color: var(--orders-text-muted);
    flex-shrink: 0;
}

.opp-detail-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.opp-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color, #2a2a3e);
}

.opp-detail-row:last-child { border-bottom: none; }

.opp-detail-label {
    font-size: 0.8rem;
    color: var(--text-muted, #888);
    flex-shrink: 0;
}

.opp-detail-value {
    font-size: 0.85rem;
    color: var(--text-primary, #e0e0e0);
    font-weight: 500;
    text-align: right;
    display: flex;
    align-items: center;
    gap: 6px;
}

.opp-status-pending { color: #f59e0b; }
.opp-status-synced { color: #10b981; }
.opp-status-rejected { color: #ef4444; }

.btn-success {
    background: #10b981;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-md, 6px);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.2s;
}
.btn-success:hover { background: #059669; }
.btn-success:disabled { opacity: 0.5; cursor: not-allowed; }

/* Won / Lost action buttons */
.btn-won {
    background: #10b981;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-md, 6px);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.2s;
}
.btn-won:hover { background: #059669; }
.btn-won:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-lost {
    background: #ef4444;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-md, 6px);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.2s;
}
.btn-lost:hover { background: #dc2626; }
.btn-lost:disabled { opacity: 0.5; cursor: not-allowed; }

/* =========================================================================
   Stage Gate Upload (mandatory attachment before stage change)
   ========================================================================= */

.stage-gate-upload {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--orders-surface);
    border: 1px solid var(--orders-border);
    border-radius: var(--orders-radius);
}

.stage-gate-upload .gate-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--orders-text);
    margin-bottom: 0.5rem;
}

.gate-dropzone {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    border: 2px dashed var(--orders-border);
    border-radius: var(--orders-radius);
    cursor: pointer;
    transition: all 0.2s;
    padding: 0.5rem;
}

.gate-dropzone:hover,
.gate-dropzone.drag-hover {
    border-color: var(--orders-accent);
    background: rgba(99, 102, 241, 0.05);
}

.gate-dropzone.has-file {
    border-color: var(--orders-success);
    background: rgba(16, 185, 129, 0.05);
}

.gate-filename {
    font-size: 0.8rem;
    color: var(--orders-text-muted);
}

.gate-dropzone.has-file .gate-filename {
    color: var(--orders-success);
    font-weight: 500;
}

/* =========================================================================
   Expanded Create Modal (enriched form with 7 sections)
   ========================================================================= */

.opp-create-expanded {
    max-width: 680px !important;
}

.opp-create-scroll {
    max-height: 70vh;
    overflow-y: auto;
}

.form-section {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--orders-border);
}

.form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--orders-accent);
    margin-bottom: 0.5rem;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
}

.proba-slider {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.proba-slider input[type="range"] {
    flex: 1;
    accent-color: var(--orders-accent);
}

.proba-slider span {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--orders-text);
    min-width: 36px;
    text-align: right;
}

.opp-probability-display {
    display: inline-block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--orders-text-muted);
    padding: 0.35rem 0;
}

@media (max-width: 600px) {
    .form-grid-2, .form-grid-3 {
        grid-template-columns: 1fr;
    }
    .opp-create-expanded {
        max-width: 95vw !important;
    }
}

.opp-card { cursor: pointer; }
.opp-card:hover { border-color: var(--accent-color, #4f8fff); }

/* Detail attachment upload */
.detail-attach-upload {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border-color, #333);
}

/* =========================================================================
   Responsive
   ========================================================================= */

@media (max-width: 1024px) {
    .kanban-column { flex: 0 0 260px; }
}

@media (max-width: 900px) {
    .devis-main { flex-direction: column; }
    #devis-cart-panel { border-left: none; border-top: 1px solid var(--border-color, #333); min-height: 300px; }
    .devis-panel:not(.active) { display: none; }
    .catalog-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

@media (max-width: 600px) {
    .devis-toolbar { flex-direction: column; align-items: stretch; }
    .toolbar-left, .toolbar-right { justify-content: center; }
    .catalog-search { width: 100%; }
    .catalog-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}
