/* ═══════════════════════════════════════════════════════════════════════════
   AutomateFlow Pro — Design System v3.0
   Premium SaaS Dashboard — Step-based Flow
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #eef2ff;
    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --danger: #ef4444;
    --danger-light: #fef2f2;

    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --bg-input: #f8fafc;

    --sidebar-bg: #0f172a;
    --sidebar-active: #1e293b;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --border: #e2e8f0;
    --border-focus: var(--primary);

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;

    --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.04);

    --transition: 200ms ease;
}

/* ─── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after {
    margin: 0; padding: 0; box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background: var(--bg-body);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
    width: 240px;
    min-width: 240px;
    background: var(--sidebar-bg);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.25rem;
    margin-bottom: 2rem;
}

.brand-icon {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
}

.brand h1 { font-size: 1.1rem; font-weight: 700; color: #f8fafc; line-height: 1.2; }
.brand-tag { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); font-weight: 600; }

.nav-menu { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav-link {
    display: flex; align-items: center; gap: 0.7rem;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm);
    color: #94a3b8;
    text-decoration: none;
    font-weight: 500; font-size: 0.875rem;
    transition: all var(--transition);
    cursor: pointer;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
.nav-link.active { background: var(--primary); color: white; box-shadow: 0 2px 8px rgba(99,102,241,.4); }

.sidebar-footer {
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex; justify-content: space-between; align-items: center;
}

.env-status { display: flex; align-items: center; gap: 6px; font-size: 0.75rem; color: #94a3b8; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 6px var(--success); }
.version-tag { font-size: 0.65rem; color: #475569; font-weight: 600; background: rgba(255,255,255,.06); padding: 2px 8px; border-radius: 4px; }

/* ─── Main Content ───────────────────────────────────────────────────────── */
.main-wrapper {
    margin-left: 240px;
    flex: 1;
    padding: 1.5rem 2.5rem 3rem;
    max-width: 1200px;
}

.top-bar {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 2rem;
}
.top-bar h2 { font-size: 1.5rem; font-weight: 800; color: var(--text-primary); }
.page-subtitle { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; }

.avatar {
    width: 36px; height: 36px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}

/* ─── Account Selector Grid ────────────────────────────────────────────── */
.account-selector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    background: var(--bg-input);
    padding: 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    max-height: 180px;
    overflow-y: auto;
}

.account-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
}
.account-chip:hover { border-color: var(--primary); background: var(--primary-light); }
.account-chip.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 2px 4px rgba(99,102,241,.2);
}

.account-icon { font-size: 1.1rem; }

/* ─── Connections List ────────────────────────────────────────────────── */
.connections-list { padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }

.connection-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
}
.connection-info { display: flex; align-items: center; gap: 12px; }
.connection-logo {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: #1877f2;
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
}

/* ─── Launch Panel ───────────────────────────────────────────────────── */
.launch-panel { display: flex; flex-direction: column; gap: 1.5rem; }

.status-panel {
    background: var(--sidebar-bg);
    color: #e2e8f0;
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.status-item:last-child { border-bottom: none; }
.status-label { font-weight: 500; }
.status-val { font-weight: 700; color: var(--success); }
.status-val.working { color: var(--warning); }
.status-val.error { color: var(--danger); }

/* ─── Views ──────────────────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.3s ease; }

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

/* ─── Step Sections ──────────────────────────────────────────────────────── */
.step-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-xs);
    transition: all var(--transition);
    overflow: hidden;
}
.step-section:hover { box-shadow: var(--shadow-sm); }

.step-section.disabled { opacity: 0.55; pointer-events: none; }
.step-section.completed { border-left: 3px solid var(--success); }
.step-section.active-step { border-left: 3px solid var(--primary); }

.step-header {
    display: flex; align-items: center; gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-input);
}
.step-header h3 { font-size: 0.95rem; font-weight: 700; }
.step-header p { font-size: 0.8rem; color: var(--text-muted); margin-top: 1px; }

.step-badge {
    width: 32px; height: 32px; min-width: 32px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem;
}
.step-section.completed .step-badge { background: var(--success); }
.step-section.disabled .step-badge { background: var(--text-muted); }

.step-body { padding: 1.5rem; }

/* ─── Form Grid ──────────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 900px) { .form-grid { grid-template-columns: 1fr; } }

.form-col { display: flex; flex-direction: column; gap: 0; }

.input-group { margin-bottom: 1.25rem; }
.input-group label {
    display: block; font-size: 0.8rem; font-weight: 600;
    color: var(--text-secondary); margin-bottom: 6px;
    text-transform: uppercase; letter-spacing: 0.03em;
}

input[type="text"], input[type="datetime-local"], textarea, select {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: var(--bg-input);
    color: var(--text-primary);
    transition: all var(--transition);
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99,102,241,.1);
    background: white;
}
textarea { resize: vertical; min-height: 80px; line-height: 1.6; }

/* ─── Language Toggle ────────────────────────────────────────────────────── */
.lang-toggle {
    display: flex; gap: 6px;
    background: var(--bg-input); padding: 4px; border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.lang-option { flex: 1; }
.lang-option input { display: none; }
.lang-btn {
    display: block; text-align: center;
    padding: 0.55rem 0.5rem;
    border-radius: 6px; font-size: 0.85rem; font-weight: 600;
    cursor: pointer; color: var(--text-muted);
    transition: all var(--transition);
}
.lang-option input:checked + .lang-btn {
    background: white; color: var(--primary);
    box-shadow: var(--shadow-xs);
}

/* ─── Asset Upload ───────────────────────────────────────────────────────── */
.asset-controls { display: flex; gap: 0.75rem; align-items: stretch; }

.drop-zone {
    flex: 1;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 6px; cursor: pointer;
    font-size: 0.8rem; color: var(--text-muted);
    transition: all var(--transition);
    background-size: cover; background-position: center;
}
.drop-zone:hover { border-color: var(--primary); background-color: var(--primary-light); }

.file-status { font-size: 0.75rem; color: var(--primary); margin-top: 6px; font-weight: 500; }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 0.65rem 1.25rem;
    border: none; border-radius: var(--radius-sm);
    font-weight: 600; font-size: 0.875rem;
    cursor: pointer; transition: all var(--transition);
    text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); box-shadow: 0 2px 8px rgba(99,102,241,.35); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #059669; box-shadow: 0 2px 8px rgba(16,185,129,.35); }

.btn-secondary { background: var(--primary-light); color: var(--primary); }
.btn-secondary:hover:not(:disabled) { background: #dbeafe; }

.btn-outline { border: 1px solid var(--border); background: white; color: var(--text-secondary); }
.btn-outline:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

.btn-lg { padding: 0.8rem 1.75rem; font-size: 0.9rem; width: 100%; }

.step-actions { margin-top: 0.5rem; }

/* ─── Loader ─────────────────────────────────────────────────────────────── */
.loader {
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Error / Status ─────────────────────────────────────────────────────── */
.error-msg {
    margin-top: 0.75rem; padding: 0.65rem 1rem;
    background: var(--danger-light); color: var(--danger);
    border-radius: var(--radius-sm); font-size: 0.8rem; font-weight: 500;
    border: 1px solid #fecaca;
}

.status-banner {
    margin-top: 1rem; padding: 0.85rem 1.25rem;
    border-radius: var(--radius-sm);
    font-weight: 600; font-size: 0.9rem;
    text-align: center;
}
.status-banner.success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.status-banner.scheduled { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }

/* ─── Tabs ───────────────────────────────────────────────────────────────── */
.tabs-header {
    display: flex; gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.25rem;
}
.tab-btn {
    padding: 0.65rem 1.25rem;
    border: none; background: transparent;
    font-weight: 600; font-size: 0.85rem;
    color: var(--text-muted); cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition);
}
.tab-btn:hover { color: var(--text-secondary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

.review-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-top: 1.25rem; }
@media (max-width: 900px) { .review-grid { grid-template-columns: 1fr; } }

.mono-text { font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; font-size: 0.82rem; }

/* ─── Distribute ─────────────────────────────────────────────────────────── */
.distribute-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 900px) { .distribute-grid { grid-template-columns: 1fr; } }

.distribute-card {
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
    display: flex; flex-direction: column; gap: 0.75rem;
}
.distribute-card h4 { font-size: 0.95rem; font-weight: 700; }
.distribute-card p { font-size: 0.8rem; color: var(--text-muted); }

.schedule-input {
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.85rem; background: var(--bg-input);
}

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
}
.card-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-input);
}
.card-header h3 { font-size: 1rem; font-weight: 700; }
.card-badge {
    background: var(--primary-light); color: var(--primary);
    padding: 3px 10px; border-radius: 20px;
    font-size: 0.72rem; font-weight: 600;
}

/* ─── History ────────────────────────────────────────────────────────────── */
.history-list { padding: 1rem 1.5rem; }

.history-item {
    padding: 1rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    transition: all var(--transition);
}
.history-item:hover { box-shadow: var(--shadow-sm); }

.history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.history-page { font-size: 0.9rem; font-weight: 600; margin-bottom: 4px; }
.history-caption { font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; }

.badge {
    display: inline-block;
    padding: 2px 8px; border-radius: 4px;
    font-size: 0.65rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.05em;
}
.badge-success { background: var(--success-light); color: #065f46; }
.badge-pending { background: var(--warning-light); color: #92400e; }

.btn-reuse {
    background: none; border: none;
    color: var(--primary); font-size: 0.75rem; font-weight: 700;
    cursor: pointer; padding: 4px 0; margin-top: 6px;
}
.btn-reuse:hover { text-decoration: underline; }

/* ─── Settings ───────────────────────────────────────────────────────────── */
.settings-grid { padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }

.setting-item {
    display: flex; align-items: center; gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.setting-item label { font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); min-width: 180px; }
.setting-item code { font-size: 0.8rem; color: var(--text-muted); flex: 1; font-family: 'SF Mono', monospace; }
.setting-status { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; padding: 3px 10px; border-radius: 20px; }
.setting-status.connected { background: var(--success-light); color: #065f46; }

/* ─── Placeholder ────────────────────────────────────────────────────────── */
.placeholder-state {
    text-align: center; padding: 3rem 1rem; color: var(--text-muted);
    display: flex; flex-direction: column; align-items: center; gap: 0.75rem;
}
.placeholder-state p { font-size: 0.85rem; }

/* ─── Toast ──────────────────────────────────────────────────────────────── */
.toast-container {
    position: fixed; bottom: 1.5rem; right: 1.5rem;
    z-index: 9999; display: flex; flex-direction: column; gap: 8px;
}
.toast {
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem; font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    max-width: 360px;
}
.toast.success { background: #065f46; color: white; }
.toast.error { background: #991b1b; color: white; }
.toast.info { background: var(--sidebar-bg); color: white; }

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

/* ─── Blog Actions ───────────────────────────────────────────────────────── */
.blog-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.btn-sm { padding: 6px 14px; font-size: 0.78rem; }

/* ─── Utilities ──────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
