/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --success: #10b981;
    --success-bg: #ecfdf5;
    --error: #ef4444;
    --error-bg: #fef2f2;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    padding: 2rem 1rem;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.auto-refresh-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: white;
    font-size: 0.875rem;
    cursor: pointer;
}

.auto-refresh-label input {
    cursor: pointer;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-secondary {
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
}

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

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Campaign Cards (list view) */
.campaign-card {
    background: var(--card-bg);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
}

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

.campaign-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.campaign-id {
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--text-light);
}

.campaign-card-body {
    padding: 1rem 1.5rem;
}

.campaign-card-body div {
    margin-bottom: 0.25rem;
}

.campaign-time {
    font-size: 0.8rem;
    color: var(--text-light);
}

.campaign-progress {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.progress-bar-mini {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-mini-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

.progress-bar-mini-fill.status-completed {
    background: var(--success);
}

.progress-bar-mini-fill.status-processing {
    background: var(--primary);
}

.progress-bar-mini-fill.status-failed {
    background: var(--error);
}

.progress-text {
    font-size: 0.8rem;
    color: var(--text-light);
    white-space: nowrap;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.status-completed,
.status-success {
    background: var(--success-bg);
    color: #065f46;
}

.status-processing {
    background: #eff6ff;
    color: #1e40af;
}

.status-failed {
    background: var(--error-bg);
    color: #991b1b;
}

.status-pending {
    background: var(--bg);
    color: var(--text-light);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin: 1.5rem 0;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 0.75rem;
    padding: 1.25rem;
    text-align: center;
    box-shadow: var(--shadow);
    border-top: 3px solid var(--border);
}

.stat-card.stat-success {
    border-top-color: var(--success);
}

.stat-card.stat-failed {
    border-top-color: var(--error);
}

.stat-card.stat-pending {
    border-top-color: var(--warning);
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.2;
}

.stat-success .stat-value {
    color: var(--success);
}

.stat-failed .stat-value {
    color: var(--error);
}

.stat-pending .stat-value {
    color: var(--warning);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-light);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

/* Campaign Info */
.campaign-info {
    background: var(--card-bg);
    border-radius: 0.75rem;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.campaign-info p {
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.filter-bar input[type="text"] {
    flex: 1;
    padding: 0.6rem 1rem;
    border: 2px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.9rem;
}

.filter-bar input:focus {
    outline: none;
    border-color: var(--primary);
}

.filter-bar select {
    padding: 0.6rem 1rem;
    border: 2px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
}

/* Lead Table */
.table-wrapper {
    background: var(--card-bg);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.lead-table {
    width: 100%;
    border-collapse: collapse;
}

.lead-table thead {
    background: var(--bg);
}

.lead-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
    border-bottom: 2px solid var(--border);
}

.lead-table td {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
}

.lead-table tbody tr:last-child td {
    border-bottom: none;
}

.lead-table tbody tr:hover {
    background: var(--bg);
}

.lead-row.lead-failed {
    background: #fff5f5;
}

.error-text {
    color: var(--error);
    font-size: 0.8rem;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Loading & Empty State */
.loading,
.empty-state {
    text-align: center;
    padding: 3rem;
    color: white;
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Footer */
footer {
    text-align: center;
    color: white;
    opacity: 0.9;
    margin-top: 3rem;
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .filter-bar {
        flex-direction: column;
    }

    .table-wrapper {
        overflow-x: auto;
    }

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

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .toolbar {
        flex-direction: column;
        align-items: flex-start;
    }
}
