/* =========================================================
   SPLASHES — Global Design System
   ========================================================= */

/* CSS Variables — Light & Dark Themes */
:root {
  --font-body: 'Space Grotesk', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  --bg-body: #f6f7f9;
  --bg-surface: #ffffff;
  --bg-surface-2: #f0f1f4;
  --bg-elevated: #ffffff;

  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  --border-color: #e2e8f0;
  --border-subtle: #f1f5f9;

  --accent: #0f172a;
  --accent-hover: #1e293b;
  --accent-light: #e2e8f0;

  --success: #22c55e;
  --error: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.08);

  --max-width: 680px;
  --header-height: 64px;
}

[data-theme="dark"] {
  --bg-body: #0f172a;
  --bg-surface: #1e293b;
  --bg-surface-2: #162032;
  --bg-elevated: #243447;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0f172a;

  --border-color: #334155;
  --border-subtle: #1e293b;

  --accent: #f8fafc;
  --accent-hover: #e2e8f0;
  --accent-light: #334155;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.4);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

/* =========================================================
   Typography
   ========================================================= */

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }

.text-secondary { color: var(--text-secondary); }
.text-muted    { color: var(--text-muted); }
.text-sm       { font-size: 0.875rem; }
.text-xs       { font-size: 0.75rem; }
.font-mono     { font-family: var(--font-mono); }

/* =========================================================
   Layout — App Shell
   ========================================================= */

#app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#main-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

#brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
}

#logo-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.125rem;
}

#brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#brand-name {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
  line-height: 1;
}

#brand-tagline {
  font-size: 0.625rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
}

#header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* =========================================================
   Buttons
   ========================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: var(--text-inverse);
}
.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}
.btn-ghost:hover {
  background: var(--bg-surface-2);
}

.btn-danger {
  background: var(--error);
  color: #fff;
}
.btn-danger:hover {
  opacity: 0.9;
}

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

.header-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background 0.15s ease;
}
.header-btn:hover {
  background: var(--bg-surface-2);
}

/* Avatar */
.avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border-color);
}

.avatar-lg {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border-color);
}

/* =========================================================
   Main Content Area
   ========================================================= */

#app-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

#side-nav {
  width: 240px;
  border-right: 1px solid var(--border-color);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  padding: 16px 0;
  z-index: 50;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
  flex-shrink: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#side-nav::-webkit-scrollbar {
  display: none;
}
#side-nav.collapsed {
  width: 64px;
  padding: 16px 0;
}
#side-nav.collapsed .nav-label,
#side-nav.collapsed .nav-text {
  opacity: 0;
  pointer-events: none;
  width: 0;
  overflow: hidden;
}
#side-nav.collapsed .nav-item {
  justify-content: center;
  padding: 12px 0;
  gap: 0;
}
#side-nav.collapsed .nav-section {
  padding: 0 12px;
}
#sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  margin: 0 auto 16px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  transition: all 0.2s;
  flex-shrink: 0;
}
#sidebar-toggle:hover {
  background: var(--bg-surface-2);
}
#side-nav.collapsed #sidebar-toggle {
  transform: rotate(180deg);
}
.nav-section {
  padding: 0 16px;
  margin-bottom: 20px;
  transition: opacity 0.2s;
}
.nav-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  font-weight: 600;
  transition: opacity 0.2s;
  white-space: nowrap;
  margin-bottom: 12px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s;
  margin-bottom: 4px;
  text-decoration: none;
  white-space: nowrap;
}
.nav-item:hover,
.nav-item.active {
  background: var(--bg-surface-2);
  color: var(--text-primary);
}
.nav-item.active {
  font-weight: 600;
}
.nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cat-country { border-left: 3px solid #3b82f6; }
.cat-finance { border-left: 3px solid #10b981; }
.cat-sports { border-left: 3px solid #f59e0b; }
.cat-studies { border-left: 3px solid #8b5cf6; }
.cat-medical { border-left: 3px solid #ef4444; }
.cat-global { border-left: 3px solid #6b7280; }

#main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  background: var(--bg-body);
  padding: 20px 16px 40px;
}
#main-content::-webkit-scrollbar {
  width: 6px;
}
#main-content::-webkit-scrollbar-track {
  background: transparent;
}
#main-content::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}
#main-content::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* =========================================================
   Cards
   ========================================================= */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  transition: box-shadow 0.2s ease;
}
.card:hover {
  box-shadow: var(--shadow-md);
}

.card-compact {
  padding: 16px;
}

/* =========================================================
   Forms
   ========================================================= */

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

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

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9375rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}
[data-theme="dark"] .form-input:focus,
[data-theme="dark"] .form-textarea:focus,
[data-theme="dark"] .form-select:focus {
  box-shadow: 0 0 0 3px rgba(248, 250, 252, 0.08);
}

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

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-error {
  font-size: 0.75rem;
  color: var(--error);
  margin-top: 4px;
}

/* =========================================================
   Auth Pages
   ========================================================= */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

.auth-card h1 {
  text-align: center;
  margin-bottom: 8px;
}

.auth-subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 24px;
  font-size: 0.875rem;
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.auth-footer a {
  color: var(--text-primary);
  font-weight: 500;
  text-decoration: underline;
}

/* =========================================================
   Feed / Post Cards
   ========================================================= */

.post-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  transition: box-shadow 0.2s ease;
}
.post-card:hover {
  box-shadow: var(--shadow-md);
}

.post-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.post-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.post-author {
  font-weight: 600;
  font-size: 0.9375rem;
}

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

.post-body {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-primary);
  margin-bottom: 12px;
  word-wrap: break-word;
}

.post-actions {
  display: flex;
  gap: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.post-action {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: color 0.15s ease;
}
.post-action:hover {
  color: var(--text-primary);
}

.post-action.active {
  color: var(--error);
}

/* =========================================================
   Profile Header
   ========================================================= */

.profile-header {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
  text-align: center;
}

.profile-header .avatar-lg {
  margin: 0 auto 16px;
}

.profile-name {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.profile-username {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.profile-bio {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  max-width: 400px;
  margin: 0 auto 16px;
}

.profile-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
}

.stat {
  text-align: center;
}
.stat-value {
  font-weight: 700;
  font-size: 1.125rem;
}
.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* =========================================================
   Tabs
   ========================================================= */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 16px;
  overflow-x: auto;
}

.tab {
  padding: 10px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}
.tab:hover {
  color: var(--text-primary);
}
.tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

/* =========================================================
   Empty / Loading States
   ========================================================= */

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state svg {
  margin-bottom: 12px;
  opacity: 0.5;
}

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

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

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--bg-surface-2) 25%, var(--border-subtle) 50%, var(--bg-surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* =========================================================
   Toast Notifications
   ========================================================= */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 12px 20px;
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 1000;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error   { border-left: 4px solid var(--error); }
.toast-info    { border-left: 4px solid var(--info); }

/* =========================================================
   Mobile Navigation
   ========================================================= */

#mobile-nav {
  display: none;
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-surface);
  z-index: 99;
  padding: 16px;
  flex-direction: column;
  gap: 4px;
}

#mobile-nav.open {
  display: flex;
}

.mobile-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
  transition: background 0.15s ease;
}
.mobile-nav-item:hover {
  background: var(--bg-surface-2);
}

/* Bottom nav for mobile */
#bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  z-index: 100;
  justify-content: space-around;
  align-items: center;
  padding: 0 8px;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.625rem;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-md);
}
.bottom-nav-item.active {
  color: var(--text-primary);
}

/* =========================================================
   Utilities
   ========================================================= */

.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.w-full { width: 100%; }
.text-center { text-align: center; }

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 640px) {
  #brand-tagline { display: none; }
  #create-btn span { display: none; }
  #create-btn { padding: 8px; }

  #side-nav {
    display: none;
  }

  #bottom-nav {
    display: flex;
  }

  #main-content {
    padding-bottom: 72px; /* space for bottom nav */
  }

  .auth-card {
    padding: 24px 20px;
  }

  .profile-stats {
    gap: 20px;
  }
}

@media (min-width: 641px) {
  #btn-menu { display: none !important; }
}
