/* AI Sales Agent Dashboard Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --text-dark: #1a1a1a;
    --text-light: #666;
    --bg-light: #f8f9fa;
    --card-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --card-shadow-hover: 0 8px 12px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    min-height: 100vh;
    color: var(--text-dark);
    padding-bottom: 60px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(102, 126, 234, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    color: white;
}

.loading-overlay.hidden {
    display: none;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    margin-top: 20px;
    font-size: 18px;
}

/* Header */
.header {
    background: white;
    box-shadow: var(--card-shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.header h1 {
    font-size: 28px;
    color: var(--text-dark);
    font-weight: 700;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.status-badge {
    padding: 8px 16px;
    background: #fef3c7;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    color: #92400e;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-badge.healthy {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.error {
    background: #fee2e2;
    color: #991b1b;
}

.last-update {
    font-size: 14px;
    color: var(--text-light);
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-shadow-hover);
}

.stat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.icon {
    font-size: 32px;
    line-height: 1;
}

.stat-header h3 {
    font-size: 16px;
    color: var(--text-light);
    font-weight: 600;
    margin: 0;
}

.stat-number {
    font-size: 48px;
    font-weight: bold;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
    line-height: 1;
}

.stat-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    color: var(--text-light);
}

.label {
    font-weight: 500;
}

.value {
    font-weight: 600;
    color: var(--text-dark);
}

.progress-bar {
    height: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 4px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transition: width 0.5s ease;
}

.progress-label {
    font-size: 12px;
    color: var(--text-light);
    text-align: right;
}

/* Bounce Protection Section */
.bounce-section {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    margin-bottom: 24px;
}

.bounce-section h2 {
    margin-bottom: 20px;
    color: var(--text-dark);
    font-size: 20px;
    font-weight: 700;
}

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

.bounce-card {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    border: 1px solid #e0e0e0;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.bounce-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.bounce-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}

.bounce-icon {
    font-size: 20px;
}

.bounce-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0;
}

.bounce-number {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-color);
    margin: 8px 0;
}

.bounce-label {
    font-size: 12px;
    color: var(--text-light);
}

/* Reply Detection Section */
.reply-section {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    margin-bottom: 24px;
}

.reply-section h2 {
    margin-bottom: 20px;
    color: var(--text-dark);
    font-size: 20px;
    font-weight: 700;
}

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

.reply-card {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    border: 1px solid #e0e0e0;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.reply-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.reply-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}

.reply-icon {
    font-size: 20px;
}

.reply-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0;
}

.reply-number {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-color);
    margin: 8px 0;
}

.reply-label {
    font-size: 12px;
    color: var(--text-light);
}

/* Campaign Overview Section */
.campaign-section {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    margin-bottom: 24px;
}

.campaign-section h2 {
    margin-bottom: 20px;
    color: var(--text-dark);
    font-size: 20px;
    font-weight: 700;
}

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

.campaign-card {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    border: 1px solid #e0e0e0;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.campaign-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.campaign-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}

.campaign-icon {
    font-size: 20px;
}

.campaign-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0;
}

.campaign-number {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-color);
    margin: 8px 0;
}

.campaign-label {
    font-size: 12px;
    color: var(--text-light);
}

/* Activity Section */
.activity-section {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    margin-bottom: 24px;
}

.activity-section h2 {
    margin-bottom: 20px;
    color: var(--text-dark);
    font-size: 20px;
}

.activity-list {
    max-height: 400px;
    overflow-y: auto;
}

.activity-item {
    padding: 16px;
    border-left: 3px solid var(--primary-color);
    margin-bottom: 12px;
    background: #f9f9f9;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.6;
}

.activity-item.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-light);
    border-left-color: #ddd;
}

.activity-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #ddd;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.activity-time {
    font-weight: 600;
    color: var(--text-dark);
    display: block;
    margin-bottom: 4px;
}

.activity-content {
    color: var(--text-light);
}

/* System Info */
.system-info {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.info-item {
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-item strong {
    color: var(--text-dark);
}

.status-indicator {
    padding: 2px 8px;
    border-radius: 4px;
    background: #f3f4f6;
    font-size: 13px;
}

/* Blocked Emails Section */
.blocked-emails-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 24px;
}

.blocked-emails-section h2 {
    margin-top: 0;
    margin-bottom: 24px;
    color: var(--text-dark);
    font-size: 20px;
}

.block-form-container {
    background: #f9fafb;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 24px;
}

.block-form-container h3 {
    margin-top: 0;
    margin-bottom: 16px;
    color: var(--text-dark);
    font-size: 16px;
}

.form-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.form-group input {
    flex: 1;
    min-width: 200px;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-primary:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

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

.btn-secondary:hover {
    background: #4b5563;
}

.message {
    margin-top: 12px;
    padding: 10px;
    border-radius: 6px;
    font-size: 14px;
}

.message.success {
    background: #d1fae5;
    color: #065f46;
}

.message.error {
    background: #fee2e2;
    color: #991b1b;
}

.blocked-emails-list h3 {
    margin-bottom: 16px;
    color: var(--text-dark);
    font-size: 16px;
}

.blocked-emails-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.blocked-email-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    transition: all 0.2s;
}

.blocked-email-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.blocked-email-info {
    flex: 1;
}

.blocked-email-address {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.blocked-email-business {
    color: #6b7280;
    font-size: 14px;
    margin-bottom: 8px;
}

.blocked-email-meta {
    font-size: 13px;
    color: #9ca3af;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.no-blocked-emails {
    text-align: center;
    padding: 40px;
    color: #9ca3af;
    font-style: italic;
}

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

.error-message {
    text-align: center;
    padding: 40px;
    color: #dc2626;
}

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    color: white;
    font-size: 14px;
}

.footer .version {
    margin-top: 8px;
    opacity: 0.8;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .header h1 {
        font-size: 24px;
    }

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

    .stat-number {
        font-size: 36px;
    }

    .system-info {
        grid-template-columns: 1fr;
    }
}

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading {
    animation: pulse 1.5s infinite;
}

/* Scrollbar Styling */
.activity-list::-webkit-scrollbar {
    width: 8px;
}

.activity-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.activity-list::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.activity-list::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Performance Metrics Section */
.performance-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--card-shadow);
    margin-bottom: 24px;
}

.performance-section h2 {
    font-size: 22px;
    margin-bottom: 20px;
    color: var(--text-dark);
    font-weight: 600;
}

.performance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.perf-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 10px;
    padding: 20px;
    border: 1px solid #e0e0e0;
    transition: transform 0.2s, box-shadow 0.2s;
}

.perf-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-hover);
}

.perf-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #dee2e6;
}

.perf-icon {
    font-size: 24px;
}

.perf-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
}

.perf-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.perf-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.perf-label {
    font-size: 13px;
    color: var(--text-light);
    font-weight: 500;
}

.perf-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-color);
}

/* Trends Section */
.trends-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--card-shadow);
    margin-bottom: 24px;
}

.trends-section h2 {
    font-size: 22px;
    margin-bottom: 20px;
    color: var(--text-dark);
    font-weight: 600;
}

.trends-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 24px;
}

.trend-card {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    border: 1px solid #e0e0e0;
}

.trend-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-dark);
}

.trend-chart {
    min-height: 200px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.trend-bars {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    width: 100%;
    height: 180px;
    gap: 8px;
    padding: 10px 0;
}

.trend-bar-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 40px;
}

.trend-bar {
    width: 100%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: 4px 4px 0 0;
    min-height: 20px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 6px;
    transition: transform 0.2s;
    cursor: pointer;
    position: relative;
}

.trend-bar:hover {
    transform: scaleY(1.05);
    filter: brightness(1.1);
}

.trend-value {
    font-size: 11px;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.trend-label {
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-light);
    text-align: center;
    font-weight: 500;
}

.trend-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-light);
    font-size: 14px;
}

/* Responsive adjustments for performance section */
@media (max-width: 768px) {
    .performance-grid {
        grid-template-columns: 1fr;
    }

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

    .perf-card {
        padding: 16px;
    }

    .trend-bars {
        height: 150px;
    }
}

/* ========================================
   MANUAL IMPORT SECTION
   ======================================== */

.import-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--card-shadow);
}

.import-section h2 {
    margin-top: 0;
    margin-bottom: 20px;
    color: var(--text-dark);
    font-size: 20px;
    font-weight: 700;
}

.import-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    background: var(--bg-light);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dark);
}

.tab-btn:hover {
    background: #e9ecef;
}

.tab-btn.active {
    background: var(--primary-color);
    color: white;
}

.import-tab-content {
    display: block;
}

.import-tab-content.hidden {
    display: none;
}

.import-instructions {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 16px;
}

.import-instructions p {
    margin: 0 0 8px 0;
    color: #0369a1;
    font-size: 14px;
}

.import-instructions code {
    display: block;
    font-family: monospace;
    color: #0369a1;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.5);
    padding: 4px 8px;
    border-radius: 4px;
}

#import-websites-data,
#import-emails-data {
    width: 100%;
    font-family: monospace;
    font-size: 13px;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    resize: vertical;
    min-height: 120px;
}

#import-websites-data:focus,
#import-emails-data:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.import-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.import-actions span {
    flex: 1;
    color: var(--text-light);
    font-size: 14px;
}

.import-result {
    margin-top: 16px;
    padding: 12px;
    border-radius: 6px;
    font-size: 14px;
}

.import-result:empty {
    display: none;
}

.import-result.success {
    background: #d1fae5;
    color: #065f46;
}

.import-result.error {
    background: #fee2e2;
    color: #991b1b;
}

.import-success {
    font-weight: 600;
}

.import-error {
    font-weight: 600;
}

.import-errors {
    margin-top: 10px;
    font-size: 13px;
}

.import-errors ul {
    margin: 8px 0 0 20px;
    padding: 0;
}

.import-errors li {
    margin-bottom: 4px;
}

/* Responsive adjustments for import section */
@media (max-width: 768px) {
    .import-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .import-actions span {
        text-align: center;
        margin-bottom: 8px;
    }

    .import-tabs {
        flex-direction: column;
    }

    .tab-btn {
        width: 100%;
        text-align: center;
    }
}
