/* FastPost Social v3 - Dashboard Styles */

:root {
    --bg: #0f1117;
    --bg2: #1a1d27;
    --bg3: #22263a;
    --border: #2e3248;
    --accent: #6c63ff;
    --accent2: #8b85ff;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text: #e8e9f0;
    --text-muted: #8891b0;
    --card-radius: 12px;
    --sidebar-w: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    font-size: 14px;
}

/* ── SIDEBAR ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
}
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 24px;
    border-bottom: 1px solid var(--border);
}
.logo-icon { font-size: 22px; }
.logo-text { font-size: 18px; font-weight: 700; color: var(--accent2); }

.sidebar-nav { margin-top: 24px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.15s;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-icon { font-size: 16px; }

.sidebar-status {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: var(--bg3);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-muted);
}
.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}
.status-dot.running { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.stopped { background: var(--danger); }

/* ── MAIN ── */
.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── TOPBAR ── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 28px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar h1 { font-size: 20px; font-weight: 700; }
.topbar-right { display: flex; gap: 10px; }
.date-badge {
    background: var(--bg3);
    color: var(--text-muted);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
}

/* ── BUTTONS ── */
.btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.85; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── PAGES ── */
.page { display: none; padding: 28px; }
.page.active { display: block; }

/* ── STAT CARDS ── */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    padding: 20px;
    text-align: center;
}
.stat-card.highlight { border-color: var(--accent); }
.stat-number { font-size: 32px; font-weight: 700; color: var(--accent2); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── QUEUE UX: onboarding, account strip, sections ── */
.onboarding-banner {
    background: linear-gradient(135deg, rgba(108, 99, 255, 0.12), rgba(139, 133, 255, 0.06));
    border: 1px solid var(--accent);
    border-radius: var(--card-radius);
    padding: 16px 20px;
    margin-bottom: 20px;
}
.onboarding-inner strong { display: block; font-size: 14px; margin-bottom: 8px; color: var(--text); }
.onboarding-inner p { font-size: 13px; color: var(--text-muted); line-height: 1.55; margin: 0; }
.onboarding-inner p + p { margin-top: 8px; }
.onboarding-note { color: var(--text) !important; }
.onboarding-foot { margin-top: 10px !important; }
.inline-link { color: var(--accent2); font-weight: 600; text-decoration: underline; cursor: pointer; }

.accounts-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 22px;
}
.account-chip {
    display: inline-flex;
    flex-direction: column;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg2);
    min-width: 168px;
}
.account-chip--ok { border-color: rgba(34, 197, 94, 0.45); }
.account-chip--warn { border-color: rgba(245, 158, 11, 0.45); }
.account-chip-icon { font-size: 14px; margin-bottom: 4px; }
.account-chip-name { font-weight: 600; font-size: 13px; }
.account-chip-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.queue-section { margin-bottom: 36px; }
.section-head { margin-bottom: 14px; }
.section-title { font-size: 15px; font-weight: 600; color: var(--text); }
.section-sub { font-size: 12px; color: var(--text-muted); margin-top: 6px; max-width: 720px; line-height: 1.5; }

.recent-published-list { display: flex; flex-direction: column; gap: 12px; }
.recent-item {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    padding: 14px 16px;
}
.recent-item-top {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    align-items: center;
    font-size: 12px;
    color: var(--text-muted);
}
.recent-name { font-weight: 600; color: var(--text); }
.recent-date { margin-left: auto; font-size: 11px; }
.recent-type { font-size: 11px; color: var(--accent2); margin: 8px 0 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.recent-caption { font-size: 13px; line-height: 1.55; color: var(--text); white-space: pre-wrap; }
.recent-empty { padding: 28px 16px !important; }

.account-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.account-title-row h3 { margin: 0; font-size: 15px; font-weight: 600; }
.platform-tag {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 6px;
    background: var(--bg3);
    border: 1px solid var(--border);
    white-space: nowrap;
}
.platform-facebook { border-color: rgba(24, 119, 242, 0.5); color: #7ab8ff; }
.platform-instagram { border-color: rgba(228, 64, 95, 0.5); color: #f472b6; }
.platform-both { border-color: var(--accent); color: var(--accent2); }

.account-links { margin-top: 4px; font-size: 12px; }
.account-links a { color: var(--accent2); }
.account-meta-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-top: 10px; }
.status-pill { font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 20px; }
.status-pill--ok { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.status-pill--warn { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.meta-text { font-size: 11px; color: var(--text-muted); }
.crawl-preview { font-size: 12px; color: var(--text-muted); margin-top: 8px; line-height: 1.45; max-width: 560px; }
.next-step-hint { font-size: 12px; color: var(--accent2); margin-top: 10px; line-height: 1.4; }

.history-item--wide { grid-template-columns: minmax(100px, 140px) 1fr minmax(90px, 120px); }
.history-item--wide .history-caption { white-space: normal; line-height: 1.4; }
.history-platform { display: block; font-size: 10px; color: var(--text-muted); font-weight: 400; text-transform: none; letter-spacing: 0; margin-top: 4px; }

.post-card-footer .btn-sm { flex: 0 0 auto; }

/* ── QUEUE GRID ── */
.queue-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}

.post-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    overflow: hidden;
    transition: border-color 0.15s;
}
.post-card:hover { border-color: var(--accent); }
.post-card.published { opacity: 0.6; border-color: var(--success); }

.post-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg3);
    border-bottom: 1px solid var(--border);
}
.post-type-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-morning { background: #fef3c7; color: #92400e; }
.badge-afternoon { background: #dbeafe; color: #1e40af; }
.badge-evening { background: #ede9fe; color: #5b21b6; }
.badge-unknown { background: var(--bg3); color: var(--text-muted); }

.post-time { font-size: 12px; color: var(--text-muted); }
.post-account { font-size: 12px; color: var(--text-muted); font-weight: 500; }

.post-card-body { padding: 16px; }
.post-caption {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
}

.post-card-footer {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}
.post-card-footer .btn { flex: 1; justify-content: center; font-size: 12px; }

/* ── CARD ── */
.card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    padding: 24px;
    margin-bottom: 20px;
}
.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 20px; }

/* ── FORMS ── */
.account-form { display: flex; flex-direction: column; gap: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.form-group input,
.form-group select,
.form-group textarea {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
}

/* ── ACCOUNTS LIST ── */
.accounts-list { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.account-item {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    padding: 16px 20px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}
.account-info h3 { font-size: 15px; font-weight: 600; }
.account-info p { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.account-actions { display: flex; gap: 8px; }

/* ── SETTINGS ── */
.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
}
.settings-row p { margin-bottom: 6px; line-height: 1.5; }
.settings-btns { display: flex; flex-direction: column; gap: 8px; min-width: 200px; }
.muted { color: var(--text-muted); font-size: 12px; }

/* ── MODAL ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-overlay.hidden { display: none; }
.modal-wide {
  max-width: min(640px,96vw);
}

.session-json-input {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.4;
  resize: vertical;
}

.modal {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 14px;
    width: 560px;
    max-width: 95vw;
    max-height: 85vh;
    overflow-y: auto;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
}
.modal-body { padding: 24px; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

.image-prompt-preview {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 12px;
    line-height: 1.5;
}

/* ── TOAST ── */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 20px;
    z-index: 2000;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    animation: slideIn 0.2s ease;
}
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.info { border-color: var(--accent); color: var(--accent2); }
.toast.hidden { display: none; }

/* ── EMPTY STATE ── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    grid-column: 1 / -1;
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { margin-top: 6px; line-height: 1.6; }

/* ── POST HISTORY ── */
.post-history { display: flex; flex-direction: column; gap: 8px; }
.history-item {
    display: grid;
    grid-template-columns: 120px 1fr 80px;
    gap: 12px;
    padding: 12px;
    background: var(--bg3);
    border-radius: 8px;
    align-items: center;
    font-size: 13px;
}
.history-type { color: var(--text-muted); font-size: 11px; text-transform: uppercase; }
.history-caption { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-stats { text-align: right; color: var(--accent2); font-weight: 600; }

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

/* ── LOADING ── */
.loading-spinner {
    display: inline-block;
    width: 16px; height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── UNDER CONSTRUCTION OVERLAY (every full page load) ── */
body.construction-locked {
    overflow: hidden;
}

.construction-overlay {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(8, 10, 18, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.construction-overlay.hidden {
    display: none;
}

.construction-panel {
    max-width: 520px;
    width: 100%;
    background: linear-gradient(165deg, var(--bg2) 0%, var(--bg3) 100%);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    padding: 28px 28px 24px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.construction-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--warning);
    margin-bottom: 12px;
}

.construction-title {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.25;
    margin-bottom: 10px;
}

.construction-lead {
    color: var(--text-muted);
    line-height: 1.55;
    margin-bottom: 16px;
}

.construction-list {
    margin: 0 0 18px 1rem;
    color: var(--text);
    line-height: 1.6;
    font-size: 13px;
}

.construction-list li {
    margin-bottom: 10px;
}

.construction-list li:last-child {
    margin-bottom: 0;
}

.construction-hint {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.construction-hint .kbd {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent2);
}

.construction-cta {
    width: 100%;
    justify-content: center;
    padding: 12px 20px;
    font-size: 15px;
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .logo-text, .nav-item span:last-child, .sidebar-status span { display: none; }
    .main { margin-left: 60px; }
    .stats-row { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .settings-row { flex-direction: column; }
}
