/* CRM Specific Styles */

/* KPI Section */
.crm-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.crm-kpi-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 18px 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(0, 2, 4, 0.03);
    /* Fixed rgba typo from original file if any, or standardizing */
}

.crm-kpi-label {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--muted);
    letter-spacing: 0.5px;
}

.crm-kpi-value {
    font-size: 32px;
    font-weight: 800;
    color: var(--ink);
    line-height: 1;
}

.crm-kpi-card.highlight .crm-kpi-value {
    color: var(--blue);
}

/* Filters */
.crm-filters {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
}

.crm-filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 180px;
}

.crm-filter-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
}

.crm-filter-select {
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    font-family: inherit;
}

.crm-filter-select:focus {
    outline: 2px solid var(--blue);
    border-color: var(--blue);
}

/* CRM Table Styles Replaced by MasterTable */

/* Cell Specifics preserved/adapted */
.crm-contact-name {
    /* Merged into master-table-name-text logic in JS or preserved here if used differently */
    font-weight: 600;
    color: #0b1426;
    /* match master-table-name-text */
    margin-bottom: 2px;
}

.crm-contact-source-small {
    font-size: 11px;
    color: var(--blue);
    text-decoration: none;
    display: block;
}

.crm-contact-source-small:hover {
    text-decoration: underline;
}

.crm-company-name {
    font-weight: 500;
    margin-bottom: 2px;
}

.crm-role-title {
    font-size: 12px;
    color: var(--muted);
}

.text-right {
    text-align: right;
}

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

.text-sm {
    font-size: 12px;
}

/* Badges / Pills - Updated Colors */
.crm-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border: 1px solid transparent;
}

/* Status: Green (Contacted), Yellow/Orange (Pending), Red (High Priority) */

/* Contact Status */
.crm-badge.status-contacted {
    background: #f0fdf4;
    color: #15803d;
    border-color: #bbf7d0;
}

.crm-badge.status-pending {
    background: #fffbeb;
    color: #b45309;
    border-color: #fde68a;
}

.crm-badge.status-closed {
    background: #f8fafc;
    color: #64748b;
    border-color: #e2e8f0;
}

/* Priority */
.crm-badge.priority-high {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fecaca;
}

.crm-badge.priority-medium {
    background: #fff7ed;
    color: #c2410c;
    border-color: #fed7aa;
}

.crm-badge.priority-low,
.crm-badge.priority- {
    background: #f8fafc;
    color: #64748b;
    border-color: #e2e8f0;
}

/* Types - Neutral/Pastel */
.crm-badge.type-lead {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #bfdbfe;
}

.crm-badge.type-client {
    background: #f0fdfa;
    /* Teal-ish */
    color: #0f766e;
    border-color: #ccfbf1;
}

.crm-badge.type-partner {
    background: #faf5ff;
    color: #7e22ce;
    border-color: #e9d5ff;
}

.crm-badge.type-supplier {
    background: #fafaf9;
    /* Stone */
    color: #57534e;
    border-color: #e7e5e4;
}

.crm-badge.type-press {
    background: #fdf4ff;
    /* Fuchsia light */
    color: #a21caf;
    border-color: #f5d0fe;
}

.crm-badge.type-other {
    background: #f3f4f6;
    color: #4b5563;
    border-color: #e5e7eb;
}

/* Actions */
.crm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.crm-action-btn {
    background: white;
    border: 1px solid var(--line);
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    /* Icon size */
    color: var(--muted);
    transition: all 0.2s;
    text-decoration: none;
}

.crm-action-btn:hover {
    background: #f8fafc;
    border-color: var(--blue);
    color: var(--blue);
    transform: translateY(-1px);
}

.crm-action-btn.delete-btn:hover {
    border-color: #ef4444;
    color: #ef4444;
    background: #fef2f2;
}


/* Modal specific overrides if needed, otherwise re-using platform modals */
.crm-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.crm-modal-overlay:not([hidden]) {
    display: flex;
}

.crm-modal-content {
    background: var(--card);
    padding: 24px;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

/* Custom Safe Select */
/* Custom Safe Select */
.crm-custom-select {
    position: relative;
    width: 100%;
}

.crm-select-trigger {
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: var(--ink);
    min-height: 42px;
}

.crm-select-trigger:after {
    content: '▼';
    font-size: 10px;
    color: var(--muted);
    margin-left: 8px;
}

.crm-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-top: 4px;
    /* Removed overflow/max-height from container to avoid double scroll */
}

.crm-select-dropdown[hidden] {
    display: none !important;
}

.crm-select-search {
    padding: 8px;
    border-bottom: 1px solid #eee;
    background: #f9fafb;
}

.crm-select-search input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
}

.crm-options-list {
    max-height: 200px;
    overflow-y: auto;
}

.crm-option {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 14px;
    color: var(--ink);
    border-bottom: 1px solid #f3f4f6;
}

.crm-option:last-child {
    border-bottom: none;
}

.crm-option:hover {
    background-color: #f3f4f6;
}

.crm-option.selected {
    background-color: #eff6ff;
    color: #2563eb;
    font-weight: 600;
}

.crm-select-trigger.disabled {
    background-color: #f3f4f6;
    cursor: not-allowed;
    color: #6b7280;
}

.crm-select-trigger {
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: var(--ink);
    min-height: 42px;
}

.crm-select-trigger:after {
    content: '▼';
    font-size: 10px;
    color: var(--muted);
    margin-left: 8px;
}

.crm-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);

    .crm-select-dropdown[hidden] {
        display: none !important;
    }

    .crm-select-search {
        padding: 8px;
        border-bottom: 1px solid #eee;
        background: #f9fafb;
    }

    .crm-select-search input {
        width: 100%;
        padding: 8px;
        border: 1px solid #ddd;
        border-radius: 6px;
        font-size: 13px;
    }

    .crm-options-list {
        max-height: 200px;
        overflow-y: auto;
    }

    .crm-option {
        padding: 10px 12px;
        cursor: pointer;
        font-size: 14px;
        color: var(--ink);
        border-bottom: 1px solid #f3f4f6;
    }

    .crm-option:last-child {
        border-bottom: none;
    }

    .crm-option:hover {
        background-color: #f3f4f6;
    }

    .crm-option.selected {
        background-color: #eff6ff;
        color: #2563eb;
        font-weight: 600;
    }

    .crm-select-trigger.disabled {
        background-color: #f3f4f6;
        cursor: not-allowed;
        color: #6b7280;
    }