/* ============================================================
   SocialForge AI — Design System
   Base tokens, spacing, typography, and shared utilities.
   ============================================================ */

/* ---- Color Tokens (Light Mode Default) ---- */
:root {
  /* Backgrounds */
  --bg-root: #F9FAFB;
  --bg-surface: #FFFFFF;
  --bg-elevated: #FFFFFF;
  --bg-hover: #F3F4F6;
  --bg-active: #ECFDF5;
  --bg-sidebar: #FFFFFF;
  --bg-nav-hover: #F3F4F6;
  --bg-nav-active: #ECFDF5;
  --bg-input: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-overlay: rgba(0, 0, 0, 0.5);

  /* Text */
  --text-primary: #111827;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --text-inverse: #F8FAFC;

  /* Accent */
  --accent: #10B981;
  --accent-hover: #059669;
  --accent-subtle: rgba(16, 185, 129, 0.1);
  --accent-blue: #3B82F6;

  /* Borders */
  --border: #E5E7EB;
  --border-subtle: rgba(0, 0, 0, 0.06);

  /* Status */
  --status-success: #22C55E;
  --status-warning: #F59E0B;
  --status-error: #EF4444;
  --status-info: #3B82F6;

  /* Header */
  --header-bg: #FFFFFF;

  /* Scrollbar */
  --scrollbar: #D1D5DB;

  /* Spacing scale (4px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

/* ---- Dark Mode ---- */
[data-theme="dark"] {
  color-scheme: dark;

  --bg-root: #111B21;
  --bg-surface: #202C33;
  --bg-elevated: #2A3942;
  --bg-hover: #2A3942;
  --bg-active: #005C4B;
  --bg-sidebar: #1F2937;
  --bg-nav-hover: #374151;
  --bg-nav-active: #065F46;
  --bg-input: #374151;
  --bg-card: #1F2937;
  --bg-overlay: rgba(0, 0, 0, 0.7);

  --text-primary: #E9EDEF;
  --text-secondary: #8696A0;
  --text-muted: #64748B;

  --accent: #00A884;
  --accent-hover: #00C49A;
  --accent-subtle: rgba(0, 168, 132, 0.15);

  --border: #374151;
  --border-subtle: rgba(255, 255, 255, 0.06);

  --header-bg: #1F2937;
  --scrollbar: #4B5563;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.3);
}

/* Dashboard-only dark (no light mode toggle) */
.theme-admin {
  color-scheme: dark;

  --bg-root: #0f172a;
  --bg-surface: #1e293b;
  --bg-elevated: #334155;
  --bg-hover: #334155;
  --bg-sidebar: #1e293b;
  --bg-input: #1e293b;
  --bg-card: #1e293b;
  --bg-overlay: rgba(0, 0, 0, 0.6);

  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;

  --accent: #10B981;
  --accent-hover: #34D399;

  --border: #334155;
  --border-subtle: rgba(255, 255, 255, 0.06);

  --header-bg: #0f172a;
  --scrollbar: #334155;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-root);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  text-wrap: balance;
  line-height: 1.2;
  font-weight: 600;
}

/* Tabular nums for data */
.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* ---- Focus States (Vercel Guidelines) ---- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

:focus:not(:focus-visible) {
  outline: none;
}

/* ---- Scrollbar ---- */
.custom-scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
}

.custom-scroll::-webkit-scrollbar {
  width: 6px;
}

.custom-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.custom-scroll::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar);
  border-radius: 3px;
}

.custom-scroll::-webkit-scrollbar-thumb:hover {
  opacity: 0.8;
}

/* ---- Animations ---- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

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

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.animate-fade-in  { animation: fadeIn 0.2s ease-out; }
.animate-slide-up { animation: slideUp 0.3s ease-out; }
.animate-spin     { animation: spin 1s linear infinite; }
.animate-pulse    { animation: pulse 2s ease-in-out infinite; }

/* Honor prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---- Transition utilities (NO transition: all) ---- */
.transition-colors {
  transition-property: background-color, border-color, color;
  transition-duration: 200ms;
  transition-timing-function: ease;
}

.transition-opacity {
  transition-property: opacity;
  transition-duration: 200ms;
  transition-timing-function: ease;
}

.transition-transform {
  transition-property: transform;
  transition-duration: 200ms;
  transition-timing-function: ease;
}

.transition-shadow {
  transition-property: box-shadow;
  transition-duration: 200ms;
  transition-timing-function: ease;
}

/* ---- Shared Components ---- */

/* Card */
.sf-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

/* Glass morphism */
.sf-glass {
  background: rgba(30, 41, 59, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
}

/* Nav item */
.sf-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  cursor: pointer;
  transition-property: background-color, color;
  transition-duration: 200ms;
  text-decoration: none;
}

.sf-nav-item:hover {
  background-color: var(--bg-nav-hover);
}

.sf-nav-item.active {
  background-color: var(--bg-nav-active);
  color: var(--accent);
  font-weight: 600;
}

/* Buttons */
.sf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition-property: background-color, color, box-shadow, opacity;
  transition-duration: 200ms;
  white-space: nowrap;
}

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

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

.sf-btn-primary:hover:not(:disabled) {
  background-color: var(--accent-hover);
}

.sf-btn-secondary {
  background-color: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.sf-btn-secondary:hover:not(:disabled) {
  background-color: var(--bg-hover);
}

.sf-btn-danger {
  background-color: rgba(239, 68, 68, 0.1);
  color: #EF4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.sf-btn-danger:hover:not(:disabled) {
  background-color: rgba(239, 68, 68, 0.2);
}

/* Badges */
.sf-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
}

.sf-badge-success {
  background-color: rgba(34, 197, 94, 0.15);
  color: #22C55E;
}

.sf-badge-warning {
  background-color: rgba(245, 158, 11, 0.15);
  color: #F59E0B;
}

.sf-badge-error {
  background-color: rgba(239, 68, 68, 0.15);
  color: #EF4444;
}

.sf-badge-info {
  background-color: rgba(59, 130, 246, 0.15);
  color: #3B82F6;
}

/* Inputs */
.sf-input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition-property: border-color, box-shadow;
  transition-duration: 200ms;
}

.sf-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
  outline: none;
}

.sf-input::placeholder {
  color: var(--text-muted);
}

/* Modal overlay */
.sf-modal-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: var(--space-4);
}

.sf-modal {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease-out;
}

/* Toast */
.sf-toast {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  z-index: 100;
  animation: slideUp 0.3s ease-out;
  box-shadow: var(--shadow-lg);
}

/* Empty state */
.sf-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-6);
  text-align: center;
  color: var(--text-muted);
}

.sf-empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: var(--space-4);
  opacity: 0.4;
}

.sf-empty-state h3 {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.sf-empty-state p {
  font-size: 0.875rem;
  max-width: 320px;
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .hide-tablet { display: none !important; }
}

@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
}

/* ---- Print ---- */
@media print {
  .no-print { display: none !important; }
}
