/* ========================================
   PARTNER RECRUITER - EMAIL ADMIN STYLES
   ======================================== */

/* Sub-tabs (section-level, mirrors .edit-tab pattern) */
.email-section-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-card);
    padding: 0 var(--spacing-lg);
    gap: 4px;
    overflow-x: auto;
}

.email-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    border: none;
    background: none;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    position: relative;
    white-space: nowrap;
    flex-shrink: 0;
    transition: color 0.15s;
}

.email-tab:hover {
    color: var(--text-primary);
}

.email-tab.active {
    color: var(--primary);
}

.email-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #667eea, #764ba2);
}

.email-tab .tab-icon {
    font-size: 14px;
}

.email-tab-content {
    display: none;
    padding: var(--spacing-lg);
}

.email-tab-content.active {
    display: block;
}

/* ===== TEMPLATES LIST ===== */
.email-templates-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    gap: var(--spacing-md);
}

.email-template-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: var(--spacing-md) var(--spacing-lg);
    margin-bottom: var(--spacing-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition:
        border-color 0.15s,
        box-shadow 0.15s;
}

.email-template-card:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

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

.email-template-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.email-template-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: var(--spacing-md);
    align-items: center;
}

.email-template-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ===== TEMPLATE EDITOR ===== */
.email-editor-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.email-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-lg);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05), rgba(118, 75, 162, 0.05));
    border-bottom: 1px solid var(--border-light);
}

.email-editor-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.email-editor-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    min-height: 500px;
}

.email-editor-form {
    padding: var(--spacing-lg);
    border-right: 1px solid var(--border-light);
    overflow-y: auto;
    max-height: 700px;
}

.email-editor-preview-wrapper {
    padding: var(--spacing-lg);
    background: #f1f5f9;
    overflow-y: auto;
    max-height: 700px;
}

.email-editor-preview-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: var(--spacing-sm);
}

.email-editor-preview {
    background: #fff;
    border-radius: var(--radius-md);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

/* Form sections in editor */
.editor-section {
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-lg);
    border-bottom: 1px solid var(--border-light);
}

.editor-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.editor-section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: var(--spacing-sm);
}

/* Variable insertion buttons */
.variable-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: var(--spacing-sm);
}

.variable-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    color: #2563eb;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.variable-btn:hover {
    background: #dbeafe;
    border-color: #93c5fd;
}

.variable-btn::before {
    content: '+';
    font-weight: 700;
    font-size: 12px;
}

/* Color inputs */
.color-input-group {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

.color-input-group input[type='color'] {
    width: 40px;
    height: 32px;
    padding: 2px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.color-input-group input[type='text'] {
    width: 100px;
    font-family: monospace;
    font-size: 12px;
}

/* Editor form inputs */
.email-editor-form .form-group {
    margin-bottom: var(--spacing-md);
}

.email-editor-form label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.email-editor-form input[type='text'],
.email-editor-form input[type='email'],
.email-editor-form textarea,
.email-editor-form select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.15s;
    box-sizing: border-box;
}

.email-editor-form input:focus,
.email-editor-form textarea:focus,
.email-editor-form select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.email-editor-form textarea {
    resize: vertical;
    min-height: 60px;
}

/* Editor footer buttons */
.email-editor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md) var(--spacing-lg);
    border-top: 1px solid var(--border-light);
    background: var(--bg-body);
}

.email-editor-footer .btn-group {
    display: flex;
    gap: 8px;
}

/* ===== EMAIL LOG TABLE ===== */
.email-log-toolbar {
    margin-bottom: var(--spacing-md);
}

.email-log-filters {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.email-log-filters input[type='date'],
.email-log-filters select {
    padding: 6px 10px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: inherit;
    background: var(--bg-card);
}

.date-separator {
    color: var(--text-muted);
    font-size: 12px;
}

.email-log-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
}

.email-stat-card {
    text-align: center;
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
}

.email-stat-value {
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
}

.email-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

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

.email-log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.email-log-table thead th {
    padding: 10px 12px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-light);
    white-space: nowrap;
}

.email-log-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    vertical-align: middle;
}

.email-log-table tbody tr:hover {
    background: rgba(102, 126, 234, 0.03);
}

.email-log-table .empty-row td {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

/* Status badges */
.email-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.email-status-badge.sent {
    background: #f0fdf4;
    color: #16a34a;
}

.email-status-badge.delivered {
    background: #eff6ff;
    color: #2563eb;
}

.email-status-badge.failed {
    background: #fef2f2;
    color: #dc2626;
}

.email-status-badge.opened {
    background: #fefce8;
    color: #ca8a04;
}

/* Template type badge */
.email-type-badge {
    display: inline-flex;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: #f1f5f9;
    color: var(--text-secondary);
}

/* Action buttons */
.email-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: none;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.15s;
    color: var(--text-secondary);
}

.email-action-btn:hover {
    background: var(--bg-body);
    border-color: #667eea;
    color: #667eea;
}

.email-action-btn.danger:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: #fef2f2;
}

/* ===== SETTINGS TAB ===== */
.email-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-lg);
}

.email-domain-info {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}

.info-item:last-child {
    border-bottom: none;
}

.info-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.info-value {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Email preview modal */
.email-preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: var(--spacing-lg);
}

.email-preview-modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 700px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.email-preview-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--border-light);
}

.email-preview-modal-header h4 {
    margin: 0;
    font-size: 16px;
}

.email-preview-modal-body {
    padding: var(--spacing-lg);
    overflow-y: auto;
    flex: 1;
}

.email-preview-meta {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 4px 12px;
    font-size: 12px;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-light);
}

.email-preview-meta dt {
    color: var(--text-muted);
    font-weight: 500;
}

.email-preview-meta dd {
    color: var(--text-primary);
    margin: 0;
}

/* ===== EMPTY STATES ===== */
.email-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.email-empty-state-icon {
    font-size: 48px;
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

.email-empty-state-text {
    font-size: 14px;
    margin-bottom: var(--spacing-md);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .email-editor-layout {
        grid-template-columns: 1fr;
    }

    .email-editor-form {
        border-right: none;
        border-bottom: 1px solid var(--border-light);
        max-height: none;
    }

    .email-editor-preview-wrapper {
        max-height: 400px;
    }

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

    .email-settings-grid {
        grid-template-columns: 1fr;
    }

    .email-templates-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .email-log-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .email-section-tabs {
        padding: 0 var(--spacing-md);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .email-tab {
        padding: 10px 10px;
        font-size: 12px;
        flex-shrink: 0;
    }

    .email-tab .tab-label {
        display: none;
    }

    .email-tab .tab-icon {
        font-size: 16px;
    }
}

/* ============ TRACKING BADGES ============ */
.email-tracking-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 22px;
    padding: 0 6px;
    border-radius: 11px;
    font-size: 11px;
    font-weight: 600;
}

.email-tracking-badge.opened {
    background: #dbeafe;
    color: #1d4ed8;
}

.email-tracking-badge.clicked {
    background: #fef3c7;
    color: #b45309;
}

.email-tracking-badge.none {
    color: #cbd5e1;
    font-weight: 400;
}

/* ========================================
   NINJAMAIL PHASE 2 - CAMPAIGN STYLES
   ======================================== */

/* ===== CAMPAIGN TOOLBAR ===== */
.campaign-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    gap: var(--spacing-md);
}

.campaign-status-filters {
    display: flex;
    gap: 4px;
    background: var(--bg-body);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border-light);
}

.campaign-filter-btn {
    padding: 6px 14px;
    border: none;
    background: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.campaign-filter-btn:hover {
    color: var(--text-primary);
    background: rgba(102, 126, 234, 0.05);
}

.campaign-filter-btn.active {
    background: #fff;
    color: var(--text-primary);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.btn-campaign-new {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition:
        opacity 0.15s,
        transform 0.15s;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-campaign-new:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* ===== CAMPAIGN CARDS ===== */
.campaign-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    margin-bottom: var(--spacing-md);
    overflow: hidden;
    transition:
        border-color 0.15s,
        box-shadow 0.15s;
    cursor: pointer;
}

.campaign-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.12);
}

.campaign-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
}

.campaign-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.campaign-card-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.campaign-card-body {
    padding: 16px 20px;
    display: flex;
    gap: 20px;
    align-items: center;
}

.campaign-card-stats {
    display: flex;
    gap: 16px;
    flex: 1;
}

.campaign-mini-stat {
    text-align: center;
}

.campaign-mini-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.campaign-mini-stat-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.campaign-card-actions {
    display: flex;
    gap: 6px;
}

/* ===== PROGRESS BAR ===== */
.campaign-progress {
    flex: 1;
    max-width: 300px;
}

.campaign-progress-bar {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.campaign-progress-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.campaign-progress-fill.sending::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.campaign-progress-text {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: right;
}

/* ===== STATUS BADGE ===== */
.campaign-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.campaign-status-badge.sending::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #2563eb;
    animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.5);
    }
}

/* ===== WIZARD ===== */
.wizard-container {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    overflow: hidden;
}

.wizard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.06), rgba(118, 75, 162, 0.06));
    border-bottom: 1px solid var(--border-light);
}

.wizard-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.wizard-steps-nav {
    display: flex;
    gap: 0;
    padding: 0 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
}

.wizard-step-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    position: relative;
    cursor: default;
    transition: color 0.2s;
}

.wizard-step-item.active {
    color: var(--text-primary);
    font-weight: 600;
}

.wizard-step-item.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 3px 3px 0 0;
}

.wizard-step-item.completed {
    color: #16a34a;
}

.wizard-step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--border-light);
    font-size: 11px;
    font-weight: 700;
    transition: all 0.2s;
}

.wizard-step-item.active .wizard-step-number {
    border-color: #667eea;
    background: #667eea;
    color: #fff;
}

.wizard-step-item.completed .wizard-step-number {
    border-color: #16a34a;
    background: #16a34a;
    color: #fff;
}

.wizard-step-arrow {
    color: var(--border-light);
    font-size: 16px;
    padding: 0 4px;
}

.wizard-body {
    padding: 24px;
    min-height: 400px;
}

.wizard-content-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    margin: -24px;
}

.wizard-form-side {
    padding: 24px;
    border-right: 1px solid var(--border-light);
    max-height: 600px;
    overflow-y: auto;
}

.wizard-preview-side {
    padding: 24px;
    background: #f1f5f9;
    max-height: 600px;
    overflow-y: auto;
}

.wizard-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-body);
}

.wizard-footer .btn-group {
    display: flex;
    gap: 8px;
}

/* Campaign HTML editor */
.campaign-html-editor {
    width: 100%;
    min-height: 300px;
    padding: 12px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 12px;
    line-height: 1.6;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    resize: vertical;
    background: #1e293b;
    color: #e2e8f0;
    tab-size: 2;
    box-sizing: border-box;
}

.campaign-html-editor:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

/* ===== SEGMENT BUILDER ===== */
.segment-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: var(--spacing-md);
}

.segment-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid var(--border-light);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-card);
    cursor: pointer;
    transition: all 0.15s;
}

.segment-chip:hover {
    border-color: #667eea;
    color: #667eea;
}

.segment-chip.active {
    border-color: #667eea;
    background: #eff6ff;
    color: #2563eb;
    font-weight: 600;
}

.segment-count {
    background: rgba(0, 0, 0, 0.06);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
}

.filter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.filter-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.filter-group input,
.filter-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    box-sizing: border-box;
}

.filter-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.filter-checkboxes label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.1s;
}

.filter-checkboxes label:has(input:checked) {
    border-color: #667eea;
    background: #eff6ff;
    color: #2563eb;
}

.filter-checkboxes input[type='checkbox'] {
    width: auto;
    margin: 0;
}

/* Recipient preview card */
.recipient-preview-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.06), rgba(118, 75, 162, 0.06));
    border-radius: 12px;
    border: 1px solid rgba(102, 126, 234, 0.15);
    margin-top: var(--spacing-lg);
}

.recipient-count-number {
    font-size: 32px;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.recipient-count-label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ===== CAMPAIGN DETAIL ===== */
.campaign-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--spacing-lg);
}

.campaign-detail-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.campaign-detail-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.campaign-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-md);
    margin-bottom: 24px;
}

.campaign-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.campaign-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--stat-color, #667eea), var(--stat-color-end, #764ba2));
}

.campaign-stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.campaign-stat-rate {
    font-size: 14px;
    font-weight: 600;
    margin-left: 4px;
}

.campaign-stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.campaign-progress-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: var(--spacing-lg);
}

.campaign-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.campaign-progress-big {
    height: 12px;
    background: #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
}

.campaign-progress-big .campaign-progress-fill {
    height: 100%;
    border-radius: 6px;
}

.campaign-progress-details {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== CAMPAIGN RESPONSIVE ===== */
@media (max-width: 768px) {
    .campaign-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .campaign-status-filters {
        overflow-x: auto;
    }

    .wizard-content-layout {
        grid-template-columns: 1fr;
    }

    .wizard-form-side {
        border-right: none;
        border-bottom: 1px solid var(--border-light);
    }

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

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

    .wizard-steps-nav {
        overflow-x: auto;
        padding: 0 12px;
    }

    .campaign-card-body {
        flex-direction: column;
        align-items: stretch;
    }

    .campaign-progress {
        max-width: none;
    }

    .campaign-detail-header {
        flex-direction: column;
        gap: 12px;
    }

    .recipient-preview-card {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }
}

/* ========================================
   EMAIL SEQUENCES — Builder & Timeline
   ======================================== */

/* Sequence Card (list view) */
.sequence-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 12px;
    cursor: pointer;
    transition:
        box-shadow 0.15s,
        border-color 0.15s;
}

.sequence-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #667eea;
}

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

.sequence-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.sequence-card-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.sequence-card-stats {
    display: flex;
    gap: 20px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}

.sequence-trigger-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    background: #f0f4ff;
    color: #4f46e5;
    white-space: nowrap;
}

/* Pulse dot for active sequences */
.seq-pulse-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #16a34a;
    margin-right: 4px;
    animation: seqPulse 2s ease-in-out infinite;
}

@keyframes seqPulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

/* Builder Layout */
.seq-builder-layout {
    display: flex;
    gap: 0;
    min-height: calc(100vh - 200px);
}

.seq-builder-sidebar {
    width: 320px;
    min-width: 320px;
    background: var(--bg-card);
    border-right: 1px solid var(--border-light);
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.seq-builder-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.seq-builder-sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.seq-builder-timeline {
    flex: 1;
    padding: 30px 40px;
    background: var(--bg-body);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Timeline Nodes */
.seq-timeline-node {
    display: flex;
    gap: 12px;
    width: 100%;
    max-width: 560px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    transition: box-shadow 0.15s;
}

.seq-timeline-node:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.seq-trigger-node {
    border-top: 3px solid #16a34a;
    background: linear-gradient(to bottom, #f0fdf4, var(--bg-card));
}

.seq-end-node {
    border-top: 3px solid #667eea;
    background: linear-gradient(to bottom, #f0f4ff, var(--bg-card));
}

.seq-step-node.editing {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

.seq-node-icon {
    font-size: 20px;
    flex-shrink: 0;
    width: 32px;
    text-align: center;
    line-height: 28px;
}

.seq-node-content {
    flex: 1;
    min-width: 0;
}

.seq-node-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.seq-node-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.seq-node-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Step actions and stats */
.seq-step-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.seq-step-stat {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
}

/* Condition badges */
.seq-condition-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.seq-condition-badge.always {
    background: #f0fdf4;
    color: #16a34a;
}

.seq-condition-badge.if_not_opened,
.seq-condition-badge.if_not_clicked {
    background: #fefce8;
    color: #d97706;
}

.seq-condition-badge.if_opened,
.seq-condition-badge.if_clicked {
    background: #eff6ff;
    color: #2563eb;
}

/* Timeline connector */
.seq-timeline-connector {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 560px;
    position: relative;
    min-height: 40px;
}

.seq-connector-line {
    width: 2px;
    flex: 1;
    min-height: 20px;
    background: linear-gradient(to bottom, var(--border-light), #667eea40, var(--border-light));
}

.seq-delay-badge {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    padding: 2px 12px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Step Editor (inline) */
.seq-step-editor {
    border-top: 1px solid var(--border-light);
    margin-top: 12px;
    padding-top: 4px;
}

.seq-step-editor .form-group {
    margin-bottom: 10px;
}

.seq-step-editor label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.seq-step-editor input[type='text'],
.seq-step-editor input[type='number'],
.seq-step-editor select,
.seq-step-editor textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    background: var(--bg-card);
    color: var(--text-primary);
    box-sizing: border-box;
}

.seq-step-editor textarea.campaign-html-editor {
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 12px;
    line-height: 1.5;
    background: #1e293b;
    color: #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    tab-size: 2;
}

/* Responsive */
@media (max-width: 900px) {
    .seq-builder-layout {
        flex-direction: column;
    }

    .seq-builder-sidebar {
        width: 100%;
        min-width: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-light);
    }

    .seq-builder-timeline {
        padding: 20px;
    }

    .sequence-card-header {
        flex-direction: column;
    }

    .sequence-card-stats {
        flex-wrap: wrap;
    }
}

/* ============================================
   ANALYTICS DASHBOARD (NinjaMail Phase 4)
   ============================================ */

/* Period Selector */
.analytics-period-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.analytics-period-btn {
    padding: 6px 16px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: #fff;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.analytics-period-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.analytics-period-btn.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border-color: transparent;
}

/* KPI Cards Row */
.analytics-kpi-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.analytics-kpi-card {
    flex: 1;
    min-width: 100px;
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
}

.analytics-kpi-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
}

.analytics-kpi-sub {
    font-size: 13px;
    font-weight: 600;
    margin-top: 2px;
}

.analytics-kpi-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 6px;
}

/* Section */
.analytics-section {
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.analytics-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.analytics-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-size: 13px;
}

/* Daily Bar Chart */
.analytics-daily-chart {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 160px;
    padding-bottom: 24px;
    overflow-x: auto;
}

.analytics-bar-group {
    flex: 1;
    min-width: 8px;
    max-width: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    cursor: default;
}

.analytics-bar-stack {
    width: 100%;
    height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    position: relative;
}

.analytics-bar {
    width: 100%;
    border-radius: 2px 2px 0 0;
    transition: opacity 0.2s;
    position: absolute;
    bottom: 0;
}

.analytics-bar.sent {
    background: #667eea;
    opacity: 0.4;
}

.analytics-bar.opened {
    background: #22c55e;
}

.analytics-bar-label {
    font-size: 9px;
    color: var(--text-muted);
    white-space: nowrap;
    transform: rotate(-45deg);
    transform-origin: center;
    margin-top: 4px;
}

.analytics-chart-legend {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 8px;
}

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

.analytics-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
}

/* Bottom Grid: Heatmap + Campaign Table */
.analytics-bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

/* Hourly Heatmap */
.analytics-heatmap {
    display: grid;
    grid-template-columns: 30px repeat(24, 1fr);
    gap: 2px;
}

.analytics-heatmap-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.analytics-heatmap-hour {
    font-size: 9px;
    color: var(--text-muted);
    text-align: center;
}

.analytics-heatmap-cell {
    aspect-ratio: 1;
    border-radius: 2px;
    min-width: 0;
}

/* Campaign Table */
.analytics-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.analytics-table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
    font-weight: 500;
}

.analytics-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
}

.analytics-table tbody tr:hover {
    background: #f8fafc;
}

/* Sequence Funnels */
.analytics-funnels {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.analytics-funnel-card {
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 16px;
}

.analytics-funnel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.analytics-funnel-step {
    margin-bottom: 8px;
}

.analytics-funnel-step-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 4px;
}

.analytics-funnel-bar-bg {
    height: 8px;
    background: #f1f5f9;
    border-radius: 4px;
    overflow: hidden;
}

.analytics-funnel-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 4px;
    transition: width 0.3s;
}

/* CRM Email Profile Card */
.crm-email-card {
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 16px;
    margin-top: 12px;
}

.crm-email-card h4 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin: 0 0 12px 0;
}

.crm-email-engagement {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.crm-email-engagement-item {
    font-size: 12px;
    color: var(--text-secondary);
}

.crm-email-engagement-item strong {
    color: var(--text-primary);
}

.crm-email-enrollment {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 12px;
}

.crm-email-history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 12px;
}

.crm-email-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
}

/* Responsive */
@media (max-width: 768px) {
    .analytics-bottom-grid {
        grid-template-columns: 1fr;
    }

    .analytics-kpi-row {
        flex-wrap: wrap;
    }

    .analytics-kpi-card {
        min-width: 80px;
    }

    .analytics-daily-chart {
        height: 120px;
    }
}
