/* ─── XPoster App Styles ────────────────────────────────────────────────────
   Brand: Indigo/violet accent — NOT Twitter blue. Zain font. Clean & airy.
   ─────────────────────────────────────────────────────────────────────────── */

:root {
  /* Brand — indigo, not Twitter blue */
  --accent:       #5b5ef4;
  --accent-dark:  #4547d4;
  --accent-light: #f0f0ff;
  --accent-soft:  #d8d8fd;

  /* Neutrals */
  --bg:           #f5f6f8;
  --surface:      #ffffff;
  --border:       #e4e6ea;
  --text:         #111318;
  --text-muted:   #6b7280;
  --text-light:   #b0b8c4;

  /* Status */
  --green:        #16a34a;
  --red:          #dc2626;

  /* Layout */
  --sidebar-w:    250px;
  --right-w:      290px;
  --radius:       16px;
  --radius-sm:    10px;
  --shadow:       0 2px 12px rgba(0,0,0,.06);
  --shadow-md:    0 6px 28px rgba(91,94,244,.18);
  --transition:   all .2s cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Zain', -apple-system, sans-serif;
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  line-height: 1.5;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-logo {
  font-size: 30px;
  color: var(--accent);
  padding: 8px 14px 22px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 17px;
  font-weight: 400;
  transition: var(--transition);
}
.nav-item:hover  { background: var(--accent-light); color: var(--accent); }
.nav-item.active { color: var(--accent); font-weight: 700; background: var(--accent-light); }
.nav-item i { width: 20px; text-align: center; font-size: 18px; }

.sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.sidebar-legal {
  display: flex !important;
  align-items: center;
  gap: 10px;
  padding: 9px 16px !important;
  border-radius: 999px;
  font-size: 14px !important;
  color: var(--text-muted) !important;
  text-decoration: none !important;
  cursor: pointer;
  transition: var(--transition);
  background: none;
  border: none;
  font-family: 'Zain', sans-serif;
  width: 100%;
  text-align: left;
}
.sidebar-legal:hover { background: var(--accent-light); color: var(--accent) !important; }
.sidebar-legal i { width: 20px; text-align: center; }

.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 14px;
  margin-top: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.profile-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent-soft);
}

.profile-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.profile-name  { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-handle { font-size: 12px; color: var(--text-muted); }

.logout-btn {
  color: var(--text-muted);
  font-size: 14px;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  transition: var(--transition);
  text-decoration: none;
}
.logout-btn:hover { background: #fee2e2; color: var(--red); }

/* ─── Main ───────────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  max-width: 640px;
  min-width: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding-bottom: 60px;
}

/* ─── Topbar ─────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-icon { font-size: 22px; color: var(--accent); }
.topbar-title { font-size: 20px; font-weight: 900; color: var(--text); letter-spacing: -.4px; }
.topbar-sub   { font-size: 13px; color: var(--text-muted); }

/* ─── Setup Guide ────────────────────────────────────────────────────────── */
.setup-guide {
  margin: 20px;
  border: 1.5px solid #fbbf24;
  border-radius: var(--radius);
  background: #fffbeb;
  overflow: hidden;
}

.setup-guide-header {
  background: #fef3c7;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  color: #92400e;
  border-bottom: 1px solid #fde68a;
}

.setup-guide-header i { font-size: 18px; color: #f59e0b; }

.setup-steps {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.setup-step {
  display: flex;
  gap: 14px;
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.step-body strong { font-size: 15px; display: block; margin-bottom: 4px; color: var(--text); }
.step-body p      { font-size: 14px; color: var(--text-muted); margin-bottom: 4px; line-height: 1.5; }
.step-body a      { color: var(--accent); text-decoration: underline; }

.step-body code {
  display: inline-block;
  background: white;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 13px;
  font-family: monospace;
  color: #92400e;
  margin: 4px 0;
}

.step-body pre {
  background: white;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  font-family: monospace;
  color: #374151;
  margin: 6px 0;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.8;
}

/* ─── Alerts ─────────────────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
  animation: slideDown .3s ease;
}
.alert-error   { background: #fef2f2; color: var(--red); }
.alert-success { background: #f0fdf4; color: var(--green); }

.alert-close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  opacity: .6;
  color: inherit;
  font-size: 14px;
  padding: 4px;
}
.alert-close:hover { opacity: 1; }

/* ─── Connect Banner ─────────────────────────────────────────────────────── */
.connect-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: linear-gradient(135deg, var(--accent-light) 0%, #f8f7ff 100%);
  border-bottom: 1px solid var(--accent-soft);
}

.connect-banner-icon { font-size: 30px; color: var(--accent); flex-shrink: 0; }
.connect-banner-text { flex: 1; }
.connect-banner-text h3 { font-size: 16px; font-weight: 700; margin-bottom: 3px; }
.connect-banner-text p  { font-size: 14px; color: var(--text-muted); }

/* ─── User Card ──────────────────────────────────────────────────────────── */
.user-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--accent-light);
}

.user-card-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  border: 2.5px solid var(--accent);
}

.user-card-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.user-card-info strong { font-size: 16px; font-weight: 700; }
.user-card-info span   { font-size: 13px; color: var(--text-muted); }

.user-card-stats {
  display: flex;
  gap: 14px;
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-muted);
}
.user-card-stats strong { color: var(--text); }

.user-card-connected {
  font-size: 13px;
  color: var(--green);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ─── Composer ───────────────────────────────────────────────────────────── */
.composer-card {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
}

.composer-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  color: var(--accent);
}
.composer-header i  { font-size: 18px; }
.composer-header h2 { font-size: 20px; font-weight: 800; color: var(--text); }

.prefs-grid { display: flex; flex-direction: column; gap: 16px; margin-bottom: 20px; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.field-group { display: flex; flex-direction: column; gap: 6px; }

.field-group label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.field-group input[type="text"] {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-family: 'Zain', sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  transition: var(--transition);
  outline: none;
  width: 100%;
}
.field-group input[type="text"]:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(91,94,244,.12);
}

.select-wrap { position: relative; }

.select-wrap select {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 34px 11px 14px;
  font-family: 'Zain', sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  appearance: none;
  cursor: pointer;
  outline: none;
  transition: var(--transition);
}
.select-wrap select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91,94,244,.12);
}
.select-wrap i {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-muted);
  font-size: 12px;
}

.toggle-row { display: flex; gap: 20px; flex-wrap: wrap; }

.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle input { display: none; }

.toggle-slider {
  width: 40px;
  height: 22px;
  background: var(--text-light);
  border-radius: 999px;
  position: relative;
  transition: var(--transition);
  flex-shrink: 0;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::after { transform: translateX(18px); }

.toggle-label { font-size: 15px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; user-select: none; }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 999px;
  font-family: 'Zain', sans-serif;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: var(--transition);
  white-space: nowrap;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-dark);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}
.btn-ghost:hover:not(:disabled) { background: var(--accent-light); }

.btn-generate {
  width: 100%;
  background: var(--accent);
  color: white;
  font-size: 17px;
  padding: 13px;
}
.btn-generate:hover:not(:disabled) {
  background: var(--accent-dark);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.btn-generate.loading { pointer-events: none; }

.btn-connect { flex-shrink: 0; font-size: 15px; padding: 10px 18px; }

@keyframes spin { to { transform: rotate(360deg); } }
.fa-spin-custom { animation: spin .8s linear infinite; }

/* ─── Preview Card ───────────────────────────────────────────────────────── */
.preview-card {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  animation: fadeUp .35s ease;
}

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

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.preview-user { display: flex; align-items: center; gap: 10px; }
.preview-avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; }

.preview-avatar-placeholder {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 17px;
}

.preview-user strong { display: block; font-size: 15px; font-weight: 700; }
.preview-user span   { font-size: 13px; color: var(--text-muted); }

.preview-badge {
  width: 32px;
  height: 32px;
  background: var(--text);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 15px;
}

.preview-text { font-size: 18px; line-height: 1.6; color: var(--text); word-break: break-word; margin-bottom: 14px; }

.preview-footer {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-bottom: 16px;
}

.preview-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.char-count      { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.char-count.warn { color: #d97706; }
.char-count.limit{ color: var(--red); }
.preview-time    { font-size: 13px; color: var(--text-muted); }

.preview-icons { display: flex; gap: 22px; color: var(--text-muted); font-size: 17px; }
.preview-icons span { cursor: pointer; transition: var(--transition); padding: 4px; border-radius: 50%; }
.preview-icons span:hover { color: var(--accent); background: var(--accent-light); }

.edit-zone { margin-bottom: 16px; }
.edit-zone label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.edit-zone textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: 'Zain', sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  resize: vertical;
  min-height: 90px;
  outline: none;
  transition: var(--transition);
  line-height: 1.5;
}
.edit-zone textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91,94,244,.12);
  background: var(--surface);
}

.post-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ─── Toast ──────────────────────────────────────────────────────────────── */
.post-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #166534;
  color: white;
  padding: 14px 22px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 8px 32px rgba(22,101,52,.3);
  z-index: 1000;
  animation: toastIn .3s ease;
}
.post-toast a { color: white; text-decoration: underline; font-weight: 400; font-size: 14px; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(14px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ─── Footer ─────────────────────────────────────────────────────────────── */
.app-footer {
  text-align: center;
  padding: 24px 20px 30px;
  font-size: 13px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.footer-sep { color: var(--text-light); }

.footer-link {
  background: none;
  border: none;
  color: var(--accent);
  font-family: 'Zain', sans-serif;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: var(--transition);
}
.footer-link:hover { color: var(--accent-dark); }

/* ─── Right Sidebar ──────────────────────────────────────────────────────── */
.right-sidebar {
  width: var(--right-w);
  flex-shrink: 0;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tips-card, .limits-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.tips-card h3, .limits-card h3 {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}
.tips-card h3 i, .limits-card h3 i { color: var(--accent); }

.tips-card ul { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.tips-card li { font-size: 14px; color: var(--text-muted); display: flex; align-items: flex-start; gap: 8px; line-height: 1.4; }
.tips-card li i { color: var(--green); margin-top: 2px; font-size: 12px; flex-shrink: 0; }

.limit-bar-wrap { display: flex; flex-direction: column; gap: 8px; }
.limit-bar-label { display: flex; justify-content: space-between; font-size: 14px; color: var(--text-muted); font-weight: 600; }

.limit-bar { height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; }
.limit-bar-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s ease, background .3s ease; }
.limit-bar-fill.warn  { background: #d97706; }
.limit-bar-fill.limit { background: var(--red); }

/* ─── Modals ─────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .2s ease;
}
.modal-overlay.open { display: flex; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 620px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,.18);
  animation: modalUp .25s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}

@keyframes modalUp {
  from { opacity: 0; transform: translateY(18px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--accent-light);
}

.modal-title-wrap { display: flex; align-items: center; gap: 10px; color: var(--accent); }
.modal-title-wrap i  { font-size: 20px; }
.modal-title-wrap h2 { font-size: 19px; font-weight: 800; color: var(--text); }

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--text-muted);
  transition: var(--transition);
}
.modal-close:hover { background: var(--border); color: var(--text); }

.modal-body {
  overflow-y: auto;
  padding: 24px;
  flex: 1;
  line-height: 1.7;
  scroll-behavior: smooth;
}
.modal-body::-webkit-scrollbar { width: 5px; }
.modal-body::-webkit-scrollbar-track { background: transparent; }
.modal-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.modal-effective {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.modal-body h3 { font-size: 15px; font-weight: 800; color: var(--text); margin: 20px 0 6px; }
.modal-body h3:first-of-type { margin-top: 0; }
.modal-body p  { font-size: 15px; color: var(--text-muted); margin-bottom: 6px; }
.modal-body a  { color: var(--accent); text-decoration: underline; }
.modal-body code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 13px;
  font-family: monospace;
}

.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  background: var(--bg);
}

.modal-permalink {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}
.modal-permalink:hover { color: var(--accent); }

body.modal-open { overflow: hidden; }

/* ─── Animations ─────────────────────────────────────────────────────────── */
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1100px) { .right-sidebar { display: none; } }

@media (max-width: 720px) {
  .sidebar { width: 62px; padding: 14px 8px; }
  .sidebar-logo { padding: 8px 6px 16px; font-size: 26px; }
  .nav-item span, .profile-info, .logout-btn, .sidebar-bottom span { display: none; }
  .nav-item { justify-content: center; padding: 11px; }
  .sidebar-profile { padding: 8px; justify-content: center; }
  .profile-avatar { width: 34px; height: 34px; }
  .sidebar-legal { justify-content: center; padding: 9px !important; }
  .field-row { grid-template-columns: 1fr; }
  .connect-banner { flex-direction: column; text-align: center; }
  .topbar-sub { display: none; }
}
