/* ==========================================================================
   Vetmivo Phase 13/15: CRM & Customer Retention Modern Stylesheet (.crm-*)
   ========================================================================== */

:root {
    --crm-primary: #4f46e5;
    --crm-primary-light: #eef2ff;
    --crm-success: #10b981;
    --crm-success-light: #ecfdf5;
    --crm-warning: #f59e0b;
    --crm-warning-light: #fffbeb;
    --crm-danger: #ef4444;
    --crm-danger-light: #fef2f2;
    --crm-info: #06b6d4;
    --crm-info-light: #ecfeff;
}

/* 1. Lifecycle Badges */
.crm-badge-lifecycle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 0.76rem;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    letter-spacing: 0.01em;
    transition: all 0.15s ease;
}

.crm-badge-new {
    background-color: #ecfdf5;
    color: #059669;
    border: 1px solid #a7f3d0;
}

.crm-badge-active {
    background-color: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}

.crm-badge-loyal {
    background-color: #fffbeb;
    color: #d97706;
    border: 1px solid #fde68a;
}

.crm-badge-at-risk {
    background-color: #fff7ed;
    color: #ea580c;
    border: 1px solid #fed7aa;
}

.crm-badge-inactive {
    background-color: #f8fafc;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.crm-badge-lost {
    background-color: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.crm-badge-reactivated {
    background-color: #f5f3ff;
    color: #7c3aed;
    border: 1px solid #ddd6fe;
}

/* 2. Tag Chips */
.crm-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.74rem;
    font-weight: 500;
    line-height: 1.2;
    background-color: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
    transition: all 0.15s ease;
}

.crm-tag-chip:hover {
    background-color: #e2e8f0;
}

.crm-tag-chip .remove-tag-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0 2px;
    font-size: 11px;
    cursor: pointer;
    color: #94a3b8;
    transition: color 0.15s ease;
}

.crm-tag-chip .remove-tag-btn:hover {
    color: #ef4444;
}

/* 3. CRM Metric & KPI Cards */
.crm-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.crm-kpi-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease;
}

.crm-kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #cbd5e1;
    transition: background 0.2s ease;
}

.crm-kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
    border-color: #cbd5e1;
}

.crm-kpi-card.kpi-primary::before { background: linear-gradient(90deg, #4f46e5, #818cf8); }
.crm-kpi-card.kpi-success::before { background: linear-gradient(90deg, #10b981, #34d399); }
.crm-kpi-card.kpi-warning::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.crm-kpi-card.kpi-danger::before { background: linear-gradient(90deg, #ef4444, #f87171); }
.crm-kpi-card.kpi-info::before { background: linear-gradient(90deg, #06b6d4, #38bdf8); }

.crm-kpi-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.crm-kpi-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.crm-kpi-icon {
    font-size: 1.25rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #f1f5f9;
}

.crm-kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.1;
    margin-top: 4px;
}

.crm-kpi-subtitle {
    font-size: 0.76rem;
    color: #94a3b8;
    line-height: 1.3;
}

/* 4. CRM Segment Cards */
.crm-segment-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    height: 100%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.crm-segment-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px -4px rgba(0, 0, 0, 0.07);
    border-color: #cbd5e1;
}

.crm-segment-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}

.crm-segment-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
    text-decoration: none;
    line-height: 1.3;
}

.crm-segment-title:hover {
    color: #4f46e5;
}

.crm-segment-desc {
    font-size: 0.85rem;
    color: #64748b;
    line-height: 1.45;
    flex-grow: 1;
    margin-bottom: 16px;
}

.crm-segment-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 14px;
    border-top: 1px solid #f1f5f9;
    margin-top: auto;
}

/* 5. CRM Timeline */
.crm-timeline-container {
    position: relative;
    padding-left: 28px;
    margin-top: 14px;
}

.crm-timeline-container::before {
    content: '';
    position: absolute;
    top: 6px;
    bottom: 6px;
    left: 10px;
    width: 2px;
    background: #e2e8f0;
}

.crm-timeline-item {
    position: relative;
    margin-bottom: 18px;
}

.crm-timeline-item:last-child {
    margin-bottom: 0;
}

.crm-timeline-dot {
    position: absolute;
    left: -28px;
    top: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid #4f46e5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    box-shadow: 0 0 0 2px #ffffff;
}

.crm-timeline-content {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 16px;
}

.crm-timeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.crm-timeline-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: #1e293b;
}

.crm-timeline-date {
    font-size: 0.74rem;
    color: #94a3b8;
    white-space: nowrap;
}

.crm-timeline-desc {
    font-size: 0.82rem;
    color: #475569;
    margin: 0;
    line-height: 1.4;
}

/* 6. Follow-Up Task Card */
.crm-task-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px 18px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.crm-task-card:hover {
    background: #f8fafc;
    transform: translateX(2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.crm-task-card.priority-high {
    border-left: 4px solid #ef4444;
}

.crm-task-card.priority-normal {
    border-left: 4px solid #3b82f6;
}

.crm-task-card.priority-low {
    border-left: 4px solid #94a3b8;
}

/* 7. Visual Rule Builder (.crm-rule-row) */
.crm-rule-row {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.15s ease;
}

.crm-rule-row:hover {
    background: #f1f5f9;
}

.crm-rule-connector {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    background: #e0e7ff;
    color: #4338ca;
    text-transform: uppercase;
}

/* 8. Avatar Circle Initials */
.crm-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e0e7ff;
    color: #4338ca;
    font-weight: 700;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #c7d2fe;
}
