/* CRM Container */
.crm-container {
    background: #212529;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #e9ecef;
    max-width: 100%;
    margin: 0 auto;
    font-size: 13px;
    /* Reduced base font size */
}

/* Header Section */
.crm-header {
    background: #343a40;
    border-bottom: 1px solid #495057;
    padding: 24px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.crm-header-left h1 {
    margin: 0;
    font-size: 28px;
    font-weight: 600;
    color: #e9ecef;
    display: flex;
    align-items: center;
    gap: 12px;
}

.crm-header-left h1 i {
    color: #007bff;
}

.crm-subtitle {
    margin: 4px 0 0 0;
    color: #adb5bd;
    font-size: 14px;
}

.crm-stats {
    display: flex;
    gap: 32px;
}

.stat-item {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: #e9ecef;
}

.stat-label {
    font-size: 12px;
    color: #adb5bd;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Filter Section */
.crm-filters {
    background: #343a40;
    border-bottom: 1px solid #495057;
    padding: 20px 32px;
    width: 100%;
}

.filter-row {
    display: flex;
    gap: 20px;
    align-items: end;
    margin-bottom: 16px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 12px;
    font-weight: 600;
    color: #adb5bd;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-select,
.filter-input {
    padding: 8px 12px;
    border: 1px solid #495057;
    border-radius: 6px;
    font-size: 14px;
    min-width: 150px;
    background: #495057;
    color: #e9ecef;
}

.filter-select:focus,
.filter-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.3);
    background: #495057;
}

.filter-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Main Content */
.crm-content {
    display: flex;
    height: calc(100vh - 200px);
    width: 100%;
}

/* Sidebar */
.crm-sidebar {
    width: 280px;
    min-width: 280px;
    background: #343a40;
    border-right: 1px solid #495057;
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #495057;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #e9ecef;
}

.project-count {
    background: #495057;
    color: #e9ecef;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.projects-list {
    padding: 0;
}

.project-item {
    padding: 16px 20px;
    border-bottom: 1px solid #495057;
    cursor: pointer;
    transition: background-color 0.2s;
}

.project-item:hover {
    background: #495057;
}

.project-item.active {
    background: #495057;
    border-left: 4px solid #007bff;
}

.project-item h4 {
    margin: 0 0 4px 0;
    font-size: 14px;
    font-weight: 600;
    color: #e9ecef;
}

.project-item p {
    margin: 0;
    font-size: 12px;
    color: #adb5bd;
}

.project-stats {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.project-stat {
    font-size: 11px;
    color: #adb5bd;
}

/* Main Content Area */
.crm-main {
    flex: 1;
    background: #343a40;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.table-header {
    padding: 20px 32px;
    border-bottom: 1px solid #495057;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-title h3 {
    margin: 0 0 4px 0;
    font-size: 18px;
    font-weight: 600;
    color: #e9ecef;
}

.lead-count {
    font-size: 14px;
    color: #adb5bd;
}

.table-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Table */
.table-container {
    flex: 1;
    overflow: auto;
    width: 100%;
}

.crm-table {
    width: 100%;
    min-width: 1800px;
    /* Increased from 1200px to reduce truncation */
    border-collapse: collapse;
    table-layout: fixed;
}

.crm-table th {
    background: #495057;
    padding: 10px 14px;
    /* Reduced padding */
    text-align: left;
    font-size: 12px;
    /* Increased from 11px for better readability */
    font-weight: 600;
    color: #e9ecef;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #6c757d;
    position: sticky;
    top: 0;
    z-index: 10;
}

.crm-table td {
    padding: 10px 14px;
    /* Reduced padding */
    border-bottom: 1px solid #495057;
    font-size: 12px;
    /* Increased from 11px for better readability */
    vertical-align: middle;
    color: #e9ecef;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 0;
}

.crm-table tbody tr:hover {
    background: #495057;
}

/* Column widths */
.checkbox-col {
    width: 50px;
}

.company-col {
    width: 200px;
    /* Increased */
}

.email-col {
    width: 220px;
    /* Increased */
}

.phone-col {
    width: 140px;
    /* Increased */
}

.linkedin-col {
    width: 160px;
    /* Increased */
}

.project-col {
    width: 180px;
    /* Increased */
}

.status-col {
    width: 120px;
    /* Increased */
}

.email-status-col {
    width: 140px;
    /* Increased */
}

.sentiment-col {
    width: 120px;
    /* Increased */
}

.date-col {
    width: 140px;
    /* Increased */
}

.actions-col {
    width: 120px;
    /* Increased */
}

/* Email column styling for better readability */
.email-col {
    word-break: break-all;
    max-width: 200px;
}

/* Status badges */
.status-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #6f42c1;
    color: white;
}

/* Sentiment badges */
.sentiment-positive,
.sentiment-neutral,
.sentiment-negative {
    background: #6f42c1;
    color: white;
}

/* Action buttons */
.action-buttons {
    display: flex;
    gap: 8px;
}

.btn-icon {
    padding: 6px;
    border: none;
    background: transparent;
    color: #6c757d;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: #e9ecef;
    color: #495057;
}

/* Pagination */
.pagination {
    padding: 20px 32px;
    border-top: 1px solid #e1e5e9;
    display: flex;
    justify-content: center;
    gap: 8px;
}

.pagination button {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    background: white;
    color: #495057;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
}

.pagination button:hover {
    background: #e9ecef;
}

.pagination button.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 8px;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e1e5e9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #2c3e50;
}

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: #000;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e1e5e9;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Lead details */
.lead-details {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.detail-section h3 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    border-bottom: 1px solid #e1e5e9;
    padding-bottom: 8px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-item label {
    font-size: 12px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-item span {
    font-size: 14px;
    color: #2c3e50;
}

/* Email and Reply History */
.email-history,
.reply-history {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    padding: 16px;
}

.history-item {
    padding: 12px;
    border-bottom: 1px solid #f8f9fa;
    margin-bottom: 12px;
}

.history-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

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

.history-date {
    font-size: 12px;
    color: #6c757d;
}

.history-content {
    font-size: 14px;
    color: #2c3e50;
    line-height: 1.5;
}

/* Loading Spinner */
.loading-spinner {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-primary:hover {
    background: #0056b3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #545b62;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .crm-content {
        flex-direction: column;
    }

    .crm-sidebar {
        width: 100%;
        height: auto;
        max-height: 200px;
        min-width: auto;
    }

    .filter-row {
        flex-wrap: wrap;
    }

    .crm-table {
        min-width: 800px;
    }
}

@media (max-width: 768px) {
    .crm-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }

    .crm-stats {
        gap: 16px;
    }

    .modal-content {
        width: 95%;
        margin: 10% auto;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .crm-table {
        min-width: 600px;
    }

    .filter-row {
        flex-direction: column;
        gap: 12px;
    }

    .filter-group {
        width: 100%;
    }
}