/* SocialAuto Design System */
:root {
  --sa-primary: #4f46e5;
  --sa-primary-hover: #4338ca;
  --sa-accent: #06b6d4;
  --sa-success: #059669;
  --sa-warning: #d97706;
  --sa-danger: #dc2626;
  --sa-bg: #f1f5f9;
  --sa-surface: #ffffff;
  --sa-text: #0f172a;
  --sa-muted: #64748b;
  --sa-border: #e2e8f0;
  --sa-radius: 0.75rem;
  --sa-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --sa-shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.08);
  --sa-sidebar: #0f172a;
  --sa-font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0;
  font-family: var(--sa-font);
  background: var(--sa-bg);
  color: var(--sa-text);
  min-height: 100vh;
}

/* Layout shell */
.sa-shell { display: flex; min-height: 100vh; }
.sa-sidebar {
  width: 240px;
  background: var(--sa-sidebar);
  color: #e2e8f0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sa-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  text-decoration: none;
  color: #fff;
}
.sa-brand-mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--sa-primary), var(--sa-accent));
  display: grid; place-items: center;
  font-weight: 800; font-size: 0.85rem; color: #fff;
}
.sa-brand-text { font-weight: 700; letter-spacing: -0.02em; font-size: 1.1rem; }
.sa-brand-sub { font-size: 0.7rem; color: #94a3b8; font-weight: 500; }

.sa-nav { padding: 1rem 0.75rem; flex: 1; }
.sa-nav a {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  border-radius: 0.5rem;
  color: #cbd5e1;
  text-decoration: none;
  font-weight: 500;
  margin-bottom: 0.25rem;
  transition: background .15s, color .15s;
}
.sa-nav a:hover, .sa-nav a.active {
  background: rgba(79, 70, 229, 0.25);
  color: #fff;
}
.sa-nav-icon { width: 1.15rem; opacity: 0.9; }

.sa-sidebar-foot {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.75rem;
  color: #64748b;
}

.sa-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sa-topbar {
  background: var(--sa-surface);
  border-bottom: 1px solid var(--sa-border);
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
}
.sa-content { padding: 1.5rem; max-width: 1200px; width: 100%; margin: 0 auto; }

/* Cards */
.sa-card {
  background: var(--sa-surface);
  border: 1px solid var(--sa-border);
  border-radius: var(--sa-radius);
  box-shadow: var(--sa-shadow);
  overflow: hidden;
}
.sa-card-header {
  padding: 0.9rem 1.15rem;
  border-bottom: 1px solid var(--sa-border);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fafbfc;
}
.sa-card-body { padding: 1.15rem; }

/* Stats */
.sa-stat {
  background: var(--sa-surface);
  border: 1px solid var(--sa-border);
  border-radius: var(--sa-radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--sa-shadow);
}
.sa-stat-label { font-size: 0.8rem; color: var(--sa-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.sa-stat-value { font-size: 1.85rem; font-weight: 700; letter-spacing: -0.03em; margin-top: 0.25rem; }
.sa-stat-value.text-primary { color: var(--sa-primary) !important; }
.sa-stat-value.text-success { color: var(--sa-success) !important; }
.sa-stat-value.text-danger { color: var(--sa-danger) !important; }

/* Buttons */
.btn-sa {
  background: var(--sa-primary);
  border-color: var(--sa-primary);
  color: #fff;
  font-weight: 600;
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
}
.btn-sa:hover { background: var(--sa-primary-hover); border-color: var(--sa-primary-hover); color: #fff; }
.btn-sa-outline {
  border: 1px solid var(--sa-border);
  background: #fff;
  color: var(--sa-text);
  font-weight: 600;
  border-radius: 0.5rem;
}
.btn-sa-outline:hover { background: #f8fafc; border-color: #cbd5e1; }

/* Badges */
.badge-sa { font-weight: 600; padding: 0.35em 0.65em; border-radius: 999px; font-size: 0.75rem; }
.badge-draft { background: #fef3c7; color: #92400e; }
.badge-approved { background: #dbeafe; color: #1e40af; }
.badge-scheduled { background: #e0e7ff; color: #3730a3; }
.badge-published { background: #d1fae5; color: #065f46; }
.badge-failed { background: #fee2e2; color: #991b1b; }
.badge-cancelled { background: #f1f5f9; color: #475569; }

/* Empty state */
.sa-empty {
  text-align: center;
  padding: 2.5rem 1.5rem;
  color: var(--sa-muted);
}
.sa-empty-icon {
  width: 56px; height: 56px;
  margin: 0 auto 1rem;
  border-radius: 16px;
  background: linear-gradient(135deg, #e0e7ff, #cffafe);
  display: grid; place-items: center;
  font-size: 1.5rem;
}
.sa-empty h3 { color: var(--sa-text); font-size: 1.1rem; margin-bottom: 0.35rem; }

/* Tables */
.sa-table { width: 100%; margin: 0; }
.sa-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sa-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--sa-border);
  padding: 0.75rem 1rem;
  background: #fafbfc;
}
.sa-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--sa-border);
  vertical-align: middle;
}
.sa-table tr:last-child td { border-bottom: none; }
.sa-table tr:hover td { background: #f8fafc; }

/* Forms */
.form-label { font-weight: 600; font-size: 0.85rem; color: #334155; }
.form-control, .form-select {
  border-radius: 0.5rem;
  border-color: var(--sa-border);
  padding: 0.55rem 0.75rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--sa-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
.char-counter { font-size: 0.75rem; color: var(--sa-muted); }
.char-counter.warn { color: var(--sa-warning); }
.char-counter.over { color: var(--sa-danger); font-weight: 600; }

/* Calendar */
.sa-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--sa-border);
  border: 1px solid var(--sa-border);
  border-radius: var(--sa-radius);
  overflow: hidden;
}
.sa-cal-head {
  background: #f8fafc;
  padding: 0.5rem;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--sa-muted);
  text-transform: uppercase;
}
.sa-cal-day {
  background: #fff;
  min-height: 100px;
  padding: 0.4rem;
  vertical-align: top;
}
.sa-cal-day.muted { background: #f8fafc; color: #94a3b8; }
.sa-cal-day.today { outline: 2px solid var(--sa-primary); outline-offset: -2px; }
.sa-cal-num { font-size: 0.8rem; font-weight: 600; margin-bottom: 0.25rem; }
.sa-cal-item {
  display: block;
  font-size: 0.7rem;
  padding: 0.2rem 0.35rem;
  margin-bottom: 0.2rem;
  border-radius: 4px;
  background: #e0e7ff;
  color: #3730a3;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sa-cal-item.published { background: #d1fae5; color: #065f46; }
.sa-cal-item.failed { background: #fee2e2; color: #991b1b; }

/* Mobile */
.sa-menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--sa-border);
  border-radius: 0.5rem;
  padding: 0.4rem 0.65rem;
  font-weight: 600;
}
@media (max-width: 900px) {
  .sa-sidebar {
    position: fixed;
    left: -260px;
    z-index: 100;
    transition: left .2s;
  }
  .sa-sidebar.open { left: 0; }
  .sa-menu-btn { display: inline-block; }
  .sa-content { padding: 1rem; }
  .sa-cal-day { min-height: 70px; }
}

/* Page title */
.sa-page-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0;
}
.sa-page-sub { color: var(--sa-muted); font-size: 0.9rem; margin-top: 0.15rem; }

.alert { border-radius: 0.65rem; }
pre.sa-content-block {
  white-space: pre-wrap;
  font-family: inherit;
  margin: 0;
  line-height: 1.55;
}
