/* SocialSync - Main App CSS */
:root {
  --primary: #4361ee;
  --primary-dark: #3245d4;
  --instagram: #E1306C;
  --facebook: #1877F2;
  --linkedin: #0A66C2;
  --sidebar-width: 260px;
  --topbar-height: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Auth Page */
.auth-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 40%, #f093fb 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  background: white;
  border-radius: 24px;
  padding: 48px 40px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.15);
  animation: slideUp 0.4s ease;
}

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

.brand-logo { 
  display: flex; align-items: center; gap: 12px; margin-bottom: 32px; 
  justify-content: center;
}
.brand-logo .logo-icon {
  width: 48px; height: 48px; border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), #764ba2);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 22px;
}
.brand-logo .logo-text { font-size: 26px; font-weight: 800; color: #1e293b; }
.brand-logo .logo-text span { color: var(--primary); }

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 14px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.form-input {
  width: 100%; padding: 12px 16px; border: 2px solid #e5e7eb; border-radius: 12px;
  font-size: 15px; transition: all 0.2s; outline: none; background: #f9fafb;
}
.form-input:focus { border-color: var(--primary); background: white; box-shadow: 0 0 0 3px rgba(67,97,238,0.1); }
.form-input.error { border-color: #ef4444; }

.btn { 
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 24px; border-radius: 12px; font-size: 15px; font-weight: 600;
  cursor: pointer; border: none; transition: all 0.2s; text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(67,97,238,0.4); }
.btn-block { width: 100%; }
.btn-outline { background: transparent; border: 2px solid #e5e7eb; color: #374151; }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: rgba(67,97,238,0.05); }
.btn-sm { padding: 8px 16px; font-size: 13px; border-radius: 8px; }
.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: #10b981; color: white; }
.btn-success:hover { background: #059669; }
.btn-ghost { background: transparent; color: #6b7280; }
.btn-ghost:hover { background: #f3f4f6; color: #374151; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; }

.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: #e5e7eb; }
.divider span { color: #9ca3af; font-size: 13px; }

.oauth-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 4px; }
.oauth-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 8px; border-radius: 12px; border: 2px solid; cursor: pointer;
  font-size: 13px; font-weight: 600; transition: all 0.2s; background: transparent;
}
.oauth-btn.instagram { border-color: var(--instagram); color: var(--instagram); }
.oauth-btn.instagram:hover { background: var(--instagram); color: white; }
.oauth-btn.facebook { border-color: var(--facebook); color: var(--facebook); }
.oauth-btn.facebook:hover { background: var(--facebook); color: white; }
.oauth-btn.linkedin { border-color: var(--linkedin); color: var(--linkedin); }
.oauth-btn.linkedin:hover { background: var(--linkedin); color: white; }

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

.sidebar {
  width: var(--sidebar-width); background: #0f172a; color: white;
  display: flex; flex-direction: column; position: fixed; left: 0; top: 0;
  height: 100vh; z-index: 100; transition: transform 0.3s ease;
}
.sidebar-header {
  padding: 20px 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; }
.sidebar-logo .logo-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #764ba2);
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.sidebar-logo .logo-text { font-size: 18px; font-weight: 800; }
.sidebar-logo .logo-text span { color: #818cf8; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-section-title { font-size: 10px; font-weight: 700; color: #475569; text-transform: uppercase; letter-spacing: 0.1em; padding: 12px 8px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  cursor: pointer; transition: all 0.15s; color: #94a3b8; font-size: 14px; font-weight: 500;
  margin-bottom: 2px; text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,0.07); color: #e2e8f0; }
.nav-item.active { background: rgba(67,97,238,0.2); color: #818cf8; }
.nav-item .nav-icon { width: 20px; text-align: center; font-size: 16px; }
.nav-badge { margin-left: auto; background: var(--primary); color: white; font-size: 11px; padding: 2px 7px; border-radius: 10px; font-weight: 700; }

.sidebar-footer { padding: 16px 12px; border-top: 1px solid rgba(255,255,255,0.08); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; cursor: pointer; }
.user-card:hover { background: rgba(255,255,255,0.07); }
.user-avatar { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: white; flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; }
.user-info .user-name { font-size: 13px; font-weight: 600; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .user-email { font-size: 11px; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Main Content */
.main-content { flex: 1; margin-left: var(--sidebar-width); display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  height: var(--topbar-height); background: white; border-bottom: 1px solid #e5e7eb;
  display: flex; align-items: center; padding: 0 28px; position: sticky; top: 0; z-index: 50;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.topbar-title { font-size: 18px; font-weight: 700; color: #1e293b; }
.topbar-subtitle { font-size: 13px; color: #64748b; margin-top: 1px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.page-content { flex: 1; padding: 28px; }

/* Cards */
.card {
  background: white; border-radius: 16px; border: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.card-header { padding: 20px 24px; border-bottom: 1px solid #f1f5f9; display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 16px; font-weight: 700; color: #1e293b; }
.card-body { padding: 24px; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: white; border-radius: 16px; padding: 20px; border: 1px solid #e5e7eb;
  display: flex; align-items: flex-start; gap: 16px; transition: box-shadow 0.2s;
}
.stat-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.stat-value { font-size: 26px; font-weight: 800; color: #1e293b; line-height: 1; }
.stat-label { font-size: 13px; color: #64748b; margin-top: 4px; }
.stat-change { font-size: 12px; margin-top: 6px; font-weight: 600; }
.stat-change.up { color: #10b981; }
.stat-change.down { color: #ef4444; }

/* Platform Cards */
.platform-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.platform-card {
  background: white; border-radius: 16px; padding: 20px; border: 1px solid #e5e7eb;
  transition: all 0.2s;
}
.platform-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); transform: translateY(-2px); }
.platform-card .platform-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.platform-badge { display: flex; align-items: center; gap: 8px; }
.platform-icon { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: white; font-size: 18px; }
.platform-icon.instagram { background: linear-gradient(135deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888); }
.platform-icon.facebook { background: var(--facebook); }
.platform-icon.linkedin { background: var(--linkedin); }
.platform-name { font-size: 15px; font-weight: 700; }
.connected-badge { padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.connected-badge.connected { background: #dcfce7; color: #16a34a; }
.connected-badge.disconnected { background: #fee2e2; color: #dc2626; }
.platform-stat { margin-top: 6px; }
.platform-stat-value { font-size: 22px; font-weight: 800; }
.platform-stat-label { font-size: 12px; color: #64748b; }
.platform-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid #f1f5f9; }
.metric-item { text-align: center; }
.metric-value { font-size: 15px; font-weight: 700; color: #1e293b; }
.metric-label { font-size: 11px; color: #94a3b8; }

/* Post Composer */
.composer { background: white; border-radius: 16px; border: 1px solid #e5e7eb; overflow: hidden; }
.composer-header { padding: 16px 20px; border-bottom: 1px solid #f1f5f9; }
.composer-body { padding: 20px; }
.platform-toggles { display: flex; gap: 10px; flex-wrap: wrap; }
.platform-toggle {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px;
  border-radius: 10px; border: 2px solid #e5e7eb; cursor: pointer;
  font-size: 13px; font-weight: 600; transition: all 0.2s; user-select: none;
  color: #64748b; background: #f9fafb;
}
.platform-toggle.instagram.selected { border-color: var(--instagram); color: var(--instagram); background: rgba(225,48,108,0.05); }
.platform-toggle.facebook.selected { border-color: var(--facebook); color: var(--facebook); background: rgba(24,119,242,0.05); }
.platform-toggle.linkedin.selected { border-color: var(--linkedin); color: var(--linkedin); background: rgba(10,102,194,0.05); }
.platform-toggle:hover { border-color: #94a3b8; }

.content-textarea {
  width: 100%; min-height: 140px; padding: 14px; border: 2px solid #e5e7eb; border-radius: 12px;
  font-size: 15px; resize: vertical; font-family: inherit; line-height: 1.6; outline: none;
  transition: border-color 0.2s; background: #f9fafb;
}
.content-textarea:focus { border-color: var(--primary); background: white; }
.char-count { font-size: 12px; color: #94a3b8; text-align: right; }
.char-count.warn { color: #f59e0b; }
.char-count.over { color: #ef4444; }

/* Post Feed */
.post-card {
  background: white; border-radius: 16px; border: 1px solid #e5e7eb; padding: 20px;
  transition: box-shadow 0.2s; margin-bottom: 16px;
}
.post-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.07); }
.post-meta { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.post-time { font-size: 12px; color: #94a3b8; }
.post-content { font-size: 15px; color: #374151; line-height: 1.7; margin-bottom: 14px; white-space: pre-wrap; }
.post-platforms { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.platform-tag { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.platform-tag.instagram { background: rgba(225,48,108,0.1); color: var(--instagram); }
.platform-tag.facebook { background: rgba(24,119,242,0.1); color: var(--facebook); }
.platform-tag.linkedin { background: rgba(10,102,194,0.1); color: var(--linkedin); }
.status-tag { padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.status-tag.published { background: #dcfce7; color: #16a34a; }
.status-tag.scheduled { background: #fef3c7; color: #d97706; }
.status-tag.draft { background: #f1f5f9; color: #64748b; }

.post-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding-top: 12px; border-top: 1px solid #f1f5f9; }
.post-stat { text-align: center; }
.post-stat-value { font-size: 16px; font-weight: 700; color: #1e293b; }
.post-stat-label { font-size: 11px; color: #94a3b8; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(4px); animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: white; border-radius: 20px; max-width: 600px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  animation: slideUp 0.3s ease;
}
.modal-header { padding: 20px 24px; border-bottom: 1px solid #f1f5f9; display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close { width: 32px; height: 32px; border-radius: 8px; border: none; background: #f1f5f9; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 16px; color: #64748b; }
.modal-close:hover { background: #e2e8f0; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid #f1f5f9; display: flex; gap: 12px; justify-content: flex-end; }

/* Tabs */
.tabs { display: flex; gap: 4px; background: #f1f5f9; padding: 4px; border-radius: 10px; margin-bottom: 24px; }
.tab { flex: 1; padding: 9px 16px; text-align: center; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600; color: #64748b; transition: all 0.2s; }
.tab.active { background: white; color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* Toasts */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 280px; max-width: 380px; padding: 14px 18px; border-radius: 12px;
  display: flex; align-items: flex-start; gap: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  animation: slideInRight 0.3s ease;
}
@keyframes slideInRight { from { opacity: 0; transform: translateX(50px); } to { opacity: 1; transform: translateX(0); } }
.toast.success { background: #10b981; color: white; }
.toast.error { background: #ef4444; color: white; }
.toast.info { background: var(--primary); color: white; }
.toast.warning { background: #f59e0b; color: white; }
.toast-icon { font-size: 16px; }
.toast-msg { flex: 1; font-size: 14px; font-weight: 500; }

/* Loading */
.spinner { width: 24px; height: 24px; border: 3px solid rgba(255,255,255,0.3); border-top: 3px solid currentColor; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay { position: fixed; inset: 0; background: white; display: flex; align-items: center; justify-content: center; z-index: 9999; flex-direction: column; gap: 16px; }
.loading-overlay .spinner { width: 40px; height: 40px; border-color: rgba(67,97,238,0.2); border-top-color: var(--primary); }

/* Chart containers */
.chart-container { position: relative; height: 260px; }

/* Responsive */
.hamburger { display: none; background: none; border: none; cursor: pointer; padding: 4px; }
.sidebar-overlay { display: none; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .hamburger { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px; color: #374151; }
  .hamburger:hover { background: #f1f5f9; }
  .sidebar-overlay { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 99; opacity: 0; pointer-events: none; transition: opacity 0.3s; }
  .sidebar-overlay.open { opacity: 1; pointer-events: all; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .platform-grid { grid-template-columns: 1fr; }
  .oauth-btns { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .auth-card { padding: 32px 24px; }
  .modal { border-radius: 16px 16px 0 0; position: fixed; bottom: 0; max-height: 85vh; max-width: 100%; width: 100%; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .toast-container { bottom: 16px; right: 16px; left: 16px; }
  .topbar { padding: 0 16px; }
  .topbar-subtitle { display: none; }
}

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

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-state .empty-icon { font-size: 56px; margin-bottom: 16px; opacity: 0.3; }
.empty-state h3 { font-size: 18px; font-weight: 700; color: #1e293b; margin-bottom: 8px; }
.empty-state p { color: #64748b; font-size: 14px; margin-bottom: 24px; }

/* Filters */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; align-items: center; }
.filter-select { padding: 8px 12px; border: 2px solid #e5e7eb; border-radius: 10px; font-size: 13px; font-weight: 500; outline: none; color: #374151; background: white; }
.filter-select:focus { border-color: var(--primary); }

/* Connect account section */
.connect-item { display: flex; align-items: center; gap: 16px; padding: 16px; border-radius: 12px; border: 1px solid #e5e7eb; margin-bottom: 12px; transition: all 0.2s; }
.connect-item:hover { border-color: #94a3b8; }
.connect-item-info { flex: 1; }
.connect-item-name { font-size: 15px; font-weight: 700; }
.connect-item-username { font-size: 13px; color: #64748b; }
.connect-item-followers { font-size: 13px; font-weight: 600; color: #374151; }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 8px; justify-content: center; margin-top: 24px; }
.page-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid #e5e7eb; background: white; cursor: pointer; font-size: 14px; font-weight: 600; color: #374151; display: flex; align-items: center; justify-content: center; }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.page-btn:hover:not(.active) { border-color: #94a3b8; background: #f9fafb; }

/* Analytics */
.metric-card { background: white; border-radius: 16px; padding: 20px; border: 1px solid #e5e7eb; }
.metric-card-label { font-size: 13px; color: #64748b; font-weight: 500; margin-bottom: 8px; }
.metric-card-value { font-size: 28px; font-weight: 800; color: #1e293b; }
.metric-card-sub { font-size: 13px; color: #94a3b8; margin-top: 4px; }

/* Tooltip */
.tooltip { position: relative; }
.tooltip::after { content: attr(data-tip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: #1e293b; color: white; font-size: 11px; padding: 5px 8px; border-radius: 6px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity 0.2s; margin-bottom: 5px; }
.tooltip:hover::after { opacity: 1; }

/* Search */
.search-box { position: relative; }
.search-box input { padding-left: 36px; }
.search-box .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #94a3b8; font-size: 14px; }

/* Scheduled picker */
.schedule-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }

/* Switch toggle */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background: #cbd5e1; transition: .3s; border-radius: 24px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background: white; transition: .3s; border-radius: 50%; }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider:before { transform: translateX(20px); }
