/* ══════════════════════════════════════════
   SocialAI Platform Styles
   ══════════════════════════════════════════ */

:root {
  --bg-primary: #0c0f14;
  --bg-secondary: #13161d;
  --bg-card: #1a1e27;
  --bg-card-hover: #1f2430;
  --bg-input: #151922;
  --border: #2a2f3a;
  --border-focus: #4f8cff;

  --text-primary: #e8eaf0;
  --text-secondary: #8b92a5;
  --text-muted: #5a6175;

  --accent: #4f8cff;
  --accent-hover: #3d7aee;
  --accent-glow: rgba(79, 140, 255, 0.15);
  --success: #34c77b;
  --warning: #f5a623;
  --danger: #ef4444;
  --info: #38bdf8;

  --facebook: #1877f2;
  --instagram: #e4405f;
  --twitter: #1da1f2;
  --linkedin: #0a66c2;

  --sidebar-width: 250px;
  --sidebar-collapsed: 64px;
  --radius: 10px;
  --radius-sm: 6px;
  --transition: 0.2s ease;

  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

html { font-size: 15px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width var(--transition);
  overflow: hidden;
}

.sidebar-header {
  padding: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text-primary);
}
.sidebar-logo i { color: var(--accent); font-size: 1.3rem; }

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  display: none;
}
.sidebar-toggle:hover { color: var(--text-primary); background: var(--bg-card); }

.sidebar-nav {
  flex: 1;
  padding: 0.8rem 0.6rem;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
}
.nav-item:hover { color: var(--text-primary); background: var(--bg-card); }
.nav-item.active { color: var(--accent); background: var(--accent-glow); }
.nav-item i { width: 20px; text-align: center; font-size: 0.95rem; }
.nav-item.nav-ai { color: var(--success); }
.nav-item.nav-ai.active { color: var(--success); background: rgba(52, 199, 123, 0.12); }

.nav-divider { height: 1px; background: var(--border); margin: 0.6rem 0.8rem; }

.sidebar-footer {
  padding: 0.8rem;
  border-top: 1px solid var(--border);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem;
  margin-bottom: 0.3rem;
}
.user-avatar {
  width: 34px; height: 34px;
  background: var(--accent-glow);
  color: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-plan { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

.logout-link { color: var(--text-muted) !important; font-size: 0.85rem; }
.logout-link:hover { color: var(--danger) !important; }

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 2rem;
  min-height: 100vh;
}
.main-public {
  min-height: 100vh;
}

/* ── Page Headers ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.page-header h1 { font-size: 1.6rem; font-weight: 700; }
.page-header-actions { display: flex; gap: 0.6rem; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: border-color var(--transition);
}
.card:hover { border-color: rgba(79, 140, 255, 0.25); }
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.card-header h2 { font-size: 1.1rem; font-weight: 600; }
.card-header h3 { font-size: 1rem; font-weight: 600; }

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
}
.stat-card .stat-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.3rem; }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-card .stat-icon { font-size: 1.5rem; color: var(--accent); margin-bottom: 0.5rem; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #2db56c; color: #fff; }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-lg { padding: 0.8rem 2rem; font-size: 1rem; }
.btn-icon { padding: 0.5rem; width: 36px; height: 36px; justify-content: center; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-card); }

/* ── Forms ── */
.form-group { margin-bottom: 1.2rem; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}
.form-control {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  transition: border-color var(--transition);
}
.form-control:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-glow); }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-help { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.3rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b92a5' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  padding-right: 2.2rem;
}

/* ── Alerts ── */
.alert {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 1.2rem;
  animation: slideDown 0.3s ease;
}
.alert-success { background: rgba(52, 199, 123, 0.1); border: 1px solid rgba(52, 199, 123, 0.25); color: var(--success); }
.alert-error { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.25); color: var(--danger); }
.alert-info { background: rgba(56, 189, 248, 0.1); border: 1px solid rgba(56, 189, 248, 0.25); color: var(--info); }

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; text-align: left; padding: 0.7rem 0.8rem; border-bottom: 1px solid var(--border); }
td { padding: 0.8rem; border-bottom: 1px solid rgba(42, 47, 58, 0.5); font-size: 0.88rem; vertical-align: middle; }
tr:hover td { background: rgba(79, 140, 255, 0.03); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-draft { background: rgba(90, 97, 117, 0.2); color: var(--text-muted); }
.badge-scheduled { background: rgba(79, 140, 255, 0.15); color: var(--accent); }
.badge-published { background: rgba(52, 199, 123, 0.15); color: var(--success); }
.badge-failed { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-pending { background: rgba(245, 166, 35, 0.15); color: var(--warning); }
.badge-active { background: rgba(52, 199, 123, 0.15); color: var(--success); }

.platform-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  font-weight: 600;
}
.platform-badge.facebook { color: var(--facebook); }
.platform-badge.instagram { color: var(--instagram); }
.platform-badge.twitter { color: var(--twitter); }
.platform-badge.linkedin { color: var(--linkedin); }

/* ── Chat Interface ── */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 8rem);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}
.chat-message {
  display: flex;
  gap: 0.8rem;
  margin-bottom: 1.2rem;
  animation: fadeIn 0.3s ease;
}
.chat-message.user { flex-direction: row-reverse; }
.chat-bubble {
  max-width: 75%;
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.55;
}
.chat-message.user .chat-bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 2px; }
.chat-message.assistant .chat-bubble { background: var(--bg-secondary); border: 1px solid var(--border); border-bottom-left-radius: 2px; }
.chat-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  flex-shrink: 0;
}
.chat-message.user .chat-avatar { background: var(--accent-glow); color: var(--accent); }
.chat-message.assistant .chat-avatar { background: rgba(52, 199, 123, 0.12); color: var(--success); }

.chat-input-area {
  padding: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.6rem;
}
.chat-input-area input {
  flex: 1;
  padding: 0.7rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
}
.chat-input-area input:focus { outline: none; border-color: var(--border-focus); }

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

/* ── Grid Layouts ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }

/* ── Empty States ── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state i { font-size: 2.5rem; margin-bottom: 1rem; color: var(--text-muted); }
.empty-state h3 { font-size: 1.1rem; color: var(--text-secondary); margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.88rem; margin-bottom: 1.2rem; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); width: 260px; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: block; }
  .main-content { margin-left: 0; padding: 1rem; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .page-header { flex-direction: column; align-items: flex-start; }

  /* Mobile header bar */
  .mobile-header {
    display: flex;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    align-items: center;
    padding: 0 1rem;
    z-index: 99;
  }
  .main-content { padding-top: 72px; }
}

@media (min-width: 769px) {
  .mobile-header { display: none; }
}
