/* SM8 Marketing Manager - App Styles */

:root {
  --primary: #0066CC;
  --primary-dark: #0052a3;
  --primary-light: #e8f0fb;
  --success: #28a745;
  --warning: #ffc107;
  --danger: #dc3545;
  --info: #17a2b8;
  --dark: #1a1a2e;
  --grey: #6c757d;
  --light-grey: #f8f9fa;
  --border: #dee2e6;
  --text: #212529;
  --text-muted: #6c757d;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius: 10px;
  --radius-sm: 6px;

  /* Platform colours */
  --facebook: #1877F2;
  --instagram: #E4405F;
  --linkedin: #0A66C2;
  --twitter: #000000;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ─── Layout ───────────────────────────────────────────────────────────────── */

.app-wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: var(--dark);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo h2 {
  font-size: 14px;
  font-weight: 700;
  color: white;
  letter-spacing: 0.5px;
}

.sidebar-logo span {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  display: block;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  transition: all 0.15s;
  border-left: 3px solid transparent;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
}

.nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: white;
}

.nav-item.active {
  background: rgba(0,102,204,0.25);
  color: white;
  border-left-color: var(--primary);
}

.nav-item svg { flex-shrink: 0; opacity: 0.8; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 11px;
  color: rgba(255,255,255,0.3);
}

.main-content {
  margin-left: 220px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h1 { font-size: 18px; font-weight: 600; }

.page-body {
  padding: 24px;
  flex: 1;
}

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

.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

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

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── Stats grid ───────────────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

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

.stat-change {
  margin-top: 6px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ─── Social connect cards ─────────────────────────────────────────────────── */

.social-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.social-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transition: all 0.2s;
  cursor: pointer;
}

.social-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.social-card.connected { border-color: var(--success); background: #f0fff4; }

.social-card .platform-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 22px;
}

.platform-icon.facebook { background: var(--facebook); }
.platform-icon.instagram { background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888); }
.platform-icon.linkedin { background: var(--linkedin); }
.platform-icon.twitter { background: var(--twitter); }

.social-card .platform-name { font-weight: 600; font-size: 14px; }
.social-card .platform-status { font-size: 12px; color: var(--text-muted); }
.social-card.connected .platform-status { color: var(--success); }
.social-card .platform-user { font-size: 12px; color: var(--text-muted); text-align: center; }

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #218838; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #c82333; }

.btn-outline {
  background: white;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }

.btn-ghost { background: transparent; color: var(--grey); }
.btn-ghost:hover { background: var(--light-grey); color: var(--text); }

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

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

/* ─── Post list ────────────────────────────────────────────────────────────── */

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

.post-item {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: grid;
  grid-template-columns: 60px 1fr auto;
  gap: 16px;
  align-items: start;
}

.post-thumb {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--light-grey);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--grey);
  font-size: 24px;
}

.post-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius-sm); }

.post-caption { font-size: 13px; line-height: 1.5; margin-bottom: 8px; }
.post-caption-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.post-platforms { display: flex; gap: 4px; }
.platform-badge {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 10px;
}

.platform-badge.facebook { background: var(--facebook); }
.platform-badge.instagram { background: var(--instagram); }
.platform-badge.linkedin { background: var(--linkedin); }
.platform-badge.twitter { background: var(--twitter); }

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.status-badge.draft { background: #f0f0f0; color: #666; }
.status-badge.scheduled { background: #fff3cd; color: #856404; }
.status-badge.published { background: #d4edda; color: #155724; }
.status-badge.failed { background: #f8d7da; color: #721c24; }
.status-badge.publishing { background: #cce5ff; color: #004085; }

.post-time { font-size: 11px; color: var(--text-muted); }

.post-actions { display: flex; gap: 8px; }

/* ─── Post creator / modal ─────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-size: 16px; font-weight: 600; }

.modal-body { padding: 24px; flex: 1; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ─── Form elements ────────────────────────────────────────────────────────── */

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

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: white;
  transition: border-color 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,102,204,0.1);
}

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

.platform-checkboxes {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.platform-check {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 13px;
  user-select: none;
}

.platform-check:hover { border-color: var(--primary); background: var(--primary-light); }
.platform-check.checked { border-color: var(--primary); background: var(--primary-light); color: var(--primary); font-weight: 500; }

.platform-check input { display: none; }

/* ─── Photos grid ──────────────────────────────────────────────────────────── */

.photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.photo-card {
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 1;
  position: relative;
  cursor: pointer;
  background: var(--light-grey);
}

.photo-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s;
}

.photo-card:hover img { transform: scale(1.05); }

.photo-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s;
  opacity: 0;
}

.photo-card:hover .photo-overlay { background: rgba(0,0,0,0.4); opacity: 1; }

.photo-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  color: white;
  font-size: 10px;
  padding: 16px 6px 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Analytics ────────────────────────────────────────────────────────────── */

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.chart-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.chart-card canvas { max-height: 250px; }

.platform-row {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.platform-row:last-child { border-bottom: none; }

.growth-indicator {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.growth-indicator.positive { color: var(--success); background: #d4edda; }
.growth-indicator.negative { color: var(--danger); background: #f8d7da; }
.growth-indicator.neutral { color: var(--grey); background: var(--light-grey); }

/* ─── Recommended posts ────────────────────────────────────────────────────── */

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

.recommendation-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  border-top: 4px solid var(--primary);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rec-category {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary);
}

.rec-caption {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.rec-image-hint {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--light-grey);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-style: italic;
}

.rec-footer { display: flex; align-items: center; justify-content: space-between; }

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

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: white;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  min-width: 280px;
  max-width: 380px;
  animation: slideIn 0.2s ease;
  border-left: 4px solid var(--success);
}

.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.info { border-left-color: var(--info); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

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

.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  gap: 4px;
}

.tab {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ─── Empty state ──────────────────────────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-muted);
  text-align: center;
}

.empty-state svg { opacity: 0.3; margin-bottom: 16px; }
.empty-state h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.empty-state p { font-size: 13px; margin-bottom: 20px; max-width: 320px; }

/* ─── Loading ──────────────────────────────────────────────────────────────── */

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

/* ─── Connection screen ────────────────────────────────────────────────────── */

.connect-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #0066CC 100%);
}

.connect-card {
  background: white;
  border-radius: 16px;
  padding: 40px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.connect-card .logo { font-size: 40px; margin-bottom: 16px; }
.connect-card h1 { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.connect-card p { color: var(--text-muted); margin-bottom: 28px; }

/* ─── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-logo h2, .sidebar-logo span, .nav-item span { display: none; }
  .main-content { margin-left: 60px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .photos-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .social-grid { grid-template-columns: repeat(2, 1fr); }
}
