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

:root {
    --bg-primary: #08090d;
    --bg-secondary: #0d0f16;
    --bg-card: #12151e;
    --bg-hover: #181c28;
    --accent: #00e5a0;
    --accent-dim: rgba(0, 229, 160, 0.12);
    --accent-glow: rgba(0, 229, 160, 0.25);
    --text-primary: #f0f2f5;
    --text-secondary: #8a8f9e;
    --text-muted: #5a5f6e;
    --border: rgba(255, 255, 255, 0.08);
    --danger: #ff6b6b;
    --warning: #fbbf24;
    --success: #00e5a0;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

h1, h2, h3, h4 {
    font-family: 'Space Grotesk', sans-serif;
}

/* ========== NAV ========== */
.top-nav {
    padding: 16px 32px;
    display: flex;
    align-items: center;
    gap: 40px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.5px;
}
.logo span { color: var(--accent); }

.nav-links {
    display: flex;
    gap: 24px;
}
.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 6px 0;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}
.nav-links a:hover,
.nav-links a.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
}

/* ========== LAYOUT ========== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 32px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -1px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 4px;
}

.back-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    display: inline-block;
    margin-bottom: 8px;
    transition: color 0.2s;
}
.back-link:hover { color: var(--accent); }

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

/* ========== BUTTONS ========== */
.btn {
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: var(--accent);
    color: #08090d;
}
.btn-primary:hover {
    background: #00cc8e;
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid rgba(255, 107, 107, 0.2);
    padding: 6px 12px;
    font-size: 0.8rem;
}
.btn-danger:hover {
    background: rgba(255, 107, 107, 0.1);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 8px;
}

/* ========== CAMPAIGNS GRID ========== */
.campaigns-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.campaign-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: inherit;
    display: block;
}
.campaign-card:hover {
    border-color: rgba(0, 229, 160, 0.2);
    transform: translateY(-2px);
}

.campaign-card h3 {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.3px;
    margin-bottom: 8px;
}

.campaign-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.campaign-meta span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.campaign-stats {
    display: flex;
    gap: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.campaign-stats .cs {
    display: flex;
    flex-direction: column;
}
.campaign-stats .cs-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent);
}
.campaign-stats .cs-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.status-draft { background: rgba(138, 143, 158, 0.15); color: var(--text-secondary); }
.status-active { background: var(--accent-dim); color: var(--accent); }
.status-paused { background: rgba(251, 191, 36, 0.15); color: var(--warning); }
.status-completed { background: rgba(0, 229, 160, 0.15); color: var(--success); }
.status-new { background: rgba(138, 143, 158, 0.15); color: var(--text-secondary); }
.status-contacted { background: rgba(96, 165, 250, 0.15); color: #60a5fa; }
.status-replied { background: var(--accent-dim); color: var(--accent); }
.status-bounced { background: rgba(255, 107, 107, 0.15); color: var(--danger); }

/* ========== STATS ROW ========== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px 24px;
    text-align: center;
}
.stat-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -1px;
}
.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========== TABLE ========== */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th {
    text-align: left;
    padding: 14px 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}
.data-table td {
    padding: 14px 20px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }
.data-table td:first-child { color: var(--text-primary); font-weight: 500; }

/* ========== MODAL ========== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 32px;
    width: 90%;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.modal-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    border-radius: 8px;
    transition: all 0.2s;
}
.btn-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ========== FORMS ========== */
.form-group {
    margin-bottom: 18px;
    flex: 1;
}
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}
.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
}
.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

.help-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    line-height: 1.5;
}

.csv-result {
    padding: 14px;
    border-radius: 10px;
    font-size: 0.85rem;
    margin-bottom: 16px;
    line-height: 1.6;
}
.csv-result.success {
    background: rgba(0, 229, 160, 0.1);
    border: 1px solid rgba(0, 229, 160, 0.2);
    color: var(--accent);
}
.csv-result.error {
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.2);
    color: var(--danger);
}

/* ========== LOADING / EMPTY ========== */
.loading {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.empty-state {
    text-align: center;
    padding: 64px 20px;
    color: var(--text-muted);
}
.empty-state h3 {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.empty-state p {
    font-size: 0.9rem;
    margin-bottom: 20px;
}

/* ========== TOAST ========== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 300;
    animation: slideUp 0.3s ease-out;
}
.toast.success {
    background: rgba(0, 229, 160, 0.15);
    border: 1px solid rgba(0, 229, 160, 0.3);
    color: var(--accent);
}
.toast.error {
    background: rgba(255, 107, 107, 0.15);
    border: 1px solid rgba(255, 107, 107, 0.3);
    color: var(--danger);
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ========== PHASE 2A: EMAIL STYLES ========== */

/* AI Generate button */
.btn-ai {
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    color: #fff;
    border: none;
}
.btn-ai:hover {
    background: linear-gradient(135deg, #6d28d9, #4338ca);
    transform: translateY(-1px);
}
.btn-icon { font-size: 1rem; }

/* Send button */
.btn-send {
    background: rgba(96, 165, 250, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(96, 165, 250, 0.25);
}
.btn-send:hover {
    background: rgba(96, 165, 250, 0.25);
    border-color: rgba(96, 165, 250, 0.4);
}

/* Tab navigation */
.tab-nav {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 10px 20px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}
.tab-btn:hover { color: var(--text-secondary); }
.tab-btn.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
}

.tab-badge {
    background: var(--accent-dim);
    color: var(--accent);
    border-radius: 20px;
    padding: 2px 8px;
    font-size: 0.7rem;
    font-weight: 700;
    align-items: center;
    justify-content: center;
}

/* Table actions bar */
.table-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0 16px;
    gap: 12px;
}

.filter-select {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    padding: 7px 12px;
    cursor: pointer;
}
.filter-select:focus { outline: none; border-color: var(--accent); }

.rate-info {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Email table styles */
.prospect-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.prospect-cell strong { color: var(--text-primary); font-weight: 500; }
.meta { font-size: 0.8rem; color: var(--text-muted); }

.subject-cell { max-width: 300px; }
.subject-text {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.actions-cell {
    display: flex;
    gap: 6px;
    white-space: nowrap;
}

.row-sent td { opacity: 0.7; }
.row-sent:hover td { opacity: 1; }

/* Sent status badge */
.status-sent { background: rgba(96, 165, 250, 0.15); color: #60a5fa; }

/* Empty hint */
.empty-hint {
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: 16px;
    padding: 32px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Wide modal for email editing */
.modal-wide {
    max-width: 680px;
}
.modal-sm {
    max-width: 360px;
    padding: 40px 32px;
}

.modal-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast info */
.toast.info {
    background: rgba(251, 191, 36, 0.12);
    border: 1px solid rgba(251, 191, 36, 0.25);
    color: var(--warning);
}

/* 5-column stats row */
.stats-row { grid-template-columns: repeat(5, 1fr); }

/* ========== ANALYTICS TAB ========== */

.analytics-funnel {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.funnel-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px 24px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.funnel-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: 14px 14px 0 0;
}

.funnel-card.sent::before   { background: rgba(96, 165, 250, 0.6); }
.funnel-card.opened::before  { background: rgba(0, 229, 160, 0.6); }
.funnel-card.replied::before { background: rgba(167, 139, 250, 0.6); }
.funnel-card.bounced::before { background: rgba(255, 107, 107, 0.6); }

.funnel-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2.4rem;
    font-weight: 700;
    letter-spacing: -1.5px;
    line-height: 1;
}

.funnel-card.sent .funnel-value   { color: #60a5fa; }
.funnel-card.opened .funnel-value  { color: var(--accent); }
.funnel-card.replied .funnel-value { color: #a78bfa; }
.funnel-card.bounced .funnel-value { color: var(--danger); }

.funnel-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-top: 6px;
}

.funnel-rate {
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 8px;
    padding: 3px 10px;
    border-radius: 20px;
    display: inline-block;
}
.funnel-card.opened  .funnel-rate { background: var(--accent-dim); color: var(--accent); }
.funnel-card.replied .funnel-rate { background: rgba(167, 139, 250, 0.12); color: #a78bfa; }
.funnel-card.bounced .funnel-rate { background: rgba(255, 107, 107, 0.1); color: var(--danger); }
.funnel-card.sent    .funnel-rate { background: rgba(96, 165, 250, 0.12); color: #60a5fa; }

.analytics-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
}

.analytics-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 20px;
    letter-spacing: -0.2px;
}

/* Bar chart */
.bar-chart-wrap {
    overflow-x: auto;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 160px;
    min-width: 500px;
    padding-bottom: 24px;
    position: relative;
}

.bar-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
    min-width: 32px;
}

.bar-group-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    width: 100%;
    height: 130px;
}

.bar {
    flex: 1;
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    transition: opacity 0.2s;
}
.bar:hover { opacity: 0.8; }

.bar.sent-bar   { background: rgba(96, 165, 250, 0.6); }
.bar.open-bar   { background: rgba(0, 229, 160, 0.7); }
.bar.reply-bar  { background: rgba(167, 139, 250, 0.7); }
.bar.bounce-bar { background: rgba(255, 107, 107, 0.6); }

.bar-date {
    font-size: 0.65rem;
    color: var(--text-muted);
    white-space: nowrap;
    transform: rotate(-30deg);
    transform-origin: top left;
    margin-top: 4px;
}

/* Chart legend */
.chart-legend {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .container { padding: 20px 16px; }
    .campaigns-grid { grid-template-columns: 1fr; }
    .stats-row { grid-template-columns: repeat(3, 1fr); }
    .form-row { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; }
    .header-actions { width: 100%; }
    .header-actions .btn { flex: 1; justify-content: center; }
    .data-table { font-size: 0.8rem; }
    .data-table th, .data-table td { padding: 10px 12px; }
}
