/* ================= Design tokens ================= */
:root {
    --teal: #2B6777;
    --teal-dark: #1E4A56;
    --teal-light: #E8F1F3;
    --orange: #FF3300;
    --orange-dark: #D62900;
    --ink: #16232A;
    --muted: #6B7B82;
    --border: #E1E8EA;
    --bg: #F6F8F9;
    --surface: #FFFFFF;
    --success: #1E8A5C;
    --success-bg: #E4F5EC;
    --danger: #D62828;
    --danger-bg: #FCE9E9;
    --warning: #B8790A;
    --warning-bg: #FBF0DD;
    --info: #2B6777;
    --info-bg: #E8F1F3;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(22,35,42,0.06), 0 1px 8px rgba(22,35,42,0.04);
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.5;
}
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.01em; }
h3 { font-size: 15px; font-weight: 700; margin: 0 0 12px; }
.text-muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ================= App shell ================= */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    background: var(--teal-dark);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    flex-shrink: 0;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 22px; }
.brand-mark {
    width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--orange), var(--teal));
}
.brand-name { font-weight: 700; font-size: 14px; line-height: 1.2; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar-nav a {
    color: rgba(255,255,255,0.75);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.08); text-decoration: none; color: #fff; }
.sidebar-nav a.active { background: rgba(255,255,255,0.14); color: #fff; }
.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.12); padding-top: 12px; margin-top: 12px; }
.user-chip { font-size: 13px; font-weight: 600; padding: 0 8px 6px; }
.logout-link { display: block; padding: 8px; font-size: 13px; color: rgba(255,255,255,0.6); }
.logout-link:hover { color: #fff; }

.main-content { flex: 1; padding: 32px 40px; max-width: 1180px; }

/* ================= Page header ================= */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.page-subtitle { color: var(--muted); font-size: 14px; margin: 0; }

/* ================= Buttons ================= */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 18px; border-radius: 8px; font-size: 14px; font-weight: 600;
    border: 1px solid transparent; cursor: pointer; transition: all 0.15s ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-dark); }
.btn-primary:disabled { background: #F2B7A8; cursor: not-allowed; }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.link-btn { background: none; border: none; color: var(--teal); font-weight: 600; cursor: pointer; padding: 0; font-size: inherit; }
.link-btn.danger { color: var(--danger); }

/* ================= Cards / surfaces ================= */
.empty-state {
    background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
    padding: 48px 24px; text-align: center; color: var(--muted);
}
.empty-state p:first-child { color: var(--ink); font-weight: 600; font-size: 16px; }

/* ================= Auth pages ================= */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--teal-dark); }
.auth-card { background: #fff; border-radius: 14px; padding: 36px; width: 360px; box-shadow: 0 20px 60px rgba(0,0,0,0.25); }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.auth-page form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.auth-page label { font-size: 13px; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.auth-page input { font: inherit; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; color: var(--ink); }
.auth-page input:focus { outline: none; border-color: var(--teal); }
.plain-list { padding-left: 18px; }

/* ================= Alerts ================= */
.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; font-weight: 500; margin: 0 0 8px; }
.alert-danger { background: var(--danger-bg); color: var(--danger); }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-warning { background: var(--warning-bg); color: var(--warning); }

/* ================= Badges ================= */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; text-transform: capitalize; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-primary { background: var(--teal-light); color: var(--teal-dark); }
.badge-muted { background: #EEF1F2; color: var(--muted); }

/* ================= Accounts page ================= */
.account-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.account-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; box-shadow: var(--shadow);
}
.account-avatar img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
.avatar-fallback {
    width: 44px; height: 44px; border-radius: 50%; background: var(--teal-light); color: var(--teal-dark);
    display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.avatar-fallback.small { width: 32px; height: 32px; font-size: 13px; }
.account-info { flex: 1; min-width: 100px; }
.account-name { font-weight: 700; font-size: 14px; }
.account-platform { font-size: 12px; color: var(--muted); }
.account-error { width: 100%; font-size: 12px; color: var(--danger); }

/* ================= Composer ================= */
.composer { display: grid; grid-template-columns: 1fr 300px; gap: 24px; align-items: start; }
.composer-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.block-label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 10px; color: var(--ink); }

.drop-zone {
    border: 2px dashed var(--border); border-radius: 10px; padding: 28px; text-align: center;
    background: var(--bg); transition: border-color 0.15s;
}
.drop-zone.dragover { border-color: var(--teal); background: var(--teal-light); }
.drop-zone img, .drop-zone video { max-width: 100%; max-height: 320px; border-radius: 8px; display: block; margin: 0 auto 10px; }

textarea#caption {
    width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 12px;
    font: inherit; resize: vertical; color: var(--ink);
}
textarea#caption:focus { outline: none; border-color: var(--teal); }
.char-count { text-align: right; font-size: 12px; color: var(--muted); margin-top: 4px; }

.account-checklist { display: flex; flex-direction: column; gap: 8px; }
.account-check {
    display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--border);
    border-radius: 8px; cursor: pointer; font-size: 13px;
}
.account-check:has(input:checked) { border-color: var(--teal); background: var(--teal-light); }
.account-check-avatar img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.account-check-name { display: block; font-weight: 600; }
.account-check-platform { display: block; font-size: 11px; color: var(--muted); }

select, input[type=date], input[type=time] {
    font: inherit; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; width: 100%; color: var(--ink);
}
.radio-row { display: flex; gap: 16px; font-size: 13px; margin-bottom: 10px; }
.radio-row label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
#scheduleFields { display: flex; gap: 8px; }

.progress-bar { height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; width: 0%; background: var(--orange); transition: width 0.2s; }

#composeResult { margin-top: 10px; font-size: 13px; }

/* ================= Post list ================= */
.post-list { display: flex; flex-direction: column; gap: 10px; }
.post-row {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 12px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow);
}
.post-thumb { width: 56px; height: 56px; border-radius: 8px; overflow: hidden; flex-shrink: 0; background: var(--bg); }
.post-thumb img, .post-thumb video { width: 100%; height: 100%; object-fit: cover; }
.thumb-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--muted); font-weight: 700; }
.post-body { flex: 1; min-width: 0; }
.post-caption { margin: 0 0 6px; font-size: 14px; }
.post-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ================= Post detail ================= */
.detail-layout { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
.detail-media { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.detail-media img, .detail-media video { max-width: 100%; border-radius: 8px; margin-bottom: 14px; }
.detail-caption { white-space: pre-wrap; font-size: 14px; }
.detail-targets { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.target-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.target-row:last-child { border-bottom: none; }
.target-info { flex: 1; font-size: 13px; }
.target-error { color: var(--danger); font-size: 12px; }

@media (max-width: 900px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 10px 16px; }
    .sidebar-nav { flex-direction: row; }
    .sidebar-footer { display: none; }
    .main-content { padding: 20px; }
    .composer, .detail-layout { grid-template-columns: 1fr; }
}
