/* ============================================================
   Social Media Manager — Design System
   ============================================================ */

:root {
  /* Brand */
  --brand-50: #eef2ff;
  --brand-100: #e0e7ff;
  --brand-200: #c7d2fe;
  --brand-300: #a5b4fc;
  --brand-400: #818cf8;
  --brand-500: #6366f1;
  --brand-600: #4f46e5;
  --brand-700: #4338ca;
  --violet-500: #8b5cf6;
  --pink-500: #ec4899;
  --fb: #1877f2;
  --fb-dark: #0f65d0;

  /* Semantic */
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --info: #0ea5e9;
  --info-bg: #f0f9ff;

  /* Surfaces */
  --bg: #f6f7fb;
  --bg-2: #eef0f6;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --glass: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.55);
  --border: #e6e8f0;
  --border-2: #d8dbe6;

  /* Text */
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --text-invert: #ffffff;

  /* Effects */
  --grad-brand: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #a855f7 100%);
  --grad-hero: linear-gradient(135deg, #4f46e5, #7c3aed 45%, #db2777);
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.14);
  --shadow-brand: 0 10px 30px rgba(99, 102, 241, 0.35);

  /* Shape & motion */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 0.18s var(--ease);
  --t-med: 0.35s var(--ease);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  --bg: #0b0e17;
  --bg-2: #11151f;
  --surface: #151a26;
  --surface-2: #1a2030;
  --glass: rgba(21, 26, 38, 0.72);
  --glass-border: rgba(255, 255, 255, 0.08);
  --border: #232a3b;
  --border-2: #2e3650;
  --text: #f1f5f9;
  --text-2: #a9b4c9;
  --text-3: #64748b;
  --success-bg: rgba(16, 185, 129, 0.12);
  --warning-bg: rgba(245, 158, 11, 0.12);
  --danger-bg: rgba(239, 68, 68, 0.12);
  --info-bg: rgba(14, 165, 233, 0.12);
  --brand-50: rgba(99, 102, 241, 0.12);
  --brand-100: rgba(99, 102, 241, 0.2);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.6);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
::selection { background: var(--brand-200); color: var(--brand-700); }

h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -0.02em; font-weight: 700; }

.lucide { width: 18px; height: 18px; flex: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--r-sm);
  font-weight: 600; font-size: 14px; line-height: 1.2;
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast), border-color var(--t-fast), color var(--t-fast), opacity var(--t-fast);
  position: relative; overflow: hidden; white-space: nowrap;
  border: 1px solid transparent;
}
.btn:active { transform: scale(0.97); }
.btn .lucide { width: 16px; height: 16px; }

.btn-primary { background: var(--grad-brand); color: #fff; box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-brand); }
.btn-outline { border-color: var(--border-2); background: var(--surface); color: var(--text); }
.btn-outline:hover { border-color: var(--brand-400); color: var(--brand-500); background: var(--brand-50); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-2); color: var(--text); }
.btn-soft { background: var(--brand-50); color: var(--brand-600); }
.btn-soft:hover { background: var(--brand-100); }
.btn-danger-soft { background: var(--danger-bg); color: var(--danger); }
.btn-danger-soft:hover { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-fb { background: var(--fb); color: #fff; box-shadow: 0 4px 14px rgba(24, 119, 242, 0.35); }
.btn-fb:hover { background: var(--fb-dark); transform: translateY(-1px); }
.btn-lg { padding: 14px 26px; font-size: 15.5px; border-radius: var(--r-md); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.55; pointer-events: none; }

/* Ripple */
.ripple-ink {
  position: absolute; border-radius: 50%; transform: scale(0);
  background: rgba(255, 255, 255, 0.45); pointer-events: none;
  animation: ripple 0.55s ease-out forwards;
}
.btn-outline .ripple-ink, .btn-ghost .ripple-ink { background: rgba(99, 102, 241, 0.18); }
@keyframes ripple { to { transform: scale(3.2); opacity: 0; } }

/* Icon button */
.icon-btn {
  width: 38px; height: 38px; border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-2); transition: all var(--t-fast); position: relative; flex: none;
}
.icon-btn:hover { background: var(--bg-2); color: var(--text); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  transition: transform var(--t-med), box-shadow var(--t-med), border-color var(--t-med);
}
.card-hover:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--border-2); }
.card-pad { padding: 22px; }
.glass {
  background: var(--glass); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--glass-border);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-title { font-size: 15.5px; font-weight: 700; }
.card-sub { font-size: 13px; color: var(--text-3); margin-top: 2px; font-weight: 400; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.6; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: #b45309; }
[data-theme="dark"] .badge-warning { color: #fbbf24; }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-brand { background: var(--brand-50); color: var(--brand-600); }
[data-theme="dark"] .badge-brand { color: var(--brand-300); }
.badge-neutral { background: var(--bg-2); color: var(--text-2); }
.badge-ai {
  background: linear-gradient(135deg, rgba(99,102,241,.14), rgba(168,85,247,.14));
  color: var(--brand-600);
}
[data-theme="dark"] .badge-ai { color: var(--brand-300); }

/* ---------- Forms ---------- */
.field { margin-bottom: 18px; }
.label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
.input, .select, .textarea {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text); font-size: 14px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  outline: none;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand-400); box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.textarea { resize: vertical; min-height: 110px; line-height: 1.6; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 38px;
}
.input-icon { position: relative; }
.input-icon .lucide { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.input-icon .input { padding-left: 40px; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px; cursor: pointer;
  background: var(--border-2); transition: background var(--t-fast);
}
.switch .track::before {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  left: 3px; top: 3px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform var(--t-fast);
}
.switch input:checked + .track { background: var(--brand-500); }
.switch input:checked + .track::before { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 4px rgba(99,102,241,0.2); }

/* Segmented control / chips */
.seg { display: inline-flex; gap: 4px; background: var(--bg-2); padding: 4px; border-radius: var(--r-sm); flex-wrap: wrap; }
.seg button {
  padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 600;
  color: var(--text-2); transition: all var(--t-fast);
}
.seg button.active { background: var(--surface); color: var(--brand-600); box-shadow: var(--shadow-xs); }
[data-theme="dark"] .seg button.active { color: var(--brand-300); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px;
  border: 1.5px solid var(--border); border-radius: 999px; font-size: 13px; font-weight: 600;
  color: var(--text-2); cursor: pointer; transition: all var(--t-fast); background: var(--surface);
}
.chip:hover { border-color: var(--brand-300); color: var(--brand-500); }
.chip.active { background: var(--brand-50); border-color: var(--brand-400); color: var(--brand-600); }
[data-theme="dark"] .chip.active { color: var(--brand-300); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
.table th {
  text-align: left; padding: 12px 18px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3);
  border-bottom: 1px solid var(--border); background: var(--surface-2);
  white-space: nowrap;
}
.table td { padding: 14px 18px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }

/* ---------- Avatars ---------- */
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px; letter-spacing: 0.02em;
  background: var(--grad-brand); user-select: none;
}
.avatar-sm { width: 30px; height: 30px; font-size: 12px; }
.avatar-lg { width: 56px; height: 56px; font-size: 20px; border-radius: var(--r-md); }
.avatar-xl { width: 80px; height: 80px; font-size: 28px; border-radius: var(--r-lg); }

/* ---------- Dropdown menu ---------- */
.menu-wrap { position: relative; }
.menu {
  position: absolute; top: calc(100% + 8px); right: 0; min-width: 200px; z-index: 60;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg); padding: 6px;
  opacity: 0; transform: translateY(-6px) scale(0.98); pointer-events: none;
  transition: opacity var(--t-fast), transform var(--t-fast);
}
.menu.open { opacity: 1; transform: none; pointer-events: auto; }
.menu a, .menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; border-radius: 8px; font-size: 13.5px; font-weight: 500;
  color: var(--text-2); transition: all var(--t-fast); text-align: left;
}
.menu a:hover, .menu button:hover { background: var(--bg-2); color: var(--text); }
.menu .danger { color: var(--danger); }
.menu .danger:hover { background: var(--danger-bg); color: var(--danger); }
.menu hr { border: none; border-top: 1px solid var(--border); margin: 6px 4px; }
.menu .lucide { width: 15px; height: 15px; }

/* ---------- Tooltip ---------- */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%) translateY(4px);
  background: var(--text); color: var(--bg); font-size: 11.5px; font-weight: 600;
  padding: 5px 10px; border-radius: 7px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: all var(--t-fast); z-index: 80;
}
[data-tip]:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(9, 12, 24, 0.55); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface); border-radius: var(--r-xl); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto;
  transform: translateY(16px) scale(0.97); transition: transform 0.3s var(--ease);
}
.modal-overlay.open .modal { transform: none; }
.modal-lg { max-width: 760px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 0;
}
.modal-body { padding: 20px 24px 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 24px 24px; }

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed; bottom: 24px; right: 24px; z-index: 200;
  display: flex; flex-direction: column; gap: 10px; max-width: 360px;
}
.toast {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  padding: 14px 16px; animation: toastIn 0.4s var(--ease);
  min-width: 280px;
}
.toast.hide { animation: toastOut 0.3s ease forwards; }
.toast-icon {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  display: flex; align-items: center; justify-content: center;
}
.toast-icon .lucide { width: 16px; height: 16px; }
.toast-success .toast-icon { background: var(--success-bg); color: var(--success); }
.toast-info .toast-icon { background: var(--info-bg); color: var(--info); }
.toast-error .toast-icon { background: var(--danger-bg); color: var(--danger); }
.toast-ai .toast-icon { background: var(--brand-50); color: var(--brand-500); }
.toast strong { display: block; font-size: 13.5px; }
.toast span { font-size: 12.5px; color: var(--text-3); }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(40px); } }

/* ---------- Skeletons ---------- */
.skel {
  position: relative; overflow: hidden; background: var(--bg-2); border-radius: 8px;
}
.skel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.55), transparent);
  transform: translateX(-100%); animation: shimmer 1.4s infinite;
}
[data-theme="dark"] .skel::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,0.07), transparent); }
@keyframes shimmer { to { transform: translateX(100%); } }

/* ---------- Empty state ---------- */
.empty {
  text-align: center; padding: 56px 24px; color: var(--text-3);
}
.empty-art {
  width: 88px; height: 88px; margin: 0 auto 18px; border-radius: 28px;
  background: var(--grad-brand); opacity: 0.9;
  display: flex; align-items: center; justify-content: center; color: #fff;
  box-shadow: var(--shadow-brand); animation: floaty 4s ease-in-out infinite;
}
.empty-art .lucide { width: 36px; height: 36px; }
.empty h3 { color: var(--text); margin-bottom: 6px; font-size: 17px; }
.empty p { max-width: 340px; margin: 0 auto 18px; font-size: 13.5px; }

/* ---------- Success check ---------- */
.check-pop {
  width: 96px; height: 96px; border-radius: 50%; margin: 0 auto;
  background: var(--success-bg); display: flex; align-items: center; justify-content: center;
  animation: popIn 0.5s var(--ease);
}
.check-pop svg { width: 52px; height: 52px; }
.check-pop .ring { stroke: var(--success); stroke-width: 2.4; fill: none; stroke-dasharray: 160; stroke-dashoffset: 160; animation: draw 0.7s 0.15s var(--ease) forwards; }
.check-pop .tick { stroke: var(--success); stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw 0.45s 0.65s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes popIn { from { transform: scale(0.4); opacity: 0; } }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; gap: 6px; justify-content: flex-end; padding: 14px 18px; flex-wrap: wrap; }
.pagination button {
  min-width: 34px; height: 34px; padding: 0 8px; border-radius: 9px;
  font-size: 13px; font-weight: 600; color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center;
  transition: all var(--t-fast); border: 1px solid transparent;
}
.pagination button:hover:not([disabled]) { background: var(--bg-2); }
.pagination button.active { background: var(--brand-500); color: #fff; box-shadow: 0 3px 10px rgba(99,102,241,0.35); }
.pagination button[disabled] { opacity: 0.4; cursor: default; }
.page-info { font-size: 13px; color: var(--text-3); margin-right: auto; }

/* ---------- Breadcrumbs ---------- */
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-3); flex-wrap: wrap; }
.crumbs a:hover { color: var(--brand-500); }
.crumbs .sep { opacity: 0.5; }
.crumbs .current { color: var(--text); font-weight: 600; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button {
  padding: 11px 18px; font-size: 13.5px; font-weight: 600; color: var(--text-3);
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all var(--t-fast);
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--brand-600); border-bottom-color: var(--brand-500); }
[data-theme="dark"] .tabs button.active { color: var(--brand-300); }

/* ---------- Progress ---------- */
.progress { height: 7px; border-radius: 999px; background: var(--bg-2); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--grad-brand); transition: width 0.8s var(--ease); }

/* ---------- Reveal animations ---------- */
.reveal { opacity: 0; transform: translateY(22px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
.reveal-d1 { transition-delay: 0.08s; } .reveal-d2 { transition-delay: 0.16s; }
.reveal-d3 { transition-delay: 0.24s; } .reveal-d4 { transition-delay: 0.32s; }

@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.45); }
  50% { box-shadow: 0 0 0 12px rgba(99, 102, 241, 0); }
}
.fade-up { animation: fadeUp 0.5s var(--ease) both; }

/* ---------- Utilities ---------- */
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.muted { color: var(--text-3); } .small { font-size: 13px; }
.text-success { color: var(--success); } .text-danger { color: var(--danger); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grad-text {
  background: var(--grad-hero); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.hide-sm { display: initial; }
@media (max-width: 640px) { .hide-sm { display: none !important; } }

/* Scrollbar */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
::-webkit-scrollbar-track { background: transparent; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
