:root {
    --bg-color: #0f172a;
    --surface-color: #1e293b;
    --border-color: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --primary-color: #3b82f6;
    /* Blue for trust/tech */
    --accent-color: #8b5cf6;
    /* Violet for premium fee l*/
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.15);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    border-radius: var(--radius);
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.logo-icon {
    font-size: 24px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    background: linear-gradient(to right, #fff, #cbd5e1);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.75rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-sm:hover {
    color: var(--text-primary);
    border-color: var(--primary-color);
}


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

.stat-card {
    background: var(--surface-color);
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.2s;
    box-shadow: var(--shadow);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary-color);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: rgba(59, 130, 246, 0.1);
}

.stat-total .stat-icon {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
}

.stat-email .stat-icon {
    background: rgba(16, 185, 129, 0.1);
    color: #34d399;
}

.stat-sent .stat-icon {
    background: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
}

.stat-pending .stat-icon {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Actions Section */
.actions-section {
    margin-bottom: 40px;
}

.actions-section h2 {
    font-size: 1.25rem;
    margin-bottom: 16px;
    color: var(--text-primary);
}

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

.action-btn {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
    box-shadow: var(--shadow);
}

.action-btn:hover {
    border-color: var(--primary-color);
    background: #253347;
    /* Slightly lighter surface */
    transform: translateY(-2px);
}

.action-icon {
    font-size: 32px;
    margin-bottom: 4px;
}

.action-text {
    font-weight: 600;
}

.action-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.action-btn.loading {
    opacity: 0.7;
    pointer-events: none;
    background: repeating-linear-gradient(45deg, var(--surface-color), var(--surface-color) 10px, #253347 10px, #253347 20px);
}

/* Email Outreach Panel */
.email-outreach-section {
    margin-bottom: 40px;
}

.email-outreach-panel {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
}

.panel-header h2 {
    font-size: 1.25rem;
    color: var(--text-primary);
}

.email-outreach-stats {
    display: flex;
    gap: 10px;
}

.stat-badge {
    background: var(--bg-color);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.stat-badge.sent {
    color: var(--success-color);
    border-color: rgba(16, 185, 129, 0.2);
    background: rgba(16, 185, 129, 0.05);
}

.stat-badge.today {
    color: var(--warning-color);
    border-color: rgba(245, 158, 11, 0.2);
    background: rgba(245, 158, 11, 0.05);
}

.stat-badge.replied {
    color: var(--primary-color);
    border-color: rgba(59, 130, 246, 0.2);
    background: rgba(59, 130, 246, 0.05);
}

.campaign-info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-color);
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 24px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.campaign-info-bar strong {
    color: var(--text-primary);
}

/* Templates Section */
.templates-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 16px;
}

.templates-info code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--accent-color);
}

.template-card {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    position: relative;
    transition: all 0.2s;
}

.template-card.editing {
    border-color: var(--warning-color);
}

.template-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.template-name {
    font-weight: 600;
    color: var(--text-primary);
}

.template-id {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: monospace;
}

.template-subject-label,
.template-body-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.template-subject {
    width: 100%;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px;
    border-radius: 4px;
    margin-bottom: 12px;
    font-family: inherit;
}

.template-body {
    width: 100%;
    min-height: 120px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px;
    border-radius: 4px;
    font-family: inherit;
    resize: vertical;
    line-height: 1.6;
}

.template-subject:focus,
.template-body:focus {
    outline: none;
    border-color: var(--primary-color);
}

.template-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    height: 0;
    overflow: hidden;
}

.template-card.editing .template-actions {
    opacity: 1;
    pointer-events: auto;
    height: auto;
}

.template-save-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    transition: .4s;
    border-radius: 20px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.toggle-slider {
    background-color: var(--success-color);
}

input:checked+.toggle-slider:before {
    transform: translateX(20px);
}

/* Data Tables */
.table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.leads-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    text-align: left;
}

.leads-table th {
    background: var(--bg-color);
    padding: 12px 16px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.leads-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.leads-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.status-sent {
    color: var(--success-color);
    font-weight: 500;
}

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

.loading {
    padding: 24px;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

/* Replies */
.email-replies-section {
    margin-top: 32px;
}

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

.reply-card {
    background: var(--bg-color);
    border-left: 3px solid var(--accent-color);
    padding: 16px;
    border-radius: 0 8px 8px 0;
    margin-bottom: 12px;
}

.reply-card-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.875rem;
}

.reply-sender {
    font-weight: 600;
    color: var(--text-primary);
}

.reply-email {
    color: var(--text-secondary);
    margin-left: 8px;
}

.reply-time {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.reply-text {
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: pre-wrap;
}

.reply-empty {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary);
    background: var(--bg-color);
    border-radius: 8px;
    border: 1px dashed var(--border-color);
}

/* Title Cells - Truncate */
.title-cell {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-secondary) !important;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 24px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    transform: translateY(0);
    transition: all 0.3s;
}

.toast.hidden {
    transform: translateY(100px);
    opacity: 0;
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--danger-color);
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

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

::-webkit-scrollbar-thumb:hover {
    background: #475569;
}
/* Mobile Optimization */
@media (max-width: 768px) {
    .app {
        padding: 12px;
    }

    .header {
        padding: 16px;
        margin-bottom: 16px;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .campaign-info-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .campaign-info-bar span {
        margin-bottom: 4px;
        display: block;
    }

    .templates-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .preview-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .preview-stats {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        padding: 16px;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }

    /* Better table scrolling on mobile */
    .leads-table th, 
    .leads-table td {
        white-space: nowrap;
        padding: 10px;
    }
    
    .reply-card-header {
        flex-direction: column;
        gap: 4px;
    }
    
    .reply-email {
        margin-left: 0;
        display: block;
        font-size: 0.75rem;
    }
}
