/* ════════════════════════════════════════════════════════════════
   SocialAI Manager — Hauptstylesheet
   Design-Sprache: Dark UI, Accent #7c6cff, Fonts: Syne + DM Sans
   ════════════════════════════════════════════════════════════════ */

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

:root {
  --bg:       #0e0e11;
  --surface:  #18181d;
  --surface2: #222229;
  --surface3: #2a2a33;
  --border:   rgba(255,255,255,0.08);
  --border2:  rgba(255,255,255,0.14);
  --accent:   #7c6cff;
  --accent-h: #6a5ae0;
  --accent2:  #ff6b6b;
  --accent3:  #06d6a0;
  --accent4:  #fbbf24;
  --text:     #f0f0f5;
  --text2:    #9090a8;
  --text3:    #5a5a72;
  --radius:   12px;
  --radius-sm: 8px;
  --sidebar-w: 240px;
  --font-display: 'Syne', sans-serif;
  --font-body:    'DM Sans', sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ── App Shell ─────────────────────────────────────────────────── */

.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-logo {
  padding: 22px 20px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo-text {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.logo-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent3);
  box-shadow: 0 0 8px var(--accent3);
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.sidebar-bottom {
  padding: 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 13.5px;
  font-weight: 500;
  transition: all .15s;
  cursor: pointer;
}

.nav-item i {
  width: 18px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--surface2);
  color: var(--text);
}

.nav-item.active {
  background: rgba(124, 108, 255, 0.15);
  color: var(--accent);
}

.nav-item.active i {
  color: var(--accent);
}

/* ── Main Content ──────────────────────────────────────────────── */

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Page Header ───────────────────────────────────────────────── */

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

.page-header h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.page-header .header-sub {
  font-size: 13px;
  color: var(--text3);
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Page Body ─────────────────────────────────────────────────── */

.page-body {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}

/* ── Buttons ───────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.btn:hover { background: var(--surface3); border-color: var(--border2); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-h); border-color: var(--accent-h); }

.btn-success {
  background: var(--accent3);
  border-color: var(--accent3);
  color: #000;
  font-weight: 600;
}
.btn-success:hover { background: #04b885; }

.btn-danger {
  background: transparent;
  border-color: var(--border);
  color: var(--accent2);
}
.btn-danger:hover { background: rgba(255,107,107,.15); border-color: var(--accent2); }

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-icon {
  padding: 7px;
  line-height: 1;
}

.btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

/* ── Cards ─────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

/* ── Stat Cards ────────────────────────────────────────────────── */

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

@media (max-width: 1100px) { .stats-row { grid-template-columns: repeat(2, 1fr); } }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color .15s;
}

.stat-card:hover { border-color: var(--border2); }

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.stat-icon.purple { background: rgba(124,108,255,.15); color: var(--accent); }
.stat-icon.red    { background: rgba(255,107,107,.15); color: var(--accent2); }
.stat-icon.green  { background: rgba(6,214,160,.15);   color: var(--accent3); }
.stat-icon.yellow { background: rgba(251,191,36,.15);  color: var(--accent4); }

.stat-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text3);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Section Headers ───────────────────────────────────────────── */

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

.section-header h2 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

/* ── Project Cards Grid ────────────────────────────────────────── */

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  cursor: pointer;
  transition: all .15s;
  position: relative;
  overflow: hidden;
}

.project-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--project-color, var(--accent));
  opacity: 0;
  transition: opacity .15s;
}

.project-card:hover {
  border-color: var(--border2);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}

.project-card:hover::before { opacity: 1; }

.project-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.project-card-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
}

.project-card-desc {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.project-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text3);
}

.project-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.project-card-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity .15s;
}
.project-card:hover .project-card-actions { opacity: 1; }

/* ── Badges ────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge-green  { background: rgba(6,214,160,.15);   color: var(--accent3); }
.badge-yellow { background: rgba(251,191,36,.15);  color: var(--accent4); }
.badge-gray   { background: rgba(90,90,114,.2);    color: var(--text2); }
.badge-blue   { background: rgba(124,108,255,.15); color: var(--accent); }
.badge-red    { background: rgba(255,107,107,.15); color: var(--accent2); }

/* ── Filter Tabs ───────────────────────────────────────────────── */

.filter-tabs {
  display: flex;
  gap: 4px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.filter-tab {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: none;
  color: var(--text2);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.filter-tab:hover { color: var(--text); }
.filter-tab.active {
  background: rgba(124,108,255,.15);
  border-color: rgba(124,108,255,.3);
  color: var(--accent);
}

/* ── Forms ─────────────────────────────────────────────────────── */

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 12px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 7px;
}

.form-control {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 9px 12px;
  outline: none;
  transition: border-color .15s;
}
.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: var(--text3); }

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

select.form-control {
  cursor: pointer;
  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='%235a5a72' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ── Modal ─────────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all .2s;
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  transform: translateY(12px);
  transition: transform .2s;
}

.modal-backdrop.open .modal { transform: translateY(0); }

.modal-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* ── Post Type Cards ───────────────────────────────────────────── */

.type-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.type-card {
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all .15s;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.type-card:hover { border-color: var(--accent); }
.type-card.selected {
  border-color: var(--accent);
  background: rgba(124,108,255,.1);
}

.type-card i {
  font-size: 22px;
  color: var(--accent);
}

.type-card .type-name {
  font-size: 13px;
  font-weight: 600;
}

.type-card .type-desc {
  font-size: 11px;
  color: var(--text3);
}

/* ── Input Tabs ────────────────────────────────────────────────── */

.input-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.input-tab {
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text2);
  font-size: 12px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all .15s;
  display: flex;
  align-items: center;
  gap: 5px;
}
.input-tab:hover { border-color: var(--accent); color: var(--text); }
.input-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.input-panel { display: none; }
.input-panel.active { display: block; }

/* ── Result Panel ──────────────────────────────────────────────── */

.result-panel {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 300px;
  display: flex;
  flex-direction: column;
}

.result-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  gap: 12px;
  padding: 40px;
}
.result-empty i { font-size: 36px; }
.result-empty p { font-size: 13px; text-align: center; }

.result-loading {
  display: none;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text2);
  gap: 16px;
  padding: 40px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.result-content {
  display: none;
  padding: 20px;
  overflow-y: auto;
}

.result-content.visible { display: block; }

/* ── Carousel Slide Preview ────────────────────────────────────── */

.slide-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.slide-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.slide-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.slide-num {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.slide-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

.slide-body {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
}

/* ── Script Preview ────────────────────────────────────────────── */

.script-section {
  margin-bottom: 16px;
}

.script-section-label {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.script-text {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.7;
  white-space: pre-wrap;
}

/* ── Recent Posts Table ────────────────────────────────────────── */

.posts-table {
  width: 100%;
  border-collapse: collapse;
}

.posts-table th {
  text-align: left;
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 14px 10px;
  border-bottom: 1px solid var(--border);
}

.posts-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}

.posts-table tr:last-child td { border-bottom: none; }

.posts-table tr:hover td { background: rgba(255,255,255,.02); }

.post-type-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: rgba(124,108,255,.15);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

/* ── Empty State ───────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
}

.empty-state i {
  font-size: 44px;
  margin-bottom: 14px;
  display: block;
  opacity: .4;
}

.empty-state h3 {
  font-size: 16px;
  color: var(--text2);
  margin-bottom: 6px;
}

.empty-state p { font-size: 13px; }

/* ── Toast ─────────────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-left: 3px solid var(--accent3);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  animation: toastIn .25s ease;
  pointer-events: all;
}
.toast.error { border-left-color: var(--accent2); }

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

/* ── Scrollbar ─────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border2); }

/* ── New Post — Two-column layout ──────────────────────────────── */

.post-new-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
}

@media (max-width: 900px) {
  .post-new-layout { grid-template-columns: 1fr; }
}

.post-new-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.panel-card-body {
  padding: 18px;
}

/* ── Result Actions Bar ────────────────────────────────────────── */

.result-actions {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  background: var(--surface);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ── Color Picker ──────────────────────────────────────────────── */

.color-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-opt {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color .15s;
}

.color-opt.selected, .color-opt:hover {
  border-color: #fff;
}
