/**
 * Lead Reservation — CRM Kanban board styles
 */

/* ── Wrapper ────────────────────────────────────────────── */
.lr-crm {
    padding: 20px 0;
    position: relative; /* sidebar positions relative to this */
}

/* ── Toolbar ────────────────────────────────────────────── */
.lr-crm__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.lr-crm__toolbar-left,
.lr-crm__toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.lr-crm__total {
    font-size: 0.85rem;
    color: var(--lr-text-muted);
    font-weight: 500;
}

/* ── Add-column form ─────────────────────────────────────── */
.lr-crm__add-col-form {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--lr-surface, #f8fafc);
    border: 1px solid var(--lr-border, #e2e8f0);
    border-radius: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.lr-crm__add-col-input {
    flex: 1;
    min-width: 160px;
    padding: 7px 12px;
    border: 1px solid var(--lr-border, #e2e8f0);
    border-radius: 7px;
    font-size: 0.9rem;
    background: #fff;
    color: var(--lr-text, #1e293b);
    outline: none;
    transition: border-color 0.15s;
}
.lr-crm__add-col-input:focus { border-color: var(--lr-accent, #0148fa); }

.lr-crm__color-swatches {
    display: flex;
    gap: 6px;
    align-items: center;
}

.lr-crm__swatch {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.12s, border-color 0.12s;
    flex-shrink: 0;
}
.lr-crm__swatch:hover { transform: scale(1.2); }
.lr-crm__swatch.is-selected { border-color: #1e293b; transform: scale(1.15); }

.lr-crm__add-col-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ── Board — full width, columns grow equally ────────────── */
.lr-crm__board {
    display: flex;
    gap: 12px;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 12px;
    align-items: flex-start;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: var(--lr-border, #e2e8f0) transparent;
}
.lr-crm__board::-webkit-scrollbar { height: 6px; }
.lr-crm__board::-webkit-scrollbar-thumb { background: var(--lr-border, #e2e8f0); border-radius: 3px; }

/* ── Column — flex-grow so columns fill available width ─── */
.lr-crm__col {
    flex: 1 1 0;
    min-width: 160px;
    background: var(--lr-bg, #f9fafb);
    border: 1.5px solid var(--lr-border, #e2e8f0);
    border-radius: 12px;
    padding: 12px;
    transition: border-color 0.15s, background 0.15s;
    box-sizing: border-box;
}

.lr-crm__col--over {
    border-color: var(--lr-accent, #0148fa);
    background: #eff6ff;
}

/* Fixed "Leads réservés" column */
.lr-crm__col--reserved {
    border-color: #c7d2fe;
    background: #f5f3ff;
}

.lr-crm__col--reserved .lr-crm__col-dot {
    background: #6366f1 !important;
}

.lr-crm__col--reserved .lr-crm__col-count {
    background: #ede9fe;
    color: #4f46e5;
}

/* Reserved card — no drag cursor */
.lr-crm__card--reserved {
    cursor: pointer;
    border-left: 3px solid #6366f1;
}

.lr-crm__card--reserved:hover {
    border-color: #6366f1;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.15);
}

/* Action zone inside sidebar (keep/release form) */
.lr-crm__action-zone {
    margin-top: 8px;
}

.lr-crm__action-textarea {
    width: 100%;
    min-height: 80px;
    resize: vertical;
    margin-bottom: 10px;
}

.lr-crm__action-message {
    font-size: 0.82rem;
    padding: 6px 10px;
    border-radius: 6px;
    margin-bottom: 10px;
}

.lr-crm__action-message--err {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

/* Column reorder drop target */
.lr-crm__col--col-over {
    border-color: #8b5cf6;
    background: #f5f3ff;
    box-shadow: -3px 0 0 0 #8b5cf6;
}

/* Column being dragged */
.lr-crm__col.is-dragging {
    opacity: 0.45;
    cursor: grabbing;
}

/* ── Column header ───────────────────────────────────────── */
.lr-crm__col-header {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 10px;
    min-height: 28px;
}

.lr-crm__col-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.lr-crm__col-title {
    flex: 1;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--lr-text, #1e293b);
    outline: none;
    border-radius: 4px;
    padding: 2px 4px;
    margin: 0 -4px;
    cursor: default;
    word-break: break-word;
}
.lr-crm__col-title[contenteditable="true"] {
    cursor: text;
    background: #fff;
    border: 1px solid var(--lr-accent, #0148fa);
    box-shadow: 0 0 0 2px rgba(1,72,250,0.08);
}

.lr-crm__col-count {
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    background: var(--lr-text-muted, #94a3b8);
    border-radius: 10px;
    padding: 1px 7px;
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
    line-height: 1.6;
}

.lr-crm__col-actions {
    display: flex;
    gap: 2px;
    align-items: center;
    opacity: 0;
    transition: opacity 0.15s;
}
.lr-crm__col:hover .lr-crm__col-actions { opacity: 1; }

.lr-crm__col-rename-btn,
.lr-crm__col-delete-btn {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    border-radius: 5px;
    color: var(--lr-text-muted, #94a3b8);
    display: flex;
    align-items: center;
    transition: background 0.12s, color 0.12s;
}
.lr-crm__col-rename-btn:hover { background: #e0e7ff; color: #4338ca; }
.lr-crm__col-delete-btn:hover { background: #fee2e2; color: #dc2626; }

/* ── Cards area ──────────────────────────────────────────── */
.lr-crm__col-cards {
    min-height: 60px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ── Card ────────────────────────────────────────────────── */
.lr-crm__card {
    background: #fff;
    border: 1px solid var(--lr-border, #e2e8f0);
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    transition: box-shadow 0.15s, transform 0.1s, border-color 0.15s;
    user-select: none;
}
.lr-crm__card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-color: var(--lr-accent, #0148fa);
}
.lr-crm__card:focus-visible {
    outline: 2px solid var(--lr-accent, #0148fa);
    outline-offset: 2px;
}
.lr-crm__card.is-dragging {
    opacity: 0.45;
    cursor: grabbing;
    transform: rotate(1.5deg) scale(0.97);
}

/* Insert position indicators for intra-column reordering */
.lr-crm__card--insert-before {
    box-shadow: 0 -3px 0 0 var(--lr-accent, #0148fa);
    margin-top: 3px;
}
.lr-crm__card--insert-after {
    box-shadow: 0 3px 0 0 var(--lr-accent, #0148fa);
    margin-bottom: 3px;
}

.lr-crm__card-post-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--lr-text-muted, #64748b);
    margin-bottom: 3px;
    line-height: 1.3;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lr-crm__card-stars {
    display: flex;
    gap: 1px;
    margin-bottom: 4px;
    line-height: 1;
}

.lr-crm__star {
    font-size: 0.78rem;
    color: #cbd5e1;
}

.lr-crm__star--on {
    color: #f59e0b;
}

.lr-crm__card-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--lr-text, #1e293b);
    margin-bottom: 3px;
    line-height: 1.3;
}

.lr-crm__card-date {
    font-size: 0.74rem;
    color: var(--lr-text-muted, #94a3b8);
    margin-bottom: 8px;
}

.lr-crm__card-footer {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.lr-crm__card-badges {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    align-items: center;
}

.lr-crm__card-notes-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.7rem;
    color: var(--lr-text-muted, #94a3b8);
    background: var(--lr-bg, #f9fafb);
    border: 1px solid var(--lr-border, #e2e8f0);
    border-radius: 6px;
    padding: 2px 6px;
    font-weight: 600;
}
.lr-crm__card-notes-badge svg { width: 10px; height: 10px; }

/* ── Drop placeholder ────────────────────────────────────── */
.lr-crm__drop-placeholder {
    display: none;
    height: 44px;
    border: 2px dashed var(--lr-accent, #0148fa);
    border-radius: 7px;
    background: #eff6ff;
    opacity: 0.6;
}
.lr-crm__col--over .lr-crm__drop-placeholder { display: block; }

/* ── Empty state ─────────────────────────────────────────── */
.lr-crm__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 48px 24px;
    text-align: center;
    color: var(--lr-text-muted, #94a3b8);
}
.lr-crm__empty svg { width: 48px; height: 48px; opacity: 0.4; }
.lr-crm__empty p { margin: 0; font-size: 0.92rem; line-height: 1.6; }

/* ── Sidebar overlay ─────────────────────────────────────── */
.lr-crm__overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 1000;
    backdrop-filter: blur(1px);
    -webkit-backdrop-filter: blur(1px);
}
.lr-crm__overlay.is-open { display: block; }

/* ── Sidebar drawer ──────────────────────────────────────── */
.lr-crm__sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 650px;
    max-width: 100vw;
    background: #fff;
    box-shadow: -4px 0 32px rgba(0,0,0,0.14);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
    overflow: hidden;
}
.lr-crm__sidebar.is-open { transform: translateX(0); }

.lr-crm__sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--lr-border, #e2e8f0);
    flex-shrink: 0;
    background: var(--lr-bg, #f9fafb);
}

.lr-crm__sidebar-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--lr-text, #1e293b);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lr-crm__sidebar-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 7px;
    color: var(--lr-text-muted, #94a3b8);
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: background 0.12s, color 0.12s;
}
.lr-crm__sidebar-close:hover { background: #fee2e2; color: #dc2626; }
.lr-crm__sidebar-close svg { width: 18px; height: 18px; }

.lr-crm__sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--lr-border, #e2e8f0) transparent;
}
.lr-crm__sidebar-body::-webkit-scrollbar { width: 5px; }
.lr-crm__sidebar-body::-webkit-scrollbar-thumb { background: var(--lr-border, #e2e8f0); border-radius: 3px; }

/* ── View toggle ─────────────────────────────────────────── */
.lr-crm__view-toggle {
    display: flex;
    gap: 0;
    border: 1px solid var(--lr-border, #e2e8f0);
    border-radius: 7px;
    overflow: hidden;
    flex-shrink: 0;
}

.lr-crm__view-btn {
    background: #fff;
    border: none;
    padding: 7px 10px;
    cursor: pointer;
    color: var(--lr-text-muted, #94a3b8);
    display: flex;
    align-items: center;
    transition: background 0.12s, color 0.12s;
    line-height: 1;
}
.lr-crm__view-btn svg { width: 15px; height: 15px; }
.lr-crm__view-btn:hover { background: var(--lr-bg, #f9fafb); color: var(--lr-text, #1e293b); }
.lr-crm__view-btn--active { background: var(--lr-accent, #0148fa); color: #fff !important; }
.lr-crm__view-btn--active:hover { background: var(--lr-accent-hover, #0139d6); }

/* ── List view ───────────────────────────────────────────── */
.lr-crm__list {
    width: 100%;
    overflow-x: auto;
}

.lr-crm__list-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.lr-crm__list-table thead tr {
    border-bottom: 2px solid var(--lr-border, #e2e8f0);
}

.lr-crm__list-table th {
    text-align: left;
    padding: 8px 12px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--lr-text-muted, #94a3b8);
    white-space: nowrap;
}

.lr-crm__list-row {
    border-bottom: 1px solid var(--lr-border, #e2e8f0);
    cursor: pointer;
    transition: background 0.1s;
}
.lr-crm__list-row:hover { background: var(--lr-bg, #f9fafb); }
.lr-crm__list-row:focus-visible { outline: 2px solid var(--lr-accent, #0148fa); outline-offset: -2px; }

.lr-crm__list-row td {
    padding: 10px 12px;
    vertical-align: middle;
}

.lr-crm__list-title {
    font-weight: 600;
    color: var(--lr-text, #1e293b);
}

.lr-crm__list-title .lr-crm__card-post-title {
    display: block;
    margin-bottom: 1px;
}

.lr-crm__list-title .lr-crm__card-stars {
    display: flex;
    margin-bottom: 2px;
}

.lr-crm__list-subtitle {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--lr-text, #1e293b);
}

.lr-crm__list-date {
    color: var(--lr-text-muted, #94a3b8);
    font-size: 0.82rem;
    white-space: nowrap;
}

.lr-crm__list-col-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--badge-color) 12%, white);
    color: var(--badge-color);
    border: 1px solid color-mix(in srgb, var(--badge-color) 30%, white);
    white-space: nowrap;
}

/* Fallback for browsers without color-mix */
@supports not (color: color-mix(in srgb, red 10%, white)) {
    .lr-crm__list-col-badge {
        background: #f1f5f9;
        color: #475569;
        border-color: #e2e8f0;
    }
}

/* ── Toast ───────────────────────────────────────────────── */
.lr-crm__toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #1e293b;
    color: #fff;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 0.85rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    z-index: 1200;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
}
.lr-crm__toast.is-visible { opacity: 1; transform: translateY(0); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 640px) {
    .lr-crm__col { min-width: 140px; }
    .lr-crm__sidebar { width: 100vw; }
    .lr-crm__add-col-form { flex-direction: column; align-items: stretch; }
    .lr-crm__add-col-input { min-width: unset; }
}

/* ── Editable fields accordion (CRM sidebar) ──────────────────── */

.lr-crm__editable-accordion .lr-leads__editable-section {
    padding-top: 8px;
}

/* ── Sidebar back button ───────────────────────────────────────── */

.lr-crm__sidebar-back {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    padding: 4px 6px;
    margin-right: 4px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--lr-text-muted, #64748b);
    cursor: pointer;
    border-radius: 5px;
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

.lr-crm__sidebar-back:hover {
    color: var(--lr-text, #1e293b);
    background: var(--lr-surface, #f1f5f9);
}

.lr-crm__sidebar-back svg {
    width: 16px;
    height: 16px;
}

/* ── Checklist send — trigger button (CRM + Mes Leads) ─────────── */

.lr-crm__checklist-send {
    margin-top: 4px;
}

/* ── Checklist inline form (Mes Leads only) ────────────────────── */

.lr-crm__checklist-form {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ── Checklist sidebar panel (CRM sidebar swap) ────────────────── */

#lr-crm-checklist-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 4px 0;
}

.lr-crm__checklist-panel-intro {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--lr-surface, #f8fafc);
    border-radius: 8px;
    border: 1px solid var(--lr-border, #e2e8f0);
}

.lr-crm__checklist-panel-intro svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    color: var(--lr-accent, #6366f1);
}

.lr-crm__checklist-panel-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--lr-text, #1e293b);
    margin: 0 0 2px;
}

.lr-crm__checklist-panel-email {
    font-size: 0.8rem;
    color: var(--lr-text-muted, #64748b);
    margin: 0;
}

.lr-crm__checklist-panel-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--lr-text-muted, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: -8px;
}

.lr-crm__checklist-panel-actions {
    padding-top: 4px;
}

/* ── Shared: template select, preview list, messages ───────────── */

.lr-crm__checklist-template-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--lr-border, #e2e8f0);
    border-radius: 6px;
    font-size: 0.875rem;
    color: var(--lr-text, #1e293b);
    background: #fff;
    cursor: pointer;
}

.lr-crm__checklist-template-select:focus {
    outline: none;
    border-color: var(--lr-accent, #6366f1);
    box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}

.lr-crm__checklist-preview-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.lr-crm__checklist-preview-item {
    font-size: 0.82rem;
    color: var(--lr-text, #1e293b);
    padding: 6px 10px;
    background: var(--lr-surface, #f8fafc);
    border-radius: 5px;
    border-left: 2px solid #e2e8f0;
    line-height: 1.4;
}

.lr-crm__checklist-preview-item.is-required {
    border-left-color: var(--lr-accent, #6366f1);
}

.lr-crm__checklist-preview-empty {
    font-size: 0.8rem;
    color: var(--lr-text-muted, #94a3b8);
    font-style: italic;
}

.lr-crm__checklist-required {
    color: var(--lr-accent, #6366f1);
    font-weight: 700;
    margin-right: 3px;
}

.lr-crm__checklist-msg {
    font-size: 0.82rem;
    padding: 8px 12px;
    border-radius: 6px;
}

.lr-crm__checklist-msg--ok {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.lr-crm__checklist-msg--err {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ── Success state (CRM panel) ─────────────────────────────────── */

.lr-crm__checklist-success {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 16px;
    padding: 40px 20px;
}

.lr-crm__checklist-success svg {
    width: 56px;
    height: 56px;
}

.lr-crm__checklist-success p {
    font-size: 0.95rem;
    color: var(--lr-text, #1e293b);
    line-height: 1.6;
    margin: 0;
}
