/*
════════════════════════════════════════════════════════════════════════════════
KANSO-OPS — LITIGE KILLER v3 — STYLES v1.3
Version: 1.3.0

FIX v1.3: Every var() has an explicit fallback color. CSS is self-contained
and works even if the base dashboard CSS doesn't define all variables.

ARCHITECTURE:
1. CSS VARIABLE SAFETY NET
2. REUSABLE (kanso-*): tabs, timeline, config-card, toggle, draft, scan, inputs
3. MODULE (lk-*): KPIs, types, levels, actions
4. RESPONSIVE
════════════════════════════════════════════════════════════════════════════════
*/


/* ══════════════════════════════════════════════════════════════════════════════
   1. REUSABLE: TABS (kanso-tabs)
   ══════════════════════════════════════════════════════════════════════════════ */

.kanso-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    background: var(--bg-card, #1e1b2e);
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
    border-radius: var(--radius-md, 10px);
    margin-bottom: var(--space-6, 24px);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.kanso-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-400, #9ca3af);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    user-select: none;
    font-family: inherit;
    line-height: 1.4;
}

.kanso-tab:hover {
    color: var(--gray-200, #e5e7eb);
    background: rgba(255,255,255,0.05);
}

.kanso-tab.active {
    color: #fff;
    background: rgba(139,92,246,0.15);
    box-shadow: inset 0 0 0 1px rgba(139,92,246,0.3);
}

.kanso-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    background: var(--danger, #ef4444);
    border-radius: 999px;
    animation: kanso-badge-pulse 2s ease-in-out infinite;
}

.kanso-tab-badge:empty { display: none; }

@keyframes kanso-badge-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.kanso-tab-panel { display: none; }
.kanso-tab-panel.active {
    display: block;
    animation: kanso-tab-fadein 0.2s ease;
}

@keyframes kanso-tab-fadein {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}


/* ══════════════════════════════════════════════════════════════════════════════
   2. REUSABLE: TIMELINE (kanso-timeline)
   ══════════════════════════════════════════════════════════════════════════════ */

.kanso-timeline {
    position: relative;
    padding-left: 28px;
    margin: 16px 0;
}

.kanso-timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(255,255,255,0.08);
}

.kanso-timeline-item {
    position: relative;
    padding-bottom: 20px;
}
.kanso-timeline-item:last-child { padding-bottom: 0; }

.kanso-timeline-dot {
    position: absolute;
    left: -24px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--bg-card, #1e1b2e);
}

.kanso-timeline-dot--active  { background: #8b5cf6; }
.kanso-timeline-dot--success { background: #10b981; }
.kanso-timeline-dot--danger  { background: #ef4444; }
.kanso-timeline-dot--warning { background: #f59e0b; }
.kanso-timeline-dot--muted   { background: #4b5563; }

.kanso-timeline-date {
    font-size: 0.75rem;
    color: #6b7280;
    margin-bottom: 2px;
}

.kanso-timeline-label {
    font-size: 0.875rem;
    color: #e5e7eb;
    font-weight: 500;
}


/* ══════════════════════════════════════════════════════════════════════════════
   3. REUSABLE: CONFIG CARD (kanso-config-card)
   ══════════════════════════════════════════════════════════════════════════════ */

.kanso-config-card {
    background: var(--bg-card, #1e1b2e);
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
    border-radius: 10px;
    padding: 20px 24px;
    margin-bottom: 16px;
    transition: border-color 0.15s ease;
}

.kanso-config-card:hover {
    border-color: rgba(255,255,255,0.15);
}

.kanso-config-card--active {
    border-color: #8b5cf6;
    box-shadow: 0 0 0 1px rgba(139,92,246,0.15);
}

.kanso-config-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 16px;
}

.kanso-config-title {
    font-size: 1rem;
    font-weight: 600;
    color: #f3f4f6;
}

.kanso-config-subtitle {
    font-size: 0.875rem;
    color: #9ca3af;
    margin-top: 4px;
    line-height: 1.4;
}

.kanso-config-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.kanso-config-row:first-of-type { border-top: none; }

.kanso-config-label {
    font-size: 0.875rem;
    color: #9ca3af;
    min-width: 120px;
    flex-shrink: 0;
}

.kanso-config-value { flex: 1; }


/* ══════════════════════════════════════════════════════════════════════════════
   4. REUSABLE: TOGGLE (kanso-toggle)
   ══════════════════════════════════════════════════════════════════════════════ */

.kanso-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.kanso-toggle-track {
    position: relative;
    width: 40px;
    height: 22px;
    background: #374151;
    border-radius: 999px;
    transition: background 0.15s ease;
    flex-shrink: 0;
}

.kanso-toggle-track.on { background: #8b5cf6; }

.kanso-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.15s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.kanso-toggle-track.on .kanso-toggle-thumb {
    transform: translateX(18px);
}

.kanso-toggle-label {
    font-size: 0.875rem;
    color: #d1d5db;
}

.kanso-lock {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 0.75rem;
    color: #f59e0b;
    background: rgba(245,158,11,0.15);
    border-radius: 6px;
    user-select: none;
}


/* ══════════════════════════════════════════════════════════════════════════════
   5. REUSABLE: DRAFT CARD (kanso-draft)
   ══════════════════════════════════════════════════════════════════════════════ */

.kanso-draft {
    background: var(--bg-card, #1e1b2e);
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
    border-left: 3px solid #f59e0b;
    border-radius: 10px;
    padding: 20px 24px;
    margin-bottom: 16px;
    transition: border-color 0.15s ease;
}

.kanso-draft:hover {
    border-color: rgba(255,255,255,0.15);
    border-left-color: #f59e0b;
}

.kanso-draft-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-wrap: wrap;
    gap: 8px;
}

.kanso-draft-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 6px;
    background: rgba(245,158,11,0.15);
    color: #f59e0b;
}

.kanso-draft-meta {
    font-size: 0.75rem;
    color: #6b7280;
}

.kanso-draft-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 24px;
    margin-bottom: 16px;
}

.kanso-draft-field {
    margin-bottom: 0;
}

.kanso-draft-field--full {
    grid-column: 1 / -1;
}

.kanso-draft-field-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.kanso-draft-field-value {
    font-size: 0.875rem;
    color: #e5e7eb;
    padding: 8px 12px;
    background: rgba(255,255,255,0.03);
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.06);
}

.kanso-draft-body {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 6px;
    padding: 16px;
    margin: 16px 0;
    font-size: 0.875rem;
    color: #d1d5db;
    line-height: 1.7;
    white-space: pre-wrap;
    max-height: 220px;
    overflow-y: auto;
}

.kanso-draft-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.04);
}

.kanso-draft-attachment {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    font-size: 0.75rem;
    color: #9ca3af;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 6px;
}


/* ══════════════════════════════════════════════════════════════════════════════
   6. REUSABLE: SCAN CONTROL (kanso-scan)
   ══════════════════════════════════════════════════════════════════════════════ */

.kanso-scan-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 20px;
    background: var(--bg-card, #1e1b2e);
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
    border-radius: 10px;
    margin-bottom: 16px;
}

.kanso-scan-info {
    font-size: 0.875rem;
    color: #9ca3af;
}

.kanso-scan-actions {
    display: flex;
    gap: 8px;
}

.kanso-scan-progress {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    margin-bottom: 16px;
    font-size: 0.875rem;
    color: #3b82f6;
    background: rgba(59,130,246,0.1);
    border: 1px solid rgba(59,130,246,0.2);
    border-radius: 6px;
    animation: kanso-scan-breathe 1.5s ease-in-out infinite;
}

.kanso-scan-progress.active { display: flex; }

@keyframes kanso-scan-breathe {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.kanso-scan-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(59,130,246,0.3);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: kanso-spin 0.8s linear infinite;
}

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


/* ══════════════════════════════════════════════════════════════════════════════
   7. REUSABLE: FORM INPUTS (kanso-input, kanso-select, kanso-textarea)
   IMPORTANT: explicit dark colors, no var() dependency for bg/border
   ══════════════════════════════════════════════════════════════════════════════ */

.kanso-input,
.kanso-select,
.kanso-textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.875rem;
    font-family: inherit;
    color: #f3f4f6;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
}

.kanso-input:focus,
.kanso-select:focus,
.kanso-textarea:focus {
    border-color: #8b5cf6;
    box-shadow: 0 0 0 2px rgba(139,92,246,0.2);
}

.kanso-input::placeholder,
.kanso-textarea::placeholder {
    color: #6b7280;
}

.kanso-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 5L6 8L9 5' stroke='%239ca3af' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

/* Force dark selects in filter bar */
.filter-bar .kanso-select,
.filter-bar .kanso-input {
    color: #f3f4f6;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.12);
}

.kanso-textarea {
    min-height: 80px;
    resize: vertical;
    line-height: 1.6;
}

.kanso-input-sm {
    padding: 6px 10px;
    font-size: 0.8rem;
}

/* Override for config card inline inputs */
.kanso-config-card .kanso-input,
.kanso-config-card .kanso-select {
    width: auto;
    max-width: 200px;
    color: #f3f4f6;
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.12);
}

.kanso-config-card .kanso-input:focus {
    border-color: #8b5cf6;
    box-shadow: 0 0 0 2px rgba(139,92,246,0.2);
}

.kanso-form-group { margin-bottom: 16px; }

.kanso-form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}


/* ══════════════════════════════════════════════════════════════════════════════
   MODULE-SPECIFIC: LITIGE KILLER (lk-*)
   ══════════════════════════════════════════════════════════════════════════════ */

/* KPI strip — 4-column grid */
.lk-kpi-strip {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 16px;
    margin-bottom: 24px;
}

/* Override base .kpi-card inside the strip */
.lk-kpi-strip > .kpi-card {
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
}

/* Type badge colors (R1-R7) */
.lk-type-R1 { background: rgba(239,68,68,0.15); color: #ef4444; }
.lk-type-R2 { background: rgba(245,158,11,0.15); color: #f59e0b; }
.lk-type-R3 { background: rgba(59,130,246,0.15); color: #3b82f6; }
.lk-type-R4 { background: rgba(139,92,246,0.15); color: #a78bfa; }
.lk-type-R5 { background: rgba(16,185,129,0.15); color: #10b981; }
.lk-type-R6 { background: rgba(236,72,153,0.2); color: #ec4899; }
.lk-type-R7 { background: rgba(14,165,233,0.2); color: #0ea5e9; }

/* Graduation level indicators */
.lk-level {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
}

.lk-level-1 { color: #3b82f6; background: rgba(59,130,246,0.15); }
.lk-level-2 { color: #f59e0b; background: rgba(245,158,11,0.15); }
.lk-level-3 { color: #ef4444; background: rgba(239,68,68,0.15); }

/* Row actions */
.lk-row-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.lk-row-action {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    background: transparent;
    font-family: inherit;
    line-height: 1.4;
    color: #9ca3af;
}

.lk-row-action--claim {
    color: #a78bfa;
    border-color: rgba(139,92,246,0.3);
}
.lk-row-action--claim:hover {
    background: rgba(139,92,246,0.15);
}

.lk-row-action--ignore {
    color: #9ca3af;
    border-color: rgba(255,255,255,0.08);
}
.lk-row-action--ignore:hover {
    background: rgba(255,255,255,0.05);
}

.lk-row-action--escalate {
    color: #f59e0b;
    border-color: rgba(245,158,11,0.3);
}
.lk-row-action--escalate:hover {
    background: rgba(245,158,11,0.15);
}

.lk-row-action--view {
    color: #9ca3af;
    border-color: rgba(255,255,255,0.08);
}
.lk-row-action--view:hover {
    color: #e5e7eb;
    background: rgba(255,255,255,0.05);
}

/* Amount cell */
.lk-cell-amount {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.lk-amount--negative { color: #ef4444; font-weight: 600; }
.lk-amount--positive { color: #10b981; font-weight: 600; }

/* Auto-correction tag */
.lk-auto-correction {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    margin-left: 6px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #10b981;
    background: rgba(16,185,129,0.15);
    border-radius: 3px;
}

/* Demo ribbon */
.lk-demo-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    margin-left: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #f59e0b;
    background: rgba(245,158,11,0.15);
    border: 1px solid rgba(245,158,11,0.3);
    border-radius: 999px;
    vertical-align: middle;
}

/* Supplier grouping bar */
.lk-supplier-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(139,92,246,0.1);
    border: 1px solid rgba(139,92,246,0.2);
    border-radius: 6px;
    margin-bottom: 16px;
}

.lk-supplier-bar-name { font-weight: 600; color: #f3f4f6; }
.lk-supplier-bar-amount { margin-left: auto; font-weight: 700; color: #a78bfa; }

/* Wide modal for resolve */
.lk-modal-wide .modal-container { max-width: 520px; }


/* ══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .lk-kpi-strip { grid-template-columns: repeat(2, 1fr) !important; }
    .kanso-tab { padding: 8px 12px; font-size: 0.8rem; }
    .kanso-config-row { flex-direction: column; align-items: flex-start; gap: 8px; }
    .kanso-config-label { min-width: auto; }
    .kanso-scan-bar { flex-direction: column; align-items: stretch; }
    .kanso-scan-actions { justify-content: stretch; }
    .kanso-scan-actions .btn { flex: 1; }
    .kanso-draft-fields { grid-template-columns: 1fr; }
    .lk-row-actions { flex-direction: column; }
}

@media (max-width: 480px) {
    .lk-kpi-strip { grid-template-columns: 1fr !important; }
}
