/* ─── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f13;
  --bg2: #16161d;
  --bg3: #1e1e28;
  --border: #2a2a35;
  --text: #e8e8f0;
  --text2: #9090a8;
  --primary: #6366f1;
  --primary-hover: #5254cc;
  --primary-glow: rgba(99,102,241,0.15);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --instagram: #e1306c;
  --facebook: #1877f2;
  --linkedin: #0a66c2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

html { font-size: 16px; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Auth ──────────────────────────────────────────────────────────────────── */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-container { width: 100%; max-width: 420px; }
.auth-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: var(--shadow);
}
.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo .logo-icon { font-size: 36px; color: var(--primary); margin-bottom: 8px; display: block; }
.auth-logo h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.03em; }
.auth-subtitle { color: var(--text2); font-size: 0.9rem; margin-top: 4px; }
.auth-switch { text-align: center; margin-top: 20px; color: var(--text2); font-size: 0.9rem; }

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

/* Sidebar */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.sidebar-logo .logo-icon { font-size: 22px; color: var(--primary); }
.sidebar-logo span { font-weight: 700; font-size: 1rem; }

/* Profile section */
.profile-section { margin-bottom: 20px; }
.active-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.profile-info { display: flex; flex-direction: column; }
.profile-name { font-size: 0.85rem; font-weight: 600; }
.profile-label { font-size: 0.7rem; color: var(--text2); }

.profile-switcher { display: flex; flex-direction: column; gap: 4px; }
.profile-switch-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  text-align: left;
  width: 100%;
  transition: background 0.15s, color 0.15s;
}
.profile-switch-btn:hover { background: var(--bg3); color: var(--text); }

/* Avatars */
.profile-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; color: white;
  flex-shrink: 0;
}
.profile-avatar.sm { width: 24px; height: 24px; font-size: 0.7rem; }
.profile-avatar.lg { width: 56px; height: 56px; font-size: 1.4rem; }

/* Nav */
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}
.nav-item:hover { background: var(--bg3); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--primary-glow); color: var(--primary); }
.nav-item-create {
  margin-top: 8px;
  background: var(--primary);
  color: white !important;
  font-weight: 600;
}
.nav-item-create:hover { background: var(--primary-hover); }
.nav-icon { width: 20px; text-align: center; }

/* Sidebar footer */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}
.user-info { display: flex; align-items: center; gap: 8px; }
.user-avatar {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; color: white;
}
.user-name { font-size: 0.8rem; font-weight: 600; }
.btn-logout {
  background: none; border: none; color: var(--text2); cursor: pointer;
  font-size: 1.2rem; padding: 4px; border-radius: 50%;
  transition: color 0.15s, background 0.15s;
}
.btn-logout:hover { color: var(--danger); background: rgba(239,68,68,0.1); }

/* Main Content */
.main-content { flex: 1; padding: 32px; overflow-x: hidden; }

/* ─── Page Header ───────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}
.page-header h1 { font-size: 1.6rem; font-weight: 800; }
.page-subtitle { color: var(--text2); font-size: 0.9rem; margin-top: 2px; }

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 600;
  cursor: pointer; border: none;
  transition: all 0.15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-full { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-disabled { background: var(--bg3); color: var(--text2); cursor: default; }
.btn-icon { background: none; border: none; color: var(--text2); cursor: pointer; font-size: 1rem; padding: 4px 8px; border-radius: 6px; }
.btn-icon:hover { background: var(--bg3); color: var(--primary); }

/* ─── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 0.85rem; font-weight: 600;
  color: var(--text2); margin-bottom: 6px;
}
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.15s;
  resize: vertical;
}
.form-group input:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.form-group input::placeholder, .form-group textarea::placeholder { color: var(--text2); opacity: 0.7; }
.required { color: var(--danger); }
.char-counter { font-size: 0.75rem; color: var(--text2); text-align: right; margin-top: 4px; }

/* ─── Alerts ────────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 0.9rem;
}
.alert-error { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.alert-success { background: rgba(16,185,129,0.15); border: 1px solid rgba(16,185,129,0.3); color: #6ee7b7; }

/* ─── Badges ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem; font-weight: 600;
}
.badge-draft { background: rgba(148,163,184,0.15); color: #94a3b8; }
.badge-scheduled { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-published { background: rgba(16,185,129,0.15); color: #34d399; }
.badge-active { background: var(--primary-glow); color: var(--primary); }

/* ─── Stats Grid ────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stat-icon { font-size: 1.5rem; }
.stat-value { font-size: 2rem; font-weight: 800; }
.stat-label { font-size: 0.8rem; color: var(--text2); }
.stat-total .stat-value { color: var(--primary); }
.stat-draft .stat-value { color: #94a3b8; }
.stat-scheduled .stat-value { color: #fbbf24; }
.stat-published .stat-value { color: #34d399; }

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

.dashboard-card, .editor-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.card-header h2 { font-size: 1rem; font-weight: 700; }
.link-small { font-size: 0.8rem; color: var(--text2); }
.link-small:hover { color: var(--primary); }

/* Post list in dashboard */
.post-list { display: flex; flex-direction: column; gap: 10px; }
.post-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
}
.post-item-left { display: flex; align-items: center; gap: 10px; }
.post-preview { display: flex; flex-direction: column; }
.post-title { font-size: 0.85rem; font-weight: 500; }
.post-date { font-size: 0.75rem; color: var(--text2); }

/* Platform dots */
.platform-dots { display: flex; gap: 4px; align-items: center; }
.platform-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.platform-dot.platform-instagram { background: var(--instagram); }
.platform-dot.platform-facebook { background: var(--facebook); }
.platform-dot.platform-linkedin { background: var(--linkedin); }

/* Week overview */
.week-overview {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  padding: 12px 0;
}
.week-day { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; }
.week-day-label { font-size: 0.75rem; color: var(--text2); }
.week-day-bar {
  width: 100%; height: 40px;
  background: var(--bg3);
  border-radius: 4px;
}
.week-day.today .week-day-bar { background: var(--primary-glow); border: 1px solid var(--primary); }
.week-day-count { font-size: 0.7rem; color: var(--text2); }
.week-target { font-size: 0.8rem; color: var(--text2); margin-top: 8px; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--bg2);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}
.empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h2 { font-size: 1.2rem; margin-bottom: 8px; }
.empty-state p { color: var(--text2); margin-bottom: 20px; }
.empty-small { padding: 20px; text-align: center; color: var(--text2); font-size: 0.85rem; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 20px; }

/* ─── Filter Bar ────────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
  align-items: center;
}
.filter-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-label { font-size: 0.8rem; color: var(--text2); font-weight: 600; }
.filter-btn {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem; font-weight: 500;
  color: var(--text2);
  background: var(--bg2);
  border: 1px solid var(--border);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}
.filter-btn:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.filter-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ─── Posts Grid ────────────────────────────────────────────────────────────── */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.post-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.15s, transform 0.15s;
}
.post-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.post-card-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.post-card-title { font-size: 0.95rem; font-weight: 700; }
.post-card-content { font-size: 0.85rem; color: var(--text2); line-height: 1.6; flex: 1; }
.post-card-hashtags { font-size: 0.8rem; color: var(--primary); }
.post-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: auto; }
.post-card-meta { font-size: 0.75rem; color: var(--text2); }
.post-card-actions { display: flex; gap: 8px; }

.platform-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.platform-chip {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
}
.platform-chip.platform-instagram { background: rgba(225,48,108,0.15); color: #e1306c; }
.platform-chip.platform-facebook { background: rgba(24,119,242,0.15); color: #1877f2; }
.platform-chip.platform-linkedin { background: rgba(10,102,194,0.15); color: #0a66c2; }

/* ─── Post Editor ───────────────────────────────────────────────────────────── */
.editor-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}
.editor-main { display: flex; flex-direction: column; gap: 16px; }
.editor-sidebar { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 20px; }
.editor-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card-section-title { font-size: 0.9rem; font-weight: 700; margin-bottom: 14px; }
.editor-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 8px; }

/* Platform checkboxes */
.platform-checkboxes { display: flex; gap: 12px; flex-wrap: wrap; }
.platform-checkbox { cursor: pointer; }
.platform-checkbox input { display: none; }
.platform-label {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  background: var(--bg3);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem; font-weight: 600;
  transition: all 0.15s;
  user-select: none;
}
.platform-checkbox input:checked + .platform-label { border-color: var(--primary); background: var(--primary-glow); color: var(--text); }
.platform-emoji { font-size: 1.1rem; }

/* Status options */
.status-options { display: flex; gap: 12px; }
.status-option { cursor: pointer; }
.status-option input { display: none; }
.status-label {
  display: block;
  padding: 10px 16px;
  background: var(--bg3);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem; font-weight: 600;
  transition: all 0.15s;
  user-select: none;
}
.status-option input:checked + .status-draft { border-color: #94a3b8; background: rgba(148,163,184,0.1); }
.status-option input:checked + .status-scheduled { border-color: #fbbf24; background: rgba(245,158,11,0.1); }
.status-option input:checked + .status-published { border-color: #34d399; background: rgba(16,185,129,0.1); }
.mt-3 { margin-top: 12px; }

/* Preview */
.preview-box {
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 16px;
}
.preview-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.preview-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.9rem; color: white; }
.preview-name { font-size: 0.85rem; font-weight: 600; }
.preview-time { font-size: 0.7rem; color: var(--text2); }
.preview-content { font-size: 0.85rem; line-height: 1.6; min-height: 60px; white-space: pre-wrap; word-break: break-word; }
.preview-placeholder { color: var(--text2); }
.preview-hashtags { font-size: 0.8rem; margin-top: 8px; min-height: 16px; }

/* Tips */
.tips-card { background: rgba(99,102,241,0.05); border-color: rgba(99,102,241,0.2); }
.tips-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.tips-list li { font-size: 0.8rem; color: var(--text2); padding-left: 0; }
.tips-list li strong { color: var(--text); }

/* ─── Calendar ──────────────────────────────────────────────────────────────── */
.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.calendar-month { font-size: 1.2rem; font-weight: 700; }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 20px;
}
.calendar-header-cell {
  text-align: center;
  padding: 10px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
}
.calendar-cell {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  min-height: 100px;
  position: relative;
  transition: border-color 0.15s;
}
.calendar-cell:hover { border-color: var(--primary); }
.calendar-cell-empty { background: transparent; border-color: transparent; }
.calendar-cell-today { border-color: var(--primary) !important; background: rgba(99,102,241,0.05); }
.calendar-day-num {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 6px;
}
.today-num {
  background: var(--primary);
  color: white;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
}

.calendar-posts { display: flex; flex-direction: column; gap: 2px; }
.calendar-post-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 0.65rem;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.calendar-post-item.status-draft { background: rgba(148,163,184,0.15); }
.calendar-post-item.status-scheduled { background: rgba(245,158,11,0.15); }
.calendar-post-item.status-published { background: rgba(16,185,129,0.15); }
.calendar-post-item:hover { opacity: 0.8; text-decoration: none; }

.cal-platform-dots { display: flex; gap: 2px; flex-shrink: 0; }
.cal-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.cal-dot.platform-instagram { background: var(--instagram); }
.cal-dot.platform-facebook { background: var(--facebook); }
.cal-dot.platform-linkedin { background: var(--linkedin); }

.cal-post-title { overflow: hidden; text-overflow: ellipsis; }
.calendar-more { font-size: 0.65rem; color: var(--text2); padding: 2px 4px; }
.calendar-add-btn {
  position: absolute;
  bottom: 4px; right: 4px;
  width: 20px; height: 20px;
  background: var(--bg3);
  border-radius: 50%;
  display: none; align-items: center; justify-content: center;
  font-size: 0.8rem; color: var(--primary);
  text-decoration: none;
}
.calendar-cell:hover .calendar-add-btn { display: flex; }

.calendar-legend {
  display: flex; gap: 20px; flex-wrap: wrap;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  font-size: 0.8rem; color: var(--text2);
  align-items: center;
  margin-bottom: 16px;
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.ml-2 { margin-left: 6px; }

.calendar-stats {
  display: flex; gap: 20px; flex-wrap: wrap;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 24px;
}
.cal-stat { font-size: 0.85rem; color: var(--text2); }
.cal-stat strong { color: var(--text); font-weight: 700; font-size: 1rem; }

/* ─── Profiles ──────────────────────────────────────────────────────────────── */
.profiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.profile-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.15s;
}
.profile-card:hover { border-color: var(--primary); }
.profile-card-active { border-color: var(--primary) !important; }
.profile-card-new { border-style: dashed; }
.profile-card-header { display: flex; justify-content: space-between; align-items: flex-start; }
.profile-card h3 { font-size: 1rem; font-weight: 700; }
.profile-desc { font-size: 0.85rem; color: var(--text2); }
.profile-created { font-size: 0.75rem; color: var(--text2); margin-top: -4px; }
.profile-card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }

/* Color picker */
.color-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.color-option { cursor: pointer; }
.color-option input { display: none; }
.color-dot { width: 28px; height: 28px; border-radius: 50%; display: block; transition: transform 0.15s, box-shadow 0.15s; }
.color-option input:checked + .color-dot { transform: scale(1.2); box-shadow: 0 0 0 3px white; }
.color-option:hover .color-dot { transform: scale(1.15); }

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .editor-layout { grid-template-columns: 1fr; }
  .editor-sidebar { position: static; }
}
@media (max-width: 768px) {
  .sidebar { width: 200px; min-width: 200px; }
  .main-content { padding: 20px 16px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .calendar-grid { font-size: 0.7rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .app-layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
