/* ═══════════════════════════════════════════════════════════
   Components — Modal, Notification, Progress
   ═══════════════════════════════════════════════════════════ */

/* ─── Modal ──────────────────────────────────────────────── */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.25s var(--ease);
    padding: var(--space-md);
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideUp 0.3s var(--ease);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-surface);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    z-index: 1;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.modal-header h3 svg {
    width: 20px;
    height: 20px;
    color: var(--primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1.2rem;
    transition: all var(--duration) var(--ease);
}
.modal-close:hover {
    background: var(--danger-muted);
    color: var(--danger);
}

.modal-body {
    padding: var(--space-lg);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border);
    background: var(--bg-elevated);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}


/* ─── Notifications ──────────────────────────────────────── */
.notification {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    box-shadow: var(--shadow-lg);
    animation: notificationSlideIn 0.3s var(--ease);
    min-width: 280px;
    position: relative;
    overflow: hidden;
}

.notification::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
}

.notification.success::before { background: var(--success); }
.notification.error::before { background: var(--danger); }
.notification.warning::before { background: var(--warning); }
.notification.info::before { background: var(--primary); }

.notification-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-xs);
}

.notification-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.notification-close {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: all var(--duration) var(--ease);
}
.notification-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.notification-message {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

@keyframes notificationSlideIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes notificationSlideOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}


/* ─── Progress Modal ─────────────────────────────────────── */
.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--bg-base);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin: var(--space-md) 0;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: var(--radius-full);
    transition: width 0.5s var(--ease);
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255,255,255,0.2) 50%,
        transparent 100%
    );
    animation: progressShine 1.5s infinite;
}

@keyframes progressShine {
    from { transform: translateX(-100%); }
    to { transform: translateX(100%); }
}

.progress-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-sm);
}

.progress-status {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.progress-percent {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-hover);
}

.progress-messages {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-sm);
    margin-top: var(--space-md);
    background: var(--bg-base);
}

.progress-message {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
}

.progress-message .timestamp {
    color: var(--text-muted);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    flex-shrink: 0;
}

.progress-message .message {
    color: var(--text-secondary);
}

.progress-message.success .message { color: var(--success); }
.progress-message.error .message { color: var(--danger); }
.progress-message.info .message { color: var(--text-secondary); }


/* ─── Campaign Detail Modal ──────────────────────────────── */
.campaign-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.detail-item {
    padding: var(--space-md);
    background: var(--bg-base);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.detail-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: var(--space-xs);
}

.detail-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}


/* ─── Tabs ───────────────────────────────────────────────── */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-lg);
    gap: 0;
    overflow-x: auto;
}

.tab {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
    white-space: nowrap;
    background: none;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--primary-hover);
    border-bottom-color: var(--primary);
    font-weight: 600;
}


/* ─── Platform Tabs (Marketing Content Modal) ───────────── */
.platform-tabs {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.ptab {
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
}

.ptab:hover { color: var(--text-primary); border-color: var(--primary); }
.ptab.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }

.ptab-content { animation: fadeIn 0.15s ease; }

/* ─── CRM Funnel Chart ───────────────────────────────────── */
.funnel-chart { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.5rem; }

.funnel-bar-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.82rem;
}

.funnel-label { width: 90px; text-align: right; color: var(--text-muted); flex-shrink: 0; }

.funnel-track {
    flex: 1;
    height: 22px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.funnel-fill {
    height: 100%;
    border-radius: var(--radius-sm);
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    padding-left: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    min-width: 2rem;
}

/* ─── Campaign Card Status Badges ────────────────────────── */
.campaign-card-badge.starting,
.campaign-card-badge.scraping,
.campaign-card-badge.analyzing,
.campaign-card-badge.generating { background: #f59e0b20; color: #f59e0b; }
.campaign-card-badge.failed { background: #ef444420; color: #ef4444; }

/* ─── Responsive Components ──────────────────────────────── */
@media (max-width: 768px) {
    .modal.active {
        align-items: flex-end;
        padding: 0;
    }

    .modal-content {
        max-width: 100%;
        max-height: 92vh;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        animation: modalSlideUpMobile 0.3s var(--ease);
    }

    @keyframes modalSlideUpMobile {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }

    .campaign-detail-grid {
        grid-template-columns: 1fr;
    }

    .tabs {
        gap: 0;
        -webkit-overflow-scrolling: touch;
    }

    #notifications {
        top: auto;
        bottom: calc(var(--bottom-nav-height) + var(--space-sm));
    }
}

@media (max-width: 380px) {
    .modal-header h3 { font-size: 1rem; }
    .modal-body { padding: var(--space-md); }
}