/* LeadsMagic Dashboard Styles */
.leadmagic-dashboard {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    max-width: 100%;
    margin: 20px 0;
}

.leadmagic-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.leadmagic-header h2 {
    margin: 0;
    color: #333;
    font-size: 24px;
    font-weight: 600;
}

.leadmagic-actions {
    display: flex;
    gap: 10px;
}

.leadmagic-export-btn {
    background: #007cba;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.leadmagic-export-btn:hover {
    background: #005a87;
}

.leadmagic-export-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.leadmagic-table-wrapper {
    background: white;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    max-width: 100%;
    width: 100%;
    position: relative;
    /* Force scrollbar to always be visible when needed */
    scrollbar-width: auto !important;
    scrollbar-color: #888 #f1f1f1 !important;
    /* Additional properties to ensure scrolling works */
    display: block;
    white-space: nowrap;
}

/* Custom scrollbar styling - Enhanced for better visibility */
.leadmagic-table-wrapper::-webkit-scrollbar {
    height: 12px; /* Increased height for better visibility */
    width: 12px;
}

.leadmagic-table-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.leadmagic-table-wrapper::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 6px;
    border: 1px solid #666;
}

.leadmagic-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.leadmagic-table-wrapper::-webkit-scrollbar-corner {
    background: #f1f1f1;
}

/* Enhanced scrolling support with forced visibility */
.leadmagic-table-wrapper {
    /* Force horizontal scrolling when content exceeds container width */
    overflow-x: scroll !important; /* Changed from auto to scroll to force scrollbar */
    overflow-y: hidden !important;
    scrollbar-width: thin !important;
    scrollbar-color: #888 #f1f1f1 !important;
    -webkit-overflow-scrolling: touch; /* For smooth scrolling on mobile */
}

/* Force minimum table width to ensure horizontal scrolling when needed */
.leadmagic-table {
    min-width: 1800px !important; /* Increased minimum width to force scrolling */
    width: max-content !important; /* Let table grow to content width */
    table-layout: auto !important; /* Allow columns to auto-size */
    border-collapse: collapse !important;
}

/* Additional styling to ensure horizontal scroll visibility */
.leadmagic-table-wrapper::after {
    content: '';
    display: block;
    height: 1px;
    width: 100%;
    clear: both;
}

/* Auto-sizing columns - each column width fits its content */
.leadmagic-table th,
.leadmagic-table td {
    width: auto; /* Let content determine width */
    min-width: 120px; /* Increased minimum width for better spacing */
    max-width: none; /* No maximum width - let content expand */
}

/* Specific adjustments for very long content types */
.leadmagic-table th:nth-child(4), /* Work Email */
.leadmagic-table td:nth-child(4),
.leadmagic-table th:nth-child(5), /* Email */
.leadmagic-table td:nth-child(5),
.leadmagic-table th:nth-child(8), /* LinkedIn URL */
.leadmagic-table td:nth-child(8),
.leadmagic-table th:nth-child(15), /* Company URL */
.leadmagic-table td:nth-child(15) {
    max-width: 300px; /* Reasonable limit for very long URLs/emails */
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Company Address can be quite long, so limit it */
.leadmagic-table th:nth-child(10), /* Company Address */
.leadmagic-table td:nth-child(10) {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leadmagic-table {
    width: max-content !important; /* Let table grow to content width */
    min-width: 1800px !important; /* Force minimum width for horizontal scrolling */
    border-collapse: collapse !important;
    font-size: 14px;
    line-height: 1.5;
    table-layout: auto !important; /* Allow columns to auto-size */
    /* Ensure table forces horizontal scroll */
    white-space: nowrap;
}

.leadmagic-table th {
    background: #f8f9fa;
    padding: 12px 15px; /* Increased padding for better spacing */
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
    /* Removed fixed width constraints - let content determine width */
}

.leadmagic-table td {
    padding: 12px 15px; /* Increased padding to match headers */
    border-bottom: 1px solid #e9ecef;
    color: #333;
    white-space: nowrap;
    /* Removed width constraints and overflow settings to show full content */
}

.leadmagic-table tbody tr:hover {
    background-color: #f8f9fa;
}

.leadmagic-table tbody tr:nth-child(even) {
    background-color: #fdfdfd;
}

.leadmagic-table tbody tr:nth-child(even):hover {
    background-color: #f8f9fa;
}

.leadmagic-table a {
    color: #007cba;
    text-decoration: none;
}

.leadmagic-table a:hover {
    text-decoration: underline;
}

.leadmagic-no-data {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 40px !important;
}

.leadmagic-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding: 15px 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.leadmagic-stats {
    color: #6c757d;
    font-size: 14px;
}

.leadmagic-error {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #f5c6cb;
    margin: 20px 0;
}

.leadmagic-loading {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

.leadmagic-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007cba;
    border-radius: 50%;
    animation: leadmagic-spin 1s linear infinite;
}

@keyframes leadmagic-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .leadmagic-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .leadmagic-table {
        min-width: 1200px;
    }
    
    .leadmagic-table th,
    .leadmagic-table td {
        min-width: 120px; /* Increased for mobile readability */
        max-width: 180px;
        padding: 8px 6px;
    }
    
    .leadmagic-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

/* WordPress Admin Styles */
.leadmagic-admin-field {
    margin-bottom: 15px;
}

.leadmagic-admin-field label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

.leadmagic-admin-field input {
    width: 100%;
    max-width: 400px;
}

/* Pagination controls */
.leadmagic-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.leadmagic-pagination-controls select {
    padding: 12px 32px 12px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    font-size: 14px;
    height: 44px;
    line-height: 18px;
    vertical-align: middle;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 5"><path fill="%23007cba" d="M2 0L0 2h4zm0 5L0 3h4z"/></svg>');
    background-repeat: no-repeat;
    background-position: calc(100% - 12px) center;
    background-size: 10px;
    box-sizing: border-box;
    display: inline-block;
}

.leadmagic-stats {
    color: #666;
    font-size: 14px;
}

.leadmagic-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

.leadmagic-pagination-info {
    color: #666;
    font-size: 14px;
}

.leadmagic-pagination-buttons {
    display: flex;
    gap: 5px;
    align-items: center;
}

.leadmagic-btn-prev,
.leadmagic-btn-next,
.leadmagic-btn-page {
    padding: 8px 12px;
    border: 1px solid #ddd;
    background-color: white;
    cursor: pointer;
    text-decoration: none;
    color: #333;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.2s;
}

.leadmagic-btn-prev:hover,
.leadmagic-btn-next:hover,
.leadmagic-btn-page:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
}

.leadmagic-btn-page.active {
    background-color: #007cba;
    color: white;
    border-color: #007cba;
}

.leadmagic-btn-prev:disabled,
.leadmagic-btn-next:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Responsive pagination */
@media (max-width: 768px) {
    .leadmagic-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .leadmagic-pagination {
        flex-direction: column;
        gap: 10px;
    }
    
    .leadmagic-pagination-buttons {
        flex-wrap: wrap;
        justify-content: center;
    }
}