/* ============================================================================
   CRM LEADS SYSTEM STYLES
   ============================================================================ */

/* CRM Button in Sidebar Header */
.crm-leads-btn {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    border: none;
    border-radius: 20px;
    padding: 6px 12px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.crm-leads-btn:hover {
    background: linear-gradient(135deg, #45a049, #3d8b40);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.leads-count {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: bold;
    min-width: 18px;
    text-align: center;
}

/* Lead Tooltip (Form for Adding/Editing Leads) */
.lead-tooltip {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    width: 90%;
    max-width: 550px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: tooltipSlideIn 0.3s ease-out;
}

.lead-tooltip-header {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    padding: 16px 20px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.lead-tooltip-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.lead-tooltip-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.lead-tooltip-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lead-tooltip-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.lead-form-section {
    margin-bottom: 20px;
}

.lead-form-section h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.lead-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.lead-form-row.full {
    grid-template-columns: 1fr;
}

.lead-form-field {
    display: flex;
    flex-direction: column;
}

.lead-form-field label {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    margin-bottom: 4px;
}

.lead-form-field input,
.lead-form-field select,
.lead-form-field textarea {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    transition: border-color 0.2s;
}

.lead-form-field input:focus,
.lead-form-field select:focus,
.lead-form-field textarea:focus {
    outline: none;
    border-color: #4CAF50;
}

.lead-form-field textarea {
    resize: vertical;
    min-height: 60px;
}

.zone-checkboxes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px 8px;
    margin-top: 12px;
    margin-bottom: 20px;
    padding: 12px;
    background: #f9f9f9;
    border-radius: 8px;
}

.zone-checkbox-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.zone-checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.zone-checkbox-item label {
    font-size: 13px;
    cursor: pointer;
    margin: 0;
    font-weight: 500;
}

.lead-tooltip-actions {
    padding: 16px 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.lead-tooltip-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.lead-tooltip-btn.primary {
    background: #4CAF50;
    color: white;
}

.lead-tooltip-btn.primary:hover {
    background: #45a049;
    transform: translateY(-1px);
}

.lead-tooltip-btn.secondary {
    background: white;
    color: #666;
    border: 2px solid #ddd;
}

.lead-tooltip-btn.secondary:hover {
    background: #f5f5f5;
}

/* Leads List Panel */
.leads-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    width: 90%;
    max-width: 650px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: tooltipSlideIn 0.3s ease-out;
}

.leads-panel-header {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    padding: 16px 20px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.leads-panel-search {
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
}

.leads-panel-search input {
    width: 100%;
    padding: 10px 40px 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.leads-panel-body {
    padding: 10px;
    overflow-y: auto;
    flex: 1;
}

.lead-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 10px;
    transition: all 0.2s;
}

.lead-card:hover {
    border-color: #4CAF50;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.1);
}

.lead-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.lead-card-name {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.lead-card-contact {
    font-size: 13px;
    color: #666;
    margin: 4px 0;
}

.lead-card-criteria {
    font-size: 12px;
    color: #888;
    margin: 8px 0;
    padding: 8px;
    background: #f9f9f9;
    border-radius: 4px;
}

.lead-card-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

.lead-card-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.lead-card-btn.edit {
    background: #2196F3;
    color: white;
}

.lead-card-btn.matches {
    background: #FF9800;
    color: white;
}

.lead-card-btn.delete {
    background: #f44336;
    color: white;
}

.lead-card-btn:hover {
    transform: translateY(-1px);
    opacity: 0.9;
}

@keyframes tooltipSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -48%);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

/* --- PREMIUM CRM SIDEBAR ENHANCEMENTS --- */
.crm-sidebar-card {
    border: 1px solid #e2e8f0;
    background: #fff;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.crm-sidebar-card:hover {
    transform: translateY(-2px);
    border-color: #3b82f6 !important;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05) !important;
}

.heat-tag {
    font-size: 8px;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}
.heat-tag.hot { background: #fee2e2; color: #ef4444; }
.heat-tag.warm { background: #fffbeb; color: #f59e0b; }
.heat-tag.cold { background: #eff6ff; color: #3b82f6; }

/* Timeline / Activities */
.crm-timeline {
    position: relative;
    padding-left: 20px;
    margin-top: 20px;
}

.crm-timeline::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 5px;
    bottom: 5px;
    width: 2px;
    background: #e2e8f0;
}

.crm-timeline-item {
    position: relative;
    padding-bottom: 20px;
}

.crm-timeline-item::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #3b82f6;
    z-index: 1;
}

.crm-timeline-time {
    font-size: 10px;
    color: #94a3b8;
    margin-bottom: 4px;
}

.crm-timeline-content {
    font-size: 12px;
    color: #1e293b;
    background: #f8fafc;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

/* Activity Tabs */
.detail-tabs {
    display: flex;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 20px;
    gap: 15px;
}

.detail-tab {
    padding: 8px 4px;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.detail-tab.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: #94a3b8;
}

.empty-state i {
    font-size: 40px;
    margin-bottom: 16px;
    opacity: 0.3;
}

@media (max-width: 768px) {

    .leads-panel,
    .modal-lead-form-overlay .custom-modal,
    .lead-tooltip {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        transform: none !important;
        width: 100% !important;
        max-width: none !important;
        height: 90vh !important;
        max-height: 90vh !important;
        border-radius: 20px 20px 0 0 !important;
        z-index: 10001 !important;
        animation: mobileSheetSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .leads-panel-header,
    .lead-tooltip-header,
    .custom-modal-header {
        border-radius: 20px 20px 0 0;
        padding: 20px;
    }

    .lead-form-row,
    .form-row {
        grid-template-columns: 1fr;
        display: flex;
        flex-direction: column;
        gap: 15px;
    }

    .zone-checkboxes {
        grid-template-columns: repeat(2, 1fr);
    }

    .lead-card-header {
        flex-direction: column;
        gap: 5px;
    }

    .lead-card-actions {
        flex-wrap: wrap;
    }

    .lead-card-btn {
        flex: 1;
        min-height: 44px;
        font-size: 14px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    @keyframes mobileSheetSlideUp {
        from {
            transform: translateY(100%);
        }

        to {
            transform: translateY(0);
        }
    }
}