/* public/css/app.css — FB Scheduler UI */

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

:root {
  --blue:      #1877F2;
  --blue-dark: #0d5fc4;
  --blue-soft: #e8f0fe;
  --green:     #22c55e;
  --green-soft:#dcfce7;
  --red:       #ef4444;
  --red-soft:  #fee2e2;
  --amber:     #f59e0b;
  --amber-soft:#fef3c7;
  --gray-50:   #f9fafb;
  --gray-100:  #f3f4f6;
  --gray-200:  #e5e7eb;
  --gray-300:  #d1d5db;
  --gray-400:  #9ca3af;
  --gray-500:  #6b7280;
  --gray-600:  #4b5563;
  --gray-700:  #374151;
  --gray-800:  #1f2937;
  --gray-900:  #111827;
  --sidebar-w: 240px;
  --radius:    10px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -1px rgba(0,0,0,.05);
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--gray-900);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  padding: 0;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-icon { width: 32px; height: 32px; flex-shrink: 0; }
.brand-name {
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  letter-spacing: -.01em;
}

.sidebar-nav {
  padding: 12px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 7px;
  color: var(--gray-400);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--blue); color: #fff; }

.sidebar-footer {
  padding: 14px 14px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.user-info { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-meta { min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-logout { font-size: 11.5px; color: var(--gray-500); text-decoration: none; }
.user-logout:hover { color: var(--red); }

/* ── Main content ────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  overflow-x: hidden;
}
.page-inner { padding: 32px; max-width: 1100px; }

/* ── Page header ─────────────────────────────────────────── */
.page-header { margin-bottom: 28px; }
.page-title { font-size: 22px; font-weight: 700; color: var(--gray-900); letter-spacing: -.02em; }
.page-subtitle { font-size: 13.5px; color: var(--gray-500); margin-top: 4px; }
.page-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; flex-wrap: wrap; gap: 12px; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-body { padding: 24px; }
.card-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--gray-100);
  font-weight: 600;
  font-size: 14px;
  color: var(--gray-700);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Stats row ───────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--gray-500); }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 6px; letter-spacing: -.03em; }
.stat-value.blue   { color: var(--blue); }
.stat-value.green  { color: var(--green); }
.stat-value.red    { color: var(--red); }
.stat-value.amber  { color: var(--amber); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background .15s, opacity .15s, transform .1s;
  white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 15px; height: 15px; }

.btn-primary   { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-success   { background: var(--green); color: #fff; }
.btn-danger    { background: var(--red); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost     { background: transparent; color: var(--gray-600); border: 1px solid var(--gray-200); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-sm        { padding: 5px 11px; font-size: 12.5px; border-radius: 6px; }
.btn-icon      { padding: 7px; }
.btn:disabled  { opacity: .5; cursor: not-allowed; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.form-label .required { color: var(--red); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 7px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--gray-800);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(24,119,242,.12);
}
.form-control.error { border-color: var(--red); }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-hint { font-size: 11.5px; color: var(--gray-400); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--red); margin-top: 4px; }

/* ── File upload drop zone ───────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--blue);
  background: var(--blue-soft);
}
.drop-zone input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}
.drop-zone-icon { font-size: 32px; display: block; margin-bottom: 8px; }
.drop-zone-text { font-size: 13px; color: var(--gray-500); }
.drop-zone-text strong { color: var(--blue); }
.media-preview { margin-top: 14px; }
.media-preview img { max-width: 120px; max-height: 80px; border-radius: 6px; object-fit: cover; }
.media-preview .video-label { font-size: 12px; color: var(--gray-500); display: flex; align-items: center; gap: 6px; }

/* ── Table ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--gray-200); }
table { width: 100%; border-collapse: collapse; background: #fff; }
thead tr { background: var(--gray-50); }
th {
  padding: 11px 16px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gray-500);
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}
td {
  padding: 13px 16px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-pending    { background: var(--amber-soft);  color: #92400e; }
.badge-publishing { background: var(--blue-soft);   color: #1e40af; }
.badge-published  { background: var(--green-soft);  color: #15803d; }
.badge-failed     { background: var(--red-soft);    color: #b91c1c; }

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
  padding: 13px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-success { background: var(--green-soft);  color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: var(--red-soft);    color: #991b1b; border: 1px solid #fecaca; }
.alert-info    { background: var(--blue-soft);   color: #1e3a5f; border: 1px solid #bfdbfe; }
.alert-warning { background: var(--amber-soft);  color: #78350f; border: 1px solid #fde68a; }

/* ── Post builder grid ───────────────────────────────────── */
.post-builder { display: flex; flex-direction: column; gap: 16px; }

.post-item {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color .2s;
}
.post-item:focus-within { border-color: var(--blue); }

.post-item-header {
  background: var(--gray-50);
  padding: 11px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--gray-200);
}
.post-item-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.post-item-body { padding: 18px; }
.post-item-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 640px) {
  .post-item-grid { grid-template-columns: 1fr; }
}

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--gray-500);
}
.empty-state-icon { font-size: 40px; margin-bottom: 12px; display: block; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.empty-state p  { font-size: 13.5px; }

/* ── Filter bar ──────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar select, .filter-bar input {
  padding: 7px 11px;
  border: 1px solid var(--gray-200);
  border-radius: 7px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: var(--gray-700);
  outline: none;
}
.filter-bar select:focus, .filter-bar input:focus {
  border-color: var(--blue);
}

/* ── Thumbnail in table ───────────────────────────────────── */
.thumb { width: 48px; height: 36px; border-radius: 5px; object-fit: cover; background: var(--gray-100); }
.thumb-placeholder { width: 48px; height: 36px; border-radius: 5px; background: var(--gray-100); display: flex; align-items: center; justify-content: center; font-size: 18px; color: var(--gray-400); }

/* ── Caption preview ─────────────────────────────────────── */
.caption-preview {
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  color: var(--gray-700);
}

/* ── Log entry ───────────────────────────────────────────── */
.log-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  color: var(--gray-600);
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 8px 12px;
  max-height: 120px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Login page ──────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-900);
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.login-logo svg { width: 36px; height: 36px; }
.login-logo span { font-size: 18px; font-weight: 800; color: var(--gray-900); }
.login-title { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.login-subtitle { font-size: 13px; color: var(--gray-500); margin-bottom: 24px; }

/* ── Pagination ──────────────────────────────────────────── */
.pagination { display: flex; gap: 6px; margin-top: 20px; justify-content: flex-end; }
.pagination a, .pagination span {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--gray-200);
  background: #fff;
  color: var(--gray-600);
  text-decoration: none;
}
.pagination a:hover { background: var(--gray-50); }
.pagination .current { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .page-inner { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Utility ─────────────────────────────────────────────── */
.text-muted   { color: var(--gray-400); }
.text-sm      { font-size: 12px; }
.text-danger  { color: var(--red); }
.mono         { font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.flex         { display: flex; }
.items-center { align-items: center; }
.gap-2        { gap: 8px; }
.gap-3        { gap: 12px; }
.mt-4         { margin-top: 16px; }
.ml-auto      { margin-left: auto; }
.sr-only      { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
