/* CSS Variables */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a25;
  --bg-card: #16161f;
  --text-primary: #f0f0f5;
  --text-secondary: #9090a0;
  --text-muted: #606070;
  --accent: #e94560;
  --accent-hover: #ff5a75;
  --accent-glow: rgba(233, 69, 96, 0.3);
  --border: #2a2a35;
  --success: #4ade80;
  --error: #f87171;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.6);
  --transition: all 0.2s ease;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--accent-hover);
}

img {
  max-width: 100%;
  height: auto;
}

/* Layout */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main {
  flex: 1;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
  padding-top: 80px;
}

/* Header */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: rgba(10, 10, 15, 0.9);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 15px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.logo:hover {
  color: var(--text-primary);
}

.logo-icon {
  font-size: 1.8rem;
}

.nav {
  display: flex;
  gap: 20px;
}

.nav-link {
  color: var(--text-secondary);
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-glow);
}

.header-actions {
  display: flex;
  gap: 10px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}

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

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 15px var(--accent-glow);
}

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

.btn-secondary:hover {
  background: var(--bg-card);
  border-color: var(--text-muted);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1.1rem;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--transition);
}

.card:hover {
  border-color: var(--text-muted);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

/* Post Card */
.post-card {
  margin-bottom: 20px;
}

.post-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
}

.post-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #ff7b54);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

.post-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.post-author {
  flex: 1;
}

.post-author-name {
  font-weight: 600;
  color: var(--text-primary);
}

.post-author-handle {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

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

.post-image {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--bg-tertiary);
  cursor: pointer;
}

.post-content {
  padding: 16px;
}

.post-caption {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

.post-caption .handle {
  color: var(--accent);
  font-weight: 500;
}

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

.post-action {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  background: none;
  border: none;
  padding: 8px;
  border-radius: var(--radius-sm);
}

.post-action:hover {
  color: var(--accent);
  background: var(--accent-glow);
}

.post-action.liked svg {
  fill: var(--accent);
  stroke: var(--accent);
}

.post-action.liked {
  color: var(--accent);
}

.post-action svg {
  width: 20px;
  height: 20px;
}

/* Profile Page - Instagram Style */
.profile-header-ig {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.profile-top {
  display: flex;
  align-items: center;
  gap: 30px;
  margin-bottom: 16px;
}

.profile-avatar-ig {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #ff7b54);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: white;
  flex-shrink: 0;
}

.profile-avatar-ig img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.profile-stats-ig {
  display: flex;
  gap: 24px;
  flex: 1;
}

.profile-stat-ig {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.profile-stat-ig .stat-value {
  font-size: 1.1rem;
  font-weight: 700;
}

.profile-stat-ig .stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.profile-info {
  padding-left: 0;
}

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

.profile-bio-ig {
  font-size: 0.9rem;
  color: var(--text-primary);
  white-space: pre-wrap;
}

.profile-tabs {
  display: flex;
  justify-content: center;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.profile-tab {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-top: 1px solid transparent;
  margin-top: -1px;
}

.profile-tab.active {
  color: var(--text-primary);
  border-top-color: var(--text-primary);
}

.profile-tab svg {
  width: 24px;
  height: 24px;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.grid-item {
  position: relative;
  aspect-ratio: 1;
  cursor: pointer;
  overflow: hidden;
}

.grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.grid-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: white;
  font-weight: 600;
  opacity: 0;
  transition: var(--transition);
}

.grid-item:hover .grid-overlay {
  opacity: 1;
}

/* Legacy Profile (keep for backwards compat) */
.profile-header {
  text-align: center;
  padding: 40px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
}

.profile-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #ff7b54);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: white;
  margin: 0 auto 20px;
  box-shadow: 0 0 0 4px var(--bg-card), 0 0 0 6px var(--accent-glow);
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

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

.profile-handle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.profile-bio {
  color: var(--text-secondary);
  max-width: 400px;
  margin: 0 auto 20px;
}

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

.profile-stat {
  text-align: center;
}

.profile-stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
}

.profile-stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Single Post View */
.post-detail {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.post-detail-image {
  width: 100%;
  max-height: 600px;
  object-fit: contain;
  background: #000;
}

.comments-section {
  padding: 20px;
  border-top: 1px solid var(--border);
}

.comments-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.comment {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.comment:last-child {
  border-bottom: none;
}

.comment-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #ff7b54);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: white;
  flex-shrink: 0;
}

.comment-content {
  flex: 1;
}

.comment-author {
  font-weight: 600;
  font-size: 0.9rem;
}

.comment-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 4px;
}

.comment-time {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.no-comments {
  text-align: center;
  padding: 30px;
  color: var(--text-muted);
}

/* Explore Grid */
.explore-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.explore-item {
  aspect-ratio: 1;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}

.explore-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--transition);
}

.explore-item:hover img {
  transform: scale(1.05);
  opacity: 0.8;
}

.explore-item-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: var(--transition);
}

.explore-item:hover .explore-item-overlay {
  opacity: 1;
}

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

.form-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: var(--transition);
}

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

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

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

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  padding: 20px;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  transform: scale(0.95);
  transition: var(--transition);
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.modal-header {
  padding: 24px 24px 0;
  text-align: center;
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.modal-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.modal-body {
  padding: 24px;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.success {
  border-color: var(--success);
}

.toast.error {
  border-color: var(--error);
}

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

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 4rem;
  margin-bottom: 16px;
}

.empty-state-title {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state-text {
  margin-bottom: 20px;
}

/* Bottom Navigation (Mobile) */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
  padding: 10px 0;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 100;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.bottom-nav-item svg {
  width: 26px;
  height: 26px;
}

.bottom-nav-item.active,
.bottom-nav-item:hover {
  color: var(--text-primary);
}

@media (max-width: 640px) {
  .bottom-nav {
    display: flex;
  }
  
  .main {
    padding-bottom: 80px;
  }
  
  .desktop-only {
    display: none;
  }
}

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 30px 20px;
  text-align: center;
  margin-top: 40px;
}

.footer-content {
  max-width: 600px;
  margin: 0 auto;
}

.footer p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.footer-tagline {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 8px;
}

/* Hero Section */
.hero {
  text-align: center;
  padding: 60px 20px;
  margin-bottom: 40px;
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 1.2rem;
  color: var(--text-secondary);
  max-width: 500px;
  margin: 0 auto 30px;
}

.hero-cta {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Section headers */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-title {
  font-size: 1.2rem;
  font-weight: 600;
}

/* API Key Display */
.api-key-display {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 20px 0;
}

.api-key-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.api-key-value {
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  font-size: 0.9rem;
  color: var(--success);
  word-break: break-all;
  background: var(--bg-secondary);
  padding: 12px;
  border-radius: var(--radius-sm);
}

.api-key-warning {
  font-size: 0.85rem;
  color: var(--error);
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Responsive */
@media (max-width: 640px) {
  .header-content {
    flex-wrap: wrap;
    gap: 10px;
  }
  
  .nav {
    order: 3;
    width: 100%;
    justify-content: center;
  }
  
  .main {
    padding: 10px;
    padding-top: 120px;
    padding-bottom: 80px; /* Space for mobile nav */
  }
  
  .hero-title {
    font-size: 2rem;
  }
  
  .profile-stats {
    gap: 20px;
  }
  
  .explore-grid {
    gap: 2px;
  }
}

/* Docs Page */
.docs-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 20px;
}

.docs-title {
  font-size: 2.5rem;
  margin-bottom: 10px;
  text-align: center;
}

.docs-intro {
  text-align: center;
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-bottom: 40px;
}

.docs-section {
  margin-bottom: 40px;
}

.docs-section h2 {
  font-size: 1.5rem;
  margin-bottom: 16px;
  color: var(--accent);
}

.code-block {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  overflow-x: auto;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre;
  margin: 16px 0;
}

.warning-box {
  background: rgba(233, 69, 96, 0.1);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin: 16px 0;
}

.share-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin: 16px 0;
}

.share-box p {
  color: var(--text-secondary);
  margin: 0;
}

.api-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.9rem;
}

.api-table th,
.api-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.api-table th {
  background: var(--bg-tertiary);
  font-weight: 600;
  color: var(--text-primary);
}

.api-table td {
  color: var(--text-secondary);
}

.api-table code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
}

/* Join Banner */
.join-banner {
  background: linear-gradient(135deg, var(--accent) 0%, #ff6b8a 100%);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  text-align: center;
}

.join-banner-content h2 {
  color: white;
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.join-banner-content p {
  color: rgba(255,255,255,0.9);
  margin-bottom: 16px;
}

.join-banner-content a {
  color: white;
  text-decoration: underline;
}

.join-quick-cmd {
  background: rgba(0,0,0,0.3);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 0.75rem;
  color: white;
  overflow-x: auto;
  white-space: nowrap;
  margin-bottom: 16px;
  text-align: left;
}

.join-banner .btn {
  background: white;
  color: var(--accent);
  border: none;
}

.join-banner .btn:hover {
  background: rgba(255,255,255,0.9);
}
