/* ══════════════════════════════════════
   Anka App — Main Stylesheet
   ══════════════════════════════════════ */

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

:root {
  --bg:        #0f1117;
  --bg2:       #161b22;
  --bg3:       #1e2530;
  --surface:   #21262d;
  --border:    rgba(255,255,255,.08);
  --text:      #e6edf3;
  --text2:     #8b949e;
  --text3:     #6e7681;
  --accent:    #58a6ff;
  --accent2:   #1f6feb;
  --green:     #3fb950;
  --orange:    #d29922;
  --red:       #f85149;
  --purple:    #bc8cff;
  --radius:    10px;
  --radius-sm: 6px;
  --shadow:    0 8px 32px rgba(0,0,0,.4);
  --sidebar-w: 240px;
  --topbar-h:  56px;
}

body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6; }

/* ── Layout ── */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform .25s ease;
}

.main-wrap {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 16px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
}
.logo-icon { font-size: 22px; }
.sidebar-close { display: none; background: none; border: none; color: var(--text2); cursor: pointer; font-size: 16px; }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-section { padding: 0 12px 12px; }
.nav-label { display: block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text3); padding: 8px 8px 4px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  text-decoration: none;
  font-size: 13.5px;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: rgba(88,166,255,.12); color: var(--accent); font-weight: 600; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  transition: background .15s;
  margin-bottom: 6px;
}
.user-card:hover { background: var(--bg3); }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent2);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-plan { font-size: 11px; color: var(--text3); }
.user-settings-icon { color: var(--text3); font-size: 14px; }
.logout-btn {
  display: block;
  text-align: center;
  padding: 7px;
  border-radius: var(--radius-sm);
  background: rgba(248,81,73,.1);
  color: var(--red);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 500;
  transition: background .15s;
}
.logout-btn:hover { background: rgba(248,81,73,.2); }

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.menu-toggle { display: none; background: none; border: none; color: var(--text2); cursor: pointer; font-size: 20px; }
.topbar-title { font-weight: 600; font-size: 15px; flex: 1; }
.topbar-actions { display: flex; gap: 8px; }

/* ── Content ── */
.main-content { padding: 24px; flex: 1; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 20px; font-weight: 700; }

/* ── Alerts ── */
.alert {
  padding: 12px 20px;
  margin: 0 24px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  border-left: 3px solid;
}
.alert-success { background: rgba(63,185,80,.1); border-color: var(--green); color: #7ee787; }
.alert-error   { background: rgba(248,81,73,.1);  border-color: var(--red);   color: #ff7b72; }

/* ── Cards ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 14px; font-weight: 600; }

/* ── Stat Cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.stat-icon { font-size: 28px; flex-shrink: 0; }
.stat-info { flex: 1; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--text2); margin-top: 4px; }
.stat-sub { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn-primary  { background: var(--accent2); color: #fff; border-color: var(--accent2); }
.btn-primary:hover { background: #1a5ccb; }
.btn-outline  { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--bg3); }
.btn-danger   { background: rgba(248,81,73,.15); color: var(--red); border-color: rgba(248,81,73,.3); }
.btn-danger:hover { background: rgba(248,81,73,.25); }
.btn-success  { background: rgba(63,185,80,.15); color: var(--green); border-color: rgba(63,185,80,.3); }
.btn-success:hover { background: rgba(63,185,80,.25); }
.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 7px 8px; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text2); }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  transition: border-color .15s;
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent2);
}
.form-textarea { min-height: 120px; resize: vertical; }
.form-select option { background: var(--bg3); }
.form-hint { font-size: 11.5px; color: var(--text3); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
th { font-weight: 600; color: var(--text2); background: var(--bg3); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
tr:hover td { background: rgba(255,255,255,.02); }
td:last-child, th:last-child { text-align: right; }

/* ── Badges ── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 100px; font-size: 11px; font-weight: 600; }
.badge-green   { background: rgba(63,185,80,.15);  color: var(--green);  }
.badge-orange  { background: rgba(210,153,34,.15); color: var(--orange); }
.badge-red     { background: rgba(248,81,73,.15);  color: var(--red);    }
.badge-blue    { background: rgba(88,166,255,.15); color: var(--accent); }
.badge-purple  { background: rgba(188,140,255,.15);color: var(--purple); }
.badge-gray    { background: rgba(139,148,158,.1); color: var(--text2);  }

/* ── Platform chips ── */
.platform-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--bg3);
}

/* ── Grid layouts ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text2);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.empty-state p  { font-size: 13.5px; margin-bottom: 20px; }

/* ── Social account cards ── */
.accounts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.account-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.account-card.connected { border-color: rgba(63,185,80,.3); }
.account-card.error     { border-color: rgba(248,81,73,.3); }
.account-icon { font-size: 28px; flex-shrink: 0; }
.account-info { flex: 1; min-width: 0; }
.account-name { font-weight: 600; font-size: 14px; }
.account-meta { font-size: 12px; color: var(--text2); margin-top: 2px; }
.account-status { font-size: 11px; margin-top: 4px; }

/* ── Post card ── */
.post-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  transition: border-color .15s;
}
.post-card:hover { border-color: rgba(88,166,255,.3); }
.post-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.post-content { font-size: 13.5px; color: var(--text); line-height: 1.6; }
.post-media { margin-top: 10px; border-radius: var(--radius-sm); overflow: hidden; max-height: 200px; }
.post-media img { width: 100%; height: 200px; object-fit: cover; }
.post-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; gap: 8px; flex-wrap: wrap; }

/* ── Calendar ── */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border-radius: var(--radius); overflow: hidden; }
.cal-header { background: var(--bg3); text-align: center; padding: 8px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text2); }
.cal-day { background: var(--bg2); min-height: 90px; padding: 8px; }
.cal-day.other-month { opacity: .35; }
.cal-day.today { background: rgba(88,166,255,.06); }
.cal-day-num { font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 4px; }
.cal-day.today .cal-day-num { color: var(--accent); }
.cal-post-dot { background: var(--accent2); border-radius: 3px; padding: 2px 5px; font-size: 10px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }

/* ── Analytics ── */
.analytics-bar { background: var(--bg3); border-radius: 4px; height: 8px; overflow: hidden; margin-top: 6px; }
.analytics-bar-fill { height: 100%; border-radius: 4px; background: var(--accent2); transition: width .5s ease; }

/* ── Connect modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden;
  transition: all .2s;
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-size: 17px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text2); cursor: pointer; font-size: 18px; }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; background: var(--bg3); padding: 4px; border-radius: var(--radius-sm); }
.tab { flex: 1; text-align: center; padding: 7px 12px; border-radius: 6px; font-size: 13px; font-weight: 500; color: var(--text2); cursor: pointer; transition: all .15s; }
.tab.active { background: var(--bg2); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.3); }

/* ── Auth pages ── */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 20px; }
.auth-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 36px; width: 100%; max-width: 400px; box-shadow: var(--shadow); }
.auth-logo { text-align: center; margin-bottom: 28px; font-size: 24px; font-weight: 800; }
.auth-logo span { color: var(--accent); }
.auth-title { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.auth-sub { font-size: 13.5px; color: var(--text2); margin-bottom: 24px; }
.auth-footer { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text2); }
.auth-footer a { color: var(--accent); text-decoration: none; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--text3); font-size: 12px; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Setup page ── */
.setup-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 20px; }
.setup-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 40px; width: 100%; max-width: 520px; }
.setup-steps { display: flex; gap: 8px; margin-bottom: 32px; }
.setup-step { flex: 1; height: 3px; border-radius: 2px; background: var(--bg3); }
.setup-step.done { background: var(--green); }
.setup-step.active { background: var(--accent2); }

/* ── Overlay ── */
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 150; }
.overlay.show { display: block; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .main-wrap { margin-left: 0; }
  .menu-toggle { display: block; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .main-content { padding: 16px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ── Utilities ── */
.text-muted { color: var(--text2); }
.text-small { font-size: 12px; }
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.w-full { width: 100%; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.2); border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
