/* ============================================================
   css/hot-leads.css
   -----------------
   PHẠM VI: Tab Hot Leads (#tab-hot-leads) — Kanban board,
            cooldown timers, quick-action cards
   JS MODULE: js/hot-leads.js

   CÁC SECTION CHÍNH:
   - Layout & Stats Bar   — .hl-page, .hl-stats-bar
   - Kanban Board         — .hl-kanban, .hl-column
   - Lead Cards           — .hl-card, .hl-card-hot/warm/cold
   - Countdown Timer      — .hl-countdown, .hl-countdown-warning
   - Action Buttons       — .hl-btn-workshop, .hl-btn-enroll, .hl-btn-call
   - Empty States         — .hl-empty
   - Animations           — pulse-hot, shimmer, countdown-blink
   ============================================================ */

/* ── Keyframe Animations ─────────────────────────────────── */
@keyframes pulse-hot {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4), 0 4px 24px rgba(239, 68, 68, 0.15); }
    50%       { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.0), 0 4px 24px rgba(239, 68, 68, 0.3); }
}
@keyframes countdown-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}
@keyframes hl-slide-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes hl-shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
@keyframes hl-card-demote {
    0%   { opacity: 1; transform: scale(1); }
    50%  { opacity: 0.4; transform: scale(0.95) translateX(20px); }
    100% { opacity: 0; transform: scale(0.9) translateX(40px); }
}

/* ── Page Container ──────────────────────────────────────── */
#tab-hot-leads {
    display: none;
    flex-direction: column;
    gap: 0;
    height: 100%;
    overflow: hidden;
}
#tab-hot-leads.active {
    display: flex;
}

.hl-page {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 20px 24px;
    gap: 20px;
    overflow: hidden;
}

/* ── Stats Bar ───────────────────────────────────────────── */
.hl-stats-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.hl-stat-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    min-width: 130px;
    flex: 1;
    transition: all 0.2s ease;
    cursor: default;
    animation: hl-slide-in 0.3s ease both;
}
.hl-stat-card:hover {
    border-color: var(--color-primary);
    transform: translateY(-1px);
}
.hl-stat-icon {
    font-size: 1.6rem;
    line-height: 1;
}
.hl-stat-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.hl-stat-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.hl-stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.hl-stat-card.stat-hot  .hl-stat-value { color: #ef4444; }
.hl-stat-card.stat-warm .hl-stat-value { color: #f59e0b; }
.hl-stat-card.stat-converted .hl-stat-value { color: #10b981; }
.hl-stat-card.stat-workshop  .hl-stat-value { color: #3b82f6; }

/* ── Header Toolbar ──────────────────────────────────────── */
.hl-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    flex-wrap: wrap;
}
.hl-toolbar-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-right: auto;
}
.hl-filter-btns {
    display: flex;
    gap: 6px;
}
.hl-filter-btn {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-main);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.hl-filter-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}
.hl-filter-btn.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}
.hl-refresh-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-main);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.hl-refresh-btn:hover {
    background: var(--bg-hover);
}
.hl-refresh-btn svg {
    transition: transform 0.4s ease;
}
.hl-refresh-btn.spinning svg {
    animation: spin 0.8s linear infinite;
}

/* ── Kanban Board ─────────────────────────────────────────── */
.hl-kanban {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ── Kanban Column ───────────────────────────────────────── */
.hl-column {
    display: flex;
    flex-direction: column;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    overflow: hidden;
    min-height: 0;
}

.hl-col-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.hl-col-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 0.88rem;
}
.hl-col-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0 6px;
}

/* Hot column */
.hl-column.col-hot .hl-col-header {
    background: linear-gradient(135deg, rgba(239,68,68,0.12) 0%, rgba(239,68,68,0.04) 100%);
    border-bottom-color: rgba(239,68,68,0.25);
}
.hl-column.col-hot .hl-col-title { color: #ef4444; }
.hl-column.col-hot .hl-col-badge {
    background: rgba(239,68,68,0.2);
    color: #ef4444;
}

/* Warm column */
.hl-column.col-warm .hl-col-header {
    background: linear-gradient(135deg, rgba(245,158,11,0.12) 0%, rgba(245,158,11,0.04) 100%);
    border-bottom-color: rgba(245,158,11,0.25);
}
.hl-column.col-warm .hl-col-title { color: #f59e0b; }
.hl-column.col-warm .hl-col-badge {
    background: rgba(245,158,11,0.2);
    color: #f59e0b;
}

/* Converted column */
.hl-column.col-converted .hl-col-header {
    background: linear-gradient(135deg, rgba(16,185,129,0.12) 0%, rgba(16,185,129,0.04) 100%);
    border-bottom-color: rgba(16,185,129,0.25);
}
.hl-column.col-converted .hl-col-title { color: #10b981; }
.hl-column.col-converted .hl-col-badge {
    background: rgba(16,185,129,0.2);
    color: #10b981;
}

.hl-col-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}
.hl-col-body::-webkit-scrollbar { width: 4px; }
.hl-col-body::-webkit-scrollbar-track { background: transparent; }
.hl-col-body::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

/* ── Lead Card ───────────────────────────────────────────── */
.hl-card {
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary, var(--bg-card));
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    animation: hl-slide-in 0.35s ease both;
    position: relative;
    overflow: hidden;
}
.hl-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    border-radius: 3px 0 0 3px;
}
.hl-card:hover {
    transform: translateY(-2px);
    border-color: var(--color-primary);
}

/* Hot card styling */
.hl-card.card-hot {
    border-color: rgba(239,68,68,0.35);
    background: linear-gradient(160deg, rgba(239,68,68,0.05) 0%, var(--bg-card) 60%);
}
.hl-card.card-hot::before { background: #ef4444; }
.hl-card.card-hot:hover {
    border-color: rgba(239,68,68,0.7);
    box-shadow: 0 4px 20px rgba(239,68,68,0.15);
}
.hl-card.card-hot.card-urgent {
    animation: pulse-hot 2s ease-in-out infinite;
}

/* Warm card styling */
.hl-card.card-warm {
    border-color: rgba(245,158,11,0.25);
}
.hl-card.card-warm::before { background: #f59e0b; }
.hl-card.card-warm:hover {
    border-color: rgba(245,158,11,0.6);
    box-shadow: 0 4px 20px rgba(245,158,11,0.12);
}

/* Converted card styling */
.hl-card.card-converted {
    border-color: rgba(16,185,129,0.25);
    opacity: 0.85;
}
.hl-card.card-converted::before { background: #10b981; }

/* ── Card Top Row ────────────────────────────────────────── */
.hl-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.hl-card-identity {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
    flex: 1;
}
.hl-card-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1;
}
.hl-card-phone {
    font-size: 0.78rem;
    color: var(--color-primary);
    font-weight: 600;
    font-family: monospace;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}
.hl-card-source-badge {
    font-size: 0.65rem;
    padding: 2px 7px;
    border-radius: 20px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}
.hl-card-source-badge.src-academy {
    background: rgba(139,92,246,0.15);
    color: #a78bfa;
    border: 1px solid rgba(139,92,246,0.3);
}
.hl-card-source-badge.src-lashes {
    background: rgba(236,72,153,0.15);
    color: #f472b6;
    border: 1px solid rgba(236,72,153,0.3);
}

/* ── Countdown Timer ─────────────────────────────────────── */
.hl-countdown {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 6px;
    border: 1px solid;
    font-variant-numeric: tabular-nums;
    width: fit-content;
}
.hl-countdown.cd-safe {
    color: #34d399;
    border-color: rgba(52,211,153,0.3);
    background: rgba(52,211,153,0.08);
}
.hl-countdown.cd-warning {
    color: #f59e0b;
    border-color: rgba(245,158,11,0.3);
    background: rgba(245,158,11,0.08);
}
.hl-countdown.cd-urgent {
    color: #ef4444;
    border-color: rgba(239,68,68,0.4);
    background: rgba(239,68,68,0.1);
    animation: countdown-blink 1.2s ease-in-out infinite;
}
.hl-countdown.cd-expired {
    color: var(--text-muted);
    border-color: var(--border-color);
    background: transparent;
}
.hl-countdown.cd-warm {
    color: #94a3b8;
    border-color: rgba(148,163,184,0.25);
    background: rgba(148,163,184,0.06);
}

/* ── Card Note Preview ───────────────────────────────────── */
.hl-card-note {
    font-size: 0.74rem;
    color: var(--text-muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    padding: 4px 6px;
    border-radius: 6px;
    border-left: 2px solid var(--border-color);
    background: rgba(255,255,255,0.02);
    font-style: italic;
}

/* ── Card Meta Row ───────────────────────────────────────── */
.hl-card-meta-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.hl-status-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 6px;
    font-weight: 600;
    border: 1px solid;
}
.hl-status-badge.s-consulted  { background: rgba(245,158,11,0.12); color: #f59e0b; border-color: rgba(245,158,11,0.25); }
.hl-status-badge.s-scheduled  { background: rgba(139,92,246,0.12); color: #a78bfa; border-color: rgba(139,92,246,0.25); }
.hl-status-badge.s-new        { background: rgba(239,68,68,0.12); color: #ef4444; border-color: rgba(239,68,68,0.25); }
.hl-status-badge.s-contacted  { background: rgba(59,130,246,0.12); color: #60a5fa; border-color: rgba(59,130,246,0.25); }
.hl-status-badge.s-visited    { background: rgba(16,185,129,0.12); color: #34d399; border-color: rgba(16,185,129,0.25); }
.hl-status-badge.s-deposited  { background: rgba(139,92,246,0.15); color: #c4b5fd; border-color: rgba(139,92,246,0.3); }
.hl-status-badge.s-registered { background: rgba(16,185,129,0.15); color: #10b981; border-color: rgba(16,185,129,0.3); }
.hl-status-badge.s-default    { background: rgba(148,163,184,0.08); color: #94a3b8; border-color: rgba(148,163,184,0.15); }

.hl-assigned-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-left: auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
}

/* ── Action Buttons ──────────────────────────────────────── */
.hl-card-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.hl-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
    justify-content: center;
}
.hl-action-btn:hover {
    transform: translateY(-1px);
}
.hl-action-btn:active {
    transform: translateY(0);
}

.hl-btn-workshop {
    background: rgba(59,130,246,0.1);
    border-color: rgba(59,130,246,0.4);
    color: #60a5fa;
}
.hl-btn-workshop:hover {
    background: rgba(59,130,246,0.2);
    border-color: #3b82f6;
    box-shadow: 0 2px 12px rgba(59,130,246,0.2);
}

.hl-btn-enroll {
    background: rgba(16,185,129,0.1);
    border-color: rgba(16,185,129,0.4);
    color: #34d399;
}
.hl-btn-enroll:hover {
    background: rgba(16,185,129,0.2);
    border-color: #10b981;
    box-shadow: 0 2px 12px rgba(16,185,129,0.2);
}

.hl-btn-call {
    background: rgba(245,158,11,0.1);
    border-color: rgba(245,158,11,0.3);
    color: #f59e0b;
}
.hl-btn-call:hover {
    background: rgba(245,158,11,0.18);
    border-color: #f59e0b;
}

.hl-btn-note {
    background: rgba(148,163,184,0.08);
    border-color: rgba(148,163,184,0.2);
    color: var(--text-muted);
    flex: none;
    padding: 6px 10px;
}
.hl-btn-note:hover {
    background: rgba(148,163,184,0.15);
    color: var(--text-main);
}

.hl-btn-demote {
    background: transparent;
    border-color: rgba(148,163,184,0.15);
    color: var(--text-muted);
    font-size: 0.68rem;
    flex: none;
    padding: 4px 8px;
}
.hl-btn-demote:hover {
    color: #f59e0b;
    border-color: rgba(245,158,11,0.3);
}

/* ── Empty State ─────────────────────────────────────────── */
.hl-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 32px 16px;
    color: var(--text-muted);
    text-align: center;
    flex: 1;
}
.hl-empty-icon {
    font-size: 2.2rem;
    opacity: 0.5;
}
.hl-empty-title {
    font-size: 0.85rem;
    font-weight: 600;
}
.hl-empty-desc {
    font-size: 0.75rem;
    opacity: 0.7;
    max-width: 200px;
    line-height: 1.5;
}

/* ── Loading Skeleton ────────────────────────────────────── */
.hl-skeleton-card {
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.hl-skeleton-line {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--border-color) 25%, rgba(255,255,255,0.08) 50%, var(--border-color) 75%);
    background-size: 200% 100%;
    animation: hl-shimmer 1.4s ease-in-out infinite;
}
.hl-skeleton-line.w-60 { width: 60%; }
.hl-skeleton-line.w-40 { width: 40%; }
.hl-skeleton-line.w-80 { width: 80%; }

/* ── Nav Sidebar Badge ───────────────────────────────────── */
.nav-hot-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: -3px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    font-size: 0.6rem;
    font-weight: 800;
    background: #ef4444;
    color: #fff;
    line-height: 1;
    box-shadow: 0 0 6px rgba(239,68,68,0.5);
    pointer-events: none;
    transition: all 0.2s;
}
.nav-hot-badge.badge-zero {
    display: none;
}

/* Removed deprecated log modal styles */
.hl-log-modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}
.hl-log-modal textarea {
    width: 100%;
    min-height: 80px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary, var(--bg-card));
    color: var(--text-main);
    padding: 10px 12px;
    font-size: 0.85rem;
    font-family: inherit;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.hl-log-modal textarea:focus {
    border-color: var(--color-primary);
}
.hl-log-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}
.hl-log-modal-actions .btn-cancel {
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}
.hl-log-modal-actions .btn-cancel:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

/* ── Cooldown Settings Strip ─────────────────────────────── */
.hl-settings-strip {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    border-radius: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    font-size: 0.78rem;
    color: var(--text-muted);
    flex-shrink: 0;
    flex-wrap: wrap;
}
.hl-settings-strip strong {
    color: var(--text-main);
}
.hl-settings-strip .sep {
    opacity: 0.3;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
    .hl-kanban {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }
    .hl-column {
        max-height: 400px;
    }
    .hl-stats-bar {
        gap: 8px;
    }
    .hl-stat-card {
        min-width: 100px;
    }
}

/* ── Sidebar Nav Badge ───────────────────────────────────── */
@keyframes badge-pulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.25); }
}

.nav-hot-badge {
    position: absolute;
    top: -5px;
    right: -8px;
    background: #ef4444;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    line-height: 1;
    animation: badge-pulse 2s ease-in-out infinite;
    border: 1.5px solid var(--bg-sidebar, #1a1a2e);
}
.nav-hot-badge.badge-zero {
    display: none;
}

/* ── Refresh Button Spinner ──────────────────────────────── */
@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
.hl-refresh-btn.spinning svg {
    animation: spin 0.6s linear infinite;
}

/* ── Log Popover Card ────────────────────────────────────── */
.hl-log-popover-card {
    position: absolute;
    width: 340px;
    padding: 12px;
    border-radius: 12px;
    background: var(--bg-elevated, #1a1d2e);
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    box-shadow: var(--shadow-xl, 0 10px 30px rgba(0,0,0,0.3));
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 1010;
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: hl-slide-in 0.15s ease;
}
.hl-log-modal textarea {
    width: 100%;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    background: var(--bg-input, rgba(255,255,255,0.04));
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.875rem;
    resize: vertical;
    outline: none;
    transition: border-color 0.15s;
}
.hl-log-modal textarea:focus {
    border-color: var(--color-primary, #6366f1);
}
.hl-log-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.hl-log-modal-actions .btn-cancel {
    background: transparent;
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.875rem;
    transition: all 0.15s;
}
.hl-log-modal-actions .btn-cancel:hover {
    border-color: var(--text-muted);
    color: var(--text-main);
}

/* ── KANBAN DRAG & DROP STYLES ───────────────────────────── */
.hl-col-body.drag-over {
    background: rgba(255, 255, 255, 0.03);
    outline: 2px dashed var(--border-color, rgba(255,255,255,0.15));
    outline-offset: -4px;
    border-radius: 0 0 12px 12px;
}
.hl-column.col-hot .hl-col-body.drag-over {
    background: rgba(239, 68, 68, 0.04);
    outline-color: rgba(239, 68, 68, 0.35);
}
.hl-column.col-warm .hl-col-body.drag-over {
    background: rgba(245, 158, 11, 0.04);
    outline-color: rgba(245, 158, 11, 0.35);
}
.hl-card.dragging {
    opacity: 0.35;
    transform: scale(0.98);
    border-color: var(--color-primary, #6366f1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Hide empty placeholder when cards are present (useful during dragging over empty column) */
.hl-col-body:has(.hl-card) .hl-empty {
    display: none;
}
