/* ─── Apollo Dashboard — Design System ──────────────────────────────────── */

:root {
    /* Colors */
    --bg-primary: #0a0a14;
    --bg-secondary: #111122;
    --bg-card: rgba(22, 22, 42, 0.7);
    --bg-card-hover: rgba(30, 30, 55, 0.85);
    --border: rgba(255, 255, 255, 0.06);
    --border-focus: rgba(67, 97, 238, 0.5);

    --text-primary: #e8e8f0;
    --text-secondary: #8888aa;
    --text-muted: #555570;

    --accent: #4361ee;
    --accent-glow: rgba(67, 97, 238, 0.25);
    --green: #06d6a0;
    --green-glow: rgba(6, 214, 160, 0.2);
    --orange: #f77f00;
    --orange-glow: rgba(247, 127, 0, 0.2);
    --red: #ef476f;
    --red-glow: rgba(239, 71, 111, 0.2);
    --purple: #7209b7;
    --purple-glow: rgba(114, 9, 183, 0.2);
    --cyan: #00b4d8;

    /* Typography */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ─── Background ──────────────────────────────────────────────────────── */

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 20% 20%, rgba(67, 97, 238, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(114, 9, 183, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(6, 214, 160, 0.04) 0%, transparent 50%);
    z-index: -1;
    pointer-events: none;
}

/* ─── Glass Card ──────────────────────────────────────────────────────── */

.glass {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: all var(--transition);
}

.glass:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.1);
}

/* ─── Header ──────────────────────────────────────────────────────────── */

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 32px;
    border-bottom: 1px solid var(--border);
    background: rgba(10, 10, 20, 0.8);
    backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px var(--accent-glow);
}

.logo .material-icons-round {
    color: white;
    font-size: 24px;
}

.header-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
}

/* ─── Buttons ─────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent), #6366f1);
    color: white;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-accent:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px var(--accent-glow);
}

.btn-accent:active {
    transform: translateY(0);
}

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

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

.btn-run {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    background: rgba(67, 97, 238, 0.15);
    color: var(--accent);
    border: 1px solid rgba(67, 97, 238, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-run:hover {
    background: var(--accent);
    color: white;
    box-shadow: 0 0 20px var(--accent-glow);
    transform: scale(1.1);
}

.btn-run .material-icons-round {
    font-size: 22px;
}

.btn-delete {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-delete:hover {
    color: var(--red);
    background: var(--red-glow);
}

/* ─── Main ────────────────────────────────────────────────────────────── */

.main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px 80px;
}

.section {
    margin-bottom: 40px;
}

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

.section-header h2 {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.section-header h2 .material-icons-round {
    font-size: 22px;
    color: var(--accent);
}

/* ─── Config Grid ─────────────────────────────────────────────────────── */

.config-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

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

.config-card {
    padding: 24px;
}

.config-card h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.config-card h3 .material-icons-round {
    font-size: 18px;
    opacity: 0.7;
}

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

.form-group {
    margin-bottom: 12px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.input {
    width: 100%;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    transition: all var(--transition);
    outline: none;
}

.input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input[readonly] {
    opacity: 0.6;
    cursor: not-allowed;
}

.hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.4;
}

/* ─── Pipeline Cards ──────────────────────────────────────────────────── */

.pipeline-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

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

.pipeline-card {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    overflow: hidden;
}

.pipeline-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0;
    transition: opacity var(--transition);
}

.pipeline-card:hover::before {
    opacity: 1;
}

.pipeline-card.running {
    border-color: rgba(67, 97, 238, 0.4);
    box-shadow: 0 0 30px var(--accent-glow);
}

.pipeline-card.running::before {
    opacity: 1;
    animation: shimmer 2s infinite;
}

@keyframes shimmer {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 1;
    }
}

.pipeline-card.success {
    border-color: rgba(6, 214, 160, 0.3);
}

.pipeline-card.error {
    border-color: rgba(239, 71, 111, 0.3);
}

.pipeline-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pipeline-icon .material-icons-round {
    font-size: 24px;
    color: white;
}

.pipeline-icon.fb {
    background: linear-gradient(135deg, #4267B2, #6366f1);
    box-shadow: 0 0 16px rgba(66, 103, 178, 0.3);
}

.pipeline-icon.leads {
    background: linear-gradient(135deg, var(--green), #00b4d8);
    box-shadow: 0 0 16px var(--green-glow);
}

.pipeline-icon.sales {
    background: linear-gradient(135deg, var(--orange), #f4a261);
    box-shadow: 0 0 16px var(--orange-glow);
}

.pipeline-icon.apt {
    background: linear-gradient(135deg, var(--purple), #e040fb);
    box-shadow: 0 0 16px var(--purple-glow);
}

.pipeline-info {
    flex: 1;
    min-width: 0;
}

.pipeline-info h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.pipeline-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.pipeline-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}

.last-run {
    font-size: 11px;
    color: var(--text-muted);
}

/* ─── Status Badges ───────────────────────────────────────────────────── */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-badge.idle {
    background: rgba(85, 85, 112, 0.2);
    color: var(--text-muted);
}

.status-badge.running {
    background: var(--accent-glow);
    color: var(--accent);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.status-badge.success {
    background: var(--green-glow);
    color: var(--green);
}

.status-badge.error {
    background: var(--red-glow);
    color: var(--red);
}

/* ─── Mapping Table ───────────────────────────────────────────────────── */

.mapping-table-wrap {
    padding: 4px;
    overflow-x: auto;
}

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

.mapping-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.mapping-table td {
    padding: 8px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 14px;
}

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

.mapping-table .input {
    padding: 6px 10px;
    font-size: 13px;
}

.mapping-table th:last-child,
.mapping-table td:last-child {
    width: 48px;
    text-align: center;
}

/* ─── Logs Panel ──────────────────────────────────────────────────────── */

.log-tabs {
    display: flex;
    gap: 4px;
}

.tab {
    padding: 6px 16px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid transparent;
    border-radius: 6px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.tab:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.03);
}

.tab.active {
    color: var(--accent);
    background: var(--accent-glow);
    border-color: rgba(67, 97, 238, 0.2);
}

.log-panel {
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.log-content {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-all;
}

.log-empty {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 40px 0;
}

.log-line {
    padding: 2px 0;
    color: var(--text-secondary);
}

.log-line.success {
    color: var(--green);
}

.log-line.error {
    color: var(--red);
}

.log-line.info {
    color: var(--cyan);
}

/* ─── Footer ──────────────────────────────────────────────────────────── */

.footer {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 12px;
    border-top: 1px solid var(--border);
}

/* ─── Scrollbar ───────────────────────────────────────────────────────── */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ─── Toast Notification ──────────────────────────────────────────────── */

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: white;
    z-index: 1000;
    animation: slideUp 0.3s ease-out;
    box-shadow: var(--shadow);
}

.toast.success {
    background: linear-gradient(135deg, #059669, var(--green));
}

.toast.error {
    background: linear-gradient(135deg, #dc2626, var(--red));
}

.toast.info {
    background: linear-gradient(135deg, var(--accent), #6366f1);
}

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

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ─── Facebook Auth ───────────────────────────────────────────────────── */

.fb-auth-card {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.fb-auth-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.fb-auth-info h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.fb-auth-status {
    font-size: 13px;
    color: var(--text-secondary);
}

.fb-auth-status.connected {
    color: var(--green);
}

.fb-auth-status.expired {
    color: var(--red);
}

.fb-auth-detail {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.btn-fb {
    background: linear-gradient(135deg, #1877F2, #4267B2);
    color: white;
    box-shadow: 0 4px 16px rgba(24, 119, 242, 0.3);
}

.btn-fb:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(24, 119, 242, 0.4);
}

.btn-fb.connected {
    background: linear-gradient(135deg, #059669, var(--green));
    box-shadow: 0 4px 16px var(--green-glow);
}

/* ─── Loading Spinner ─────────────────────────────────────────────────── */

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.btn-run.running .material-icons-round {
    animation: spin 1s linear infinite;
}

/* ─── Scheduler ──────────────────────────────────────────────────────── */

.scheduler-card {
    padding: 20px 24px;
}

.scheduler-row {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}

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

.scheduler-label {
    font-size: 14px;
    font-weight: 500;
}

.scheduler-time {
    display: flex;
    align-items: center;
    gap: 8px;
}

.scheduler-time label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.scheduler-time .input {
    width: 120px;
    text-align: center;
}

.scheduler-next {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-muted);
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: rgba(85, 85, 112, 0.3);
    border-radius: 26px;
    transition: var(--transition);
    border: 1px solid var(--border);
}

.slider::before {
    content: '';
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 2px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: var(--transition);
}

.switch input:checked+.slider {
    background: var(--accent-glow);
    border-color: rgba(67, 97, 238, 0.4);
}

.switch input:checked+.slider::before {
    transform: translateX(21px);
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}

/* Scheduler Extras */
.scheduler-pipelines {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.scheduler-pipes-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.pipe-check {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: var(--text-secondary);
}

.scheduler-info-row {
    margin-top: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.scheduler-last-run {
    font-size: 13px;
    color: var(--text-muted);
}

.scheduler-history {
    margin-top: 20px;
    padding: 20px 24px;
}

.scheduler-history h3 {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 16px 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-item {
    transition: all 0.2s ease;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.05) !important;
}