/* =========================================================
   SocialSuite — Light Theme
   ========================================================= */

:root {
    --bg: #f5f7fb;
    --bg-card: #ffffff;
    --bg-soft: #f0f2f9;
    --border: #e4e8f0;
    --text: #1a1d29;
    --text-muted: #6b7280;
    --text-faint: #9ca3af;

    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;

    --success: #16a34a;
    --success-soft: #ecfdf3;
    --warning: #d97706;
    --warning-soft: #fffaeb;
    --danger: #dc2626;
    --danger-soft: #fef2f2;

    --fb: #1877f2;
    --ig: #e1306c;
    --tw: #14171a;
    --li: #0a66c2;
    --tt: #010101;
    --yt: #ff0000;
    --pin: #e60023;
    --th: #000000;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);
    --sidebar-w: 250px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }
img { max-width: 100%; display: block; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s ease;
    white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg-soft); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #fde2e2; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-icon { padding: 8px; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 18px; }
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--text); }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=datetime-local], textarea, select {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea { resize: vertical; min-height: 100px; }
.form-hint { font-size: 12px; color: var(--text-faint); margin-top: 6px; }
.input-error { border-color: var(--danger) !important; }
.error-text { color: var(--danger); font-size: 12px; margin-top: 6px; }

/* ---------- Auth pages ---------- */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(150deg, #f5f7fb 0%, #eef1fb 100%);
    padding: 20px;
}
.auth-card {
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 420px;
    padding: 40px 36px;
    border: 1px solid var(--border);
}
.auth-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    margin-bottom: 8px;
    font-weight: 800;
    font-size: 22px;
}
.auth-logo .logo-mark {
    width: 34px; height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 800; font-size: 16px;
}
.auth-subtitle { text-align: center; color: var(--text-muted); margin-bottom: 28px; font-size: 13px; }
.auth-footer { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-muted); }
.auth-footer a { color: var(--primary); font-weight: 600; }
.divider { text-align: center; margin: 8px 0; color: var(--text-faint); font-size: 12px; }

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert-info { background: var(--primary-soft); color: var(--primary); }

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

.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 40;
}
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 22px;
    font-weight: 800;
    font-size: 18px;
}
.sidebar-logo .logo-mark {
    width: 32px; height: 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 800; font-size: 15px;
}
.nav-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-faint);
    font-weight: 700;
    padding: 14px 12px 6px;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
    transition: all .15s ease;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link:hover { background: var(--bg-soft); color: var(--text); }
.nav-link.active { background: var(--primary-soft); color: var(--primary); }
.sidebar-footer { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
}
.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
    overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-chip-info { overflow: hidden; }
.user-chip-name { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip-email { font-size: 12px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 26px 34px 60px;
    width: calc(100% - var(--sidebar-w));
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 26px;
    flex-wrap: wrap;
    gap: 14px;
}
.page-title { font-size: 24px; font-weight: 800; }
.page-subtitle { color: var(--text-muted); font-size: 13.5px; margin-top: 4px; }

.mobile-toggle {
    display: none;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    cursor: pointer;
}

/* ---------- Cards / grid ---------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
}
.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

.stat-card { display: flex; flex-direction: column; gap: 8px; }
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
}
.stat-value { font-size: 26px; font-weight: 800; }
.stat-label { color: var(--text-muted); font-size: 13px; font-weight: 600; }
.stat-delta { font-size: 12px; font-weight: 700; }
.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--danger); }

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.section-heading h3 { font-size: 16px; font-weight: 700; }

/* ---------- Platform badges ---------- */
.platform-icon {
    width: 34px; height: 34px;
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    flex-shrink: 0;
}
.platform-icon svg { width: 18px; height: 18px; }
.p-facebook { background: var(--fb); }
.p-instagram { background: linear-gradient(45deg,#f9ce34,#ee2a7b,#6228d7); }
.p-twitter { background: #000; }
.p-linkedin { background: var(--li); }
.p-tiktok { background: #000; }
.p-youtube { background: var(--yt); }
.p-pinterest { background: var(--pin); }
.p-threads { background: #000; }

.platform-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px 5px 6px;
    border-radius: 999px;
    background: var(--bg-soft);
    font-size: 12px;
    font-weight: 700;
}
.platform-pill .dot { width: 20px; height: 20px; border-radius: 50%; display:flex; align-items:center; justify-content:center; color:#fff; }
.platform-pill .dot svg { width: 11px; height: 11px; }

/* ---------- Account cards (connect page) ---------- */
.account-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
}
.account-card .info { flex: 1; min-width: 0; }
.account-card .name { font-weight: 700; font-size: 14.5px; }
.account-card .handle { color: var(--text-faint); font-size: 12.5px; }
.status-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
    display: inline-block;
}
.status-connected { background: var(--success-soft); color: var(--success); }
.status-expired { background: var(--warning-soft); color: var(--warning); }
.status-error { background: var(--danger-soft); color: var(--danger); }

.connect-tile {
    border: 1.5px dashed var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
    background: var(--bg-soft);
    cursor: pointer;
    transition: all .15s ease;
}
.connect-tile:hover { border-color: var(--primary); background: var(--primary-soft); }
.connect-tile .platform-icon { width: 44px; height: 44px; border-radius: 12px; }
.connect-tile .platform-icon svg { width: 22px; height: 22px; }
.connect-tile-name { font-weight: 700; font-size: 13.5px; }

/* ---------- Composer ---------- */
.composer-platforms { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 6px; }
.platform-check {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 8px 8px;
    border: 1.5px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all .15s ease;
    background: #fff;
}
.platform-check.checked { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.platform-check .platform-icon { width: 24px; height: 24px; border-radius: 6px; }
.platform-check .platform-icon svg { width: 13px; height: 13px; }
.platform-check input { display: none; }

.char-counter { font-size: 12px; color: var(--text-faint); text-align: right; margin-top: 6px; }
.char-counter.over { color: var(--danger); font-weight: 700; }

.upload-zone {
    border: 1.5px dashed var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    color: var(--text-faint);
    cursor: pointer;
    font-size: 13px;
    background: var(--bg-soft);
}
.upload-zone:hover { border-color: var(--primary); }
.media-preview { position: relative; margin-top: 12px; display: inline-block; }
.media-preview img, .media-preview video { max-height: 220px; border-radius: var(--radius-sm); }
.media-preview .remove-media {
    position: absolute; top: -8px; right: -8px;
    background: var(--danger); color: #fff;
    width: 24px; height: 24px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; border: 2px solid #fff; font-size: 13px;
}

.schedule-row { display: flex; align-items: center; gap: 10px; }

/* ---------- Table / post list ---------- */
.post-row {
    display: flex;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    align-items: flex-start;
}
.post-row .thumb { width: 56px; height: 56px; border-radius: var(--radius-sm); object-fit: cover; background: var(--bg-soft); flex-shrink: 0; }
.post-row .content-text { font-size: 13.5px; color: var(--text); margin-bottom: 8px; }
.post-row .meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.post-row .platforms { display: flex; gap: 6px; }

.badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
}
.badge-published { background: var(--success-soft); color: var(--success); }
.badge-scheduled { background: var(--primary-soft); color: var(--primary); }
.badge-draft { background: var(--bg-soft); color: var(--text-muted); }
.badge-failed { background: var(--danger-soft); color: var(--danger); }

.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-faint);
}
.empty-state svg { width: 46px; height: 46px; margin: 0 auto 14px; opacity: .5; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn {
    padding: 10px 16px;
    font-weight: 600;
    font-size: 13.5px;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tab-btn.active { color: var(--primary); border-color: var(--primary); }

.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(17, 20, 30, .5);
    display: none;
    align-items: center; justify-content: center;
    z-index: 100;
    padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 460px;
    padding: 26px;
    box-shadow: var(--shadow-md);
    max-height: 88vh;
    overflow-y: auto;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-header h3 { font-size: 17px; font-weight: 800; }
.modal-close { cursor: pointer; color: var(--text-faint); font-size: 20px; background: none; border: none; }

.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
    background: var(--text);
    color: #fff;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 600;
    box-shadow: var(--shadow-md);
    animation: slideIn .2s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.spinner {
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .6s linear infinite;
}
.spinner-dark { border: 2px solid var(--border); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

.text-muted { color: var(--text-muted); }
.mt-8 { margin-top: 8px; } .mt-14 { margin-top: 14px; } .mt-20 { margin-top: 20px; } .mt-26 { margin-top: 26px; }
.mb-14 { margin-bottom: 14px; } .mb-20 { margin-bottom: 20px; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-14 { gap: 14px; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-md); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; width: 100%; padding: 20px 18px 50px; }
    .mobile-toggle { display: flex; }
    .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .auth-card { padding: 30px 22px; }
}
