/* ============================================================
   FB Auto Responder — Main Stylesheet
   ============================================================ */

/* ── CSS Variables ──────────────────────────────────────────── */
:root {
  --primary:        #4F46E5;
  --primary-dark:   #3730A3;
  --primary-light:  #EEF2FF;
  --success:        #10B981;
  --error:          #EF4444;
  --warning:        #F59E0B;
  --info:           #3B82F6;

  --sidebar-bg:     #1E1B4B;
  --sidebar-w:      260px;

  --bg:             #F1F5F9;
  --surface:        #FFFFFF;
  --border:         #E2E8F0;
  --text:           #1E293B;
  --text-muted:     #64748B;
  --text-faint:     #94A3B8;

  --radius:         12px;
  --radius-sm:      8px;
  --radius-xs:      6px;
  --shadow:         0 1px 3px rgba(0,0,0,.07), 0 4px 8px rgba(0,0,0,.04);
  --shadow-lg:      0 10px 30px rgba(0,0,0,.12);
  --transition:     all .2s ease;
  --topbar-h:       64px;
}

[data-theme="dark"] {
  --bg:             #0F172A;
  --surface:        #1E293B;
  --border:         #334155;
  --text:           #F1F5F9;
  --text-muted:     #94A3B8;
  --text-faint:     #475569;
  --primary-light:  rgba(79,70,229,.15);
}

/* ── Reset ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button { font-family: inherit; }

/* ── Layout ───────────────────────────────────────────────────── */
.app-layout  { display: flex; min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: #fff;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 200;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}

.sidebar-header {
  padding: 1.4rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.sidebar-logo i { font-size: 1.6rem; color: #60A5FA; }

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: rgba(255,255,255,.5);
  font-size: 1.1rem;
  cursor: pointer;
  padding: .3rem;
  border-radius: var(--radius-xs);
  transition: var(--transition);
}
.sidebar-close:hover { color: #fff; }

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .78rem 1.5rem;
  color: rgba(255,255,255,.6);
  font-size: .875rem;
  font-weight: 500;
  transition: var(--transition);
  border-left: 3px solid transparent;
  text-decoration: none;
}
.nav-item:hover  { color: #fff; background: rgba(255,255,255,.06); text-decoration: none; }
.nav-item.active {
  color: #fff;
  background: rgba(99,102,241,.25);
  border-left-color: #818CF8;
}
.nav-item i { width: 1.1rem; text-align: center; font-size: .9rem; opacity: .85; }
.nav-item.active i { opacity: 1; }

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  flex-direction: column;
  gap: .6rem;
  flex-shrink: 0;
}
.api-status {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .78rem;
  color: rgba(255,255,255,.45);
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #6B7280;
  flex-shrink: 0;
  transition: background .4s;
}
.status-dot.online  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { background: var(--error); }

.logout-btn {
  display: flex;
  align-items: center;
  gap: .6rem;
  color: rgba(255,255,255,.5);
  font-size: .85rem;
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition);
  padding: .3rem 0;
}
.logout-btn:hover { color: #fff; text-decoration: none; }

/* ── Main wrapper ─────────────────────────────────────────────── */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* ── Topbar ───────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.15rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: .4rem;
  border-radius: var(--radius-xs);
  transition: var(--transition);
}
.menu-btn:hover { color: var(--text); }
.topbar-title { font-size: 1.05rem; font-weight: 600; flex: 1; }
.topbar-actions { display: flex; gap: .6rem; align-items: center; }
.theme-toggle {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: .45rem .65rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
  font-size: .85rem;
}
.theme-toggle:hover { color: var(--primary); border-color: var(--primary); }

/* ── Main content ─────────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 1.75rem;
  max-width: 1260px;
  width: 100%;
}

/* ── Stats Grid ───────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  box-shadow: var(--shadow);
  transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.stat-icon.blue   { background: #DBEAFE; color: #2563EB; }
.stat-icon.green  { background: #D1FAE5; color: #059669; }
.stat-icon.purple { background: #EDE9FE; color: #7C3AED; }
.stat-icon.orange { background: #FEF3C7; color: #D97706; }
.stat-icon.red    { background: #FEE2E2; color: #DC2626; }
.stat-value {
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.02em;
}
.stat-label {
  font-size: .8rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: .15rem;
}

/* ── Card ─────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 1.25rem;
}
.card-header {
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.card-title { font-size: .95rem; font-weight: 600; display: flex; align-items: center; gap: .5rem; }
.card-body  { padding: 1.5rem; }

/* ── Table ────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  text-align: left;
  padding: .8rem 1rem;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
  background: var(--bg);
}
tbody td {
  padding: .9rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg); }

/* ── Badges ───────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .22rem .65rem;
  border-radius: 100px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge-success { background: #D1FAE5; color: #065F46; }
.badge-error   { background: #FEE2E2; color: #991B1B; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-info    { background: #DBEAFE; color: #1E40AF; }
.badge-neutral { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
.badge-purple  { background: #EDE9FE; color: #5B21B6; }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .58rem 1.15rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
  font-family: inherit;
}
.btn:hover { text-decoration: none; }
.btn-primary   { background: var(--primary);  color: #fff; }
.btn-primary:hover   { background: var(--primary-dark); }
.btn-success   { background: var(--success);  color: #fff; }
.btn-success:hover   { background: #059669; }
.btn-danger    { background: var(--error);    color: #fff; }
.btn-danger:hover    { background: #DC2626; }
.btn-warning   { background: var(--warning);  color: #fff; }
.btn-warning:hover   { background: #D97706; }
.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost     { background: transparent; color: var(--text-muted); border: none; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm    { padding: .38rem .85rem; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; padding: .72rem; }
.btn-icon  { width: 34px; height: 34px; padding: 0; justify-content: center; border-radius: var(--radius-sm); }
.btn:disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }

/* ── Forms ────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.2rem; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: .35rem;
}
.label-hint {
  font-size: .75rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: .3rem;
}
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: .62rem .95rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: .875rem;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
textarea { min-height: 90px; resize: vertical; }
select { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right .6rem center; background-size: 1.2em; padding-right: 2.2rem; }

.input-icon { position: relative; }
.input-icon i {
  position: absolute;
  left: .9rem; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: .875rem;
  pointer-events: none;
}
.input-icon input { padding-left: 2.5rem; }

.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: .3rem; }

/* Toggle switch */
.toggle-group { display: flex; align-items: flex-start; gap: .85rem; }
.toggle-group label { margin-bottom: 0; font-weight: 500; cursor: pointer; line-height: 1.4; }
.toggle { position: relative; width: 42px; height: 23px; flex-shrink: 0; margin-top: .1rem; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: #CBD5E1;
  border-radius: 23px;
  cursor: pointer;
  transition: .2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 17px; height: 17px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(19px); }

/* ── Alerts ───────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem 1.15rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  margin-bottom: 1.25rem;
}
.alert-success { background: #D1FAE5; color: #065F46; border: 1px solid #A7F3D0; }
.alert-error   { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.alert-warning { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; }
.alert-info    { background: #DBEAFE; color: #1E40AF; border: 1px solid #BFDBFE; }
.alert-close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  opacity: .6;
  color: inherit;
  padding: .2rem;
  line-height: 1;
}
.alert-close:hover { opacity: 1; }

/* ── Modal ────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(2px);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s, visibility .2s;
}
.modal-backdrop.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 620px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(.95) translateY(12px);
  transition: transform .2s;
}
.modal-backdrop.open .modal { transform: scale(1) translateY(0); }
.modal-header {
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.modal-title  { font-size: 1rem; font-weight: 700; }
.modal-close  { background: none; border: none; color: var(--text-muted); font-size: 1.1rem; cursor: pointer; padding: .2rem; border-radius: var(--radius-xs); transition: var(--transition); }
.modal-close:hover { color: var(--text); background: var(--bg); }
.modal-body   { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
}

/* ── Pagination ───────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  padding: 1rem 0;
}
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px; height: 34px;
  padding: 0 .5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .82rem;
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition);
  background: var(--surface);
}
.page-btn:hover         { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.page-btn.active        { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn.disabled      { opacity: .4; pointer-events: none; }

/* ── Empty state ──────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3.5rem 2rem;
  color: var(--text-muted);
}
.empty-state i   { font-size: 2.75rem; margin-bottom: 1rem; opacity: .35; display: block; }
.empty-state h3  { font-size: 1.05rem; margin-bottom: .4rem; color: var(--text); }
.empty-state p   { font-size: .875rem; }

/* ── Auth pages ───────────────────────────────────────────────── */
.auth-body, .setup-body {
  background: linear-gradient(135deg, #1E1B4B 0%, #4338CA 50%, #7C3AED 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}
.auth-card, .setup-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.setup-card { max-width: 520px; }
.auth-logo {
  width: 60px; height: 60px;
  background: linear-gradient(135deg, #1877F2, #0C5FD4);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: #fff;
  margin: 0 auto 1.25rem;
  box-shadow: 0 4px 12px rgba(24,119,242,.4);
}
.auth-title    { font-size: 1.4rem; font-weight: 700; text-align: center; margin-bottom: .25rem; letter-spacing: -.02em; }
.auth-subtitle { color: var(--text-muted); text-align: center; font-size: .875rem; margin-bottom: 1.75rem; }
.auth-form     { display: flex; flex-direction: column; gap: 1rem; }

/* Setup steps progress */
.setup-steps  { display: flex; gap: .4rem; margin-bottom: 2rem; }
.setup-step   { flex: 1; height: 4px; background: var(--border); border-radius: 4px; transition: background .3s; }
.setup-step.active { background: var(--primary); }

/* ── Toolbar ──────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: .6rem; }

/* ── Filter bar ───────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.filter-bar input,
.filter-bar select { max-width: 200px; }

/* ── Post card (alternative card view) ───────────────────────── */
.post-meta { font-size: .78rem; color: var(--text-muted); margin-top: .2rem; }
.post-id   { font-family: 'Courier New', monospace; font-size: .82rem; color: var(--text-muted); background: var(--bg); padding: .15rem .5rem; border-radius: var(--radius-xs); border: 1px solid var(--border); }

/* ── Action icons in table ────────────────────────────────────── */
.action-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  flex-shrink: 0;
}
.action-icon.like   { background: #DBEAFE; color: #2563EB; }
.action-icon.reply  { background: #D1FAE5; color: #059669; }
.action-icon.dm     { background: #EDE9FE; color: #7C3AED; }
.action-icon.error  { background: #FEE2E2; color: #DC2626; }
.action-icon.info   { background: #FEF3C7; color: #D97706; }

/* ── Overlay ──────────────────────────────────────────────────── */
.overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 150;
}
.overlay.show { display: block; }

/* ── Section heading ──────────────────────────────────────────── */
.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1rem;
  padding-bottom: .6rem;
  border-bottom: 2px solid var(--primary-light);
}

/* ── Utility ──────────────────────────────────────────────────── */
.text-muted   { color: var(--text-muted) !important; }
.text-success { color: var(--success) !important; }
.text-error   { color: var(--error)   !important; }
.text-primary { color: var(--primary) !important; }
.font-mono    { font-family: 'Courier New', monospace; font-size: .85em; }
.truncate     { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 240px; display: inline-block; vertical-align: middle; }
.flex-center  { display: flex; align-items: center; gap: .5rem; }
.d-flex       { display: flex; }
.align-center { align-items: center; }
.gap-1        { gap: .25rem; }
.gap-2        { gap: .5rem; }
.gap-3        { gap: .75rem; }
.mb-0         { margin-bottom: 0 !important; }
.mb-1         { margin-bottom: .5rem !important; }
.mt-1         { margin-top: 1rem !important; }
.w-full       { width: 100%; }
.separator    { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* ── Animations ───────────────────────────────────────────────── */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0);   }
}
.fade-in { animation: fadeSlideIn .3s ease both; }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }
.loading { animation: pulse 1.4s infinite; }

/* ── Scrollbar ────────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar             { transform: translateX(-100%); }
  .sidebar.open        { transform: translateX(0); }
  .sidebar-close       { display: block; }
  .menu-btn            { display: flex; }
  .main-wrapper        { margin-left: 0; }
  .main-content        { padding: 1rem; }
  .stats-grid          { grid-template-columns: repeat(2, 1fr); }
  .form-row            { grid-template-columns: 1fr; }
  thead th:nth-child(n+5),
  tbody td:nth-child(n+5) { display: none; }
}
@media (max-width: 480px) {
  .stats-grid  { grid-template-columns: 1fr 1fr; }
  .toolbar     { flex-direction: column; align-items: stretch; }
  .toolbar-right { justify-content: flex-end; }
  .filter-bar input,
  .filter-bar select { max-width: 100%; width: 100%; }
}
