/* ============================================
   HindiHook Wiki - Modern CSS
   ============================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #eef2ff;
  --secondary: #64748b;
  --secondary-hover: #475569;
  --background: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-hover: #cbd5e1;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --error: #ef4444;
  --error-bg: #fef2f2;
  --warning: #f59e0b;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius: 8px;
  --radius-lg: 12px;
  --transition: 150ms ease;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--background);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ============================================
   Navbar
   ============================================ */

.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.25rem;
}

.logo-icon {
  font-size: 1.5rem;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem;
  background: var(--background);
  border-radius: 100px;
  font-size: 0.875rem;
}

.user-avatar {
  width: 24px;
  height: 24px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
}

.user-name {
  color: var(--text-secondary);
}

.admin-badge {
  background: var(--primary-light);
  color: var(--primary);
  padding: 0.125rem 0.5rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* ============================================
   Main Content
   ============================================ */

.main-content {
  min-height: calc(100vh - 60px);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ============================================
   Toolbar
   ============================================ */

.toolbar {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.search-wrapper {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 3rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 0.9375rem;
  background: var(--surface);
  transition: var(--transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ============================================
   Breadcrumbs
   ============================================ */

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  flex-wrap: wrap;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition);
}

.breadcrumb-item:hover {
  color: var(--primary);
}

.breadcrumb-item.active {
  color: var(--text);
  font-weight: 500;
}

.breadcrumb-sep {
  color: var(--text-muted);
}

/* ============================================
   Loading State
   ============================================ */

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem;
  color: var(--text-secondary);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1rem;
}

.spinner-sm {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   Pages Grid
   ============================================ */

.pages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.page-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition);
}

.page-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.page-card-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.page-card-content {
  flex: 1;
  min-width: 0;
}

.page-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-slug {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-family: 'SF Mono', Monaco, monospace;
}

.page-card-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: var(--transition);
}

.page-card:hover .page-card-arrow {
  color: var(--primary);
  transform: translateX(4px);
}

/* ============================================
   Empty State
   ============================================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.25rem;
  color: var(--text);
  margin-bottom: 0.5rem;
}

/* ============================================
   Page Detail
   ============================================ */

.page-detail {
  max-width: 900px;
  margin: 0 auto;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.page-title-section h1 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

.page-meta {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.page-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.page-content {
  background: var(--surface);
  padding: 2rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  line-height: 1.8;
  font-size: 1rem;
  margin-bottom: 2rem;
}

.page-content p {
  margin-bottom: 1rem;
}

.page-content p:last-child {
  margin-bottom: 0;
}

/* ============================================
   Subpages
   ============================================ */

.subpages-section {
  margin-bottom: 2rem;
}

.subpages-section h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
}

.subpages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.subpage-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
}

.subpage-card:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.subpage-icon {
  font-size: 1.25rem;
}

.subpage-title {
  font-weight: 500;
  font-size: 0.9375rem;
}

/* ============================================
   Comments
   ============================================ */

.comments-section {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.comments-section h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

.comment-count {
  background: var(--background);
  padding: 0.125rem 0.5rem;
  border-radius: 100px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.comment-form {
  margin-bottom: 1.5rem;
}

.comment-form textarea {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9375rem;
  resize: vertical;
  min-height: 80px;
  transition: var(--transition);
}

.comment-form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.comment-form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
}

.char-count {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.comment-card {
  padding: 1rem 1.25rem;
  background: var(--background);
  border-radius: var(--radius);
  position: relative;
}

.comment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.comment-author {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.author-avatar {
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
}

.author-name {
  font-weight: 600;
  font-size: 0.9375rem;
}

.comment-time {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.comment-body {
  font-size: 0.9375rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

.comment-delete {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  padding: 0.375rem;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: var(--radius);
  transition: var(--transition);
  opacity: 0;
}

.comment-card:hover .comment-delete {
  opacity: 1;
}

.comment-delete:hover {
  background: var(--error-bg);
  color: var(--error);
}

.no-comments {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ============================================
   Search Results
   ============================================ */

.search-results h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

.search-result-card {
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
}

.search-result-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.search-result-card h3 {
  font-size: 1.0625rem;
  margin-bottom: 0.375rem;
}

.search-result-card p {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.search-result-card mark {
  background: #fef08a;
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}

/* ============================================
   Auth Pages
   ============================================ */

.auth-page {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.auth-container {
  width: 100%;
  max-width: 420px;
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-logo {
  font-size: 3rem;
  display: block;
  margin-bottom: 1rem;
}

.auth-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.auth-header p {
  color: var(--text-secondary);
}

.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.auth-footer p {
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

/* ============================================
   Forms
   ============================================ */

.form-group {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  font-size: 0.9375rem;
}

.required {
  color: var(--error);
}

input[type="text"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9375rem;
  background: var(--surface);
  transition: var(--transition);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

small {
  display: block;
  margin-top: 0.375rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ============================================
   Buttons
   ============================================ */

button {
  font-family: inherit;
  cursor: pointer;
}

.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: none;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--background);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--background);
  color: var(--text);
}

.btn-danger {
  background: transparent;
  color: var(--text-muted);
}

.btn-danger:hover {
  background: var(--error-bg);
  color: var(--error);
}

.btn-full {
  width: 100%;
}

.form-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* ============================================
   Edit Card
   ============================================ */

.edit-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 2rem;
  border: 1px solid var(--border);
  max-width: 900px;
  margin: 0 auto;
}

.edit-card h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 2rem;
}

/* ============================================
   Notifications
   ============================================ */

.notification {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.875rem 1.25rem;
  background: var(--text);
  color: white;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1000;
  max-width: 90%;
}

.notification.show {
  transform: translateY(0);
  opacity: 1;
}

.notification-success {
  background: var(--success);
}

.notification-error {
  background: var(--error);
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
  .nav-container {
    padding: 0.75rem 1rem;
  }

  .logo-text {
    display: none;
  }

  .container {
    padding: 1rem;
  }

  .toolbar {
    flex-direction: column;
  }

  .pages-grid {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
    gap: 1rem;
  }

  .page-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .page-actions button {
    flex: 1;
    min-width: 0;
  }

  .page-title-section h1 {
    font-size: 1.5rem;
  }

  .page-content {
    padding: 1.25rem;
  }

  .auth-card {
    padding: 1.5rem;
  }

  .form-actions {
    flex-direction: column-reverse;
  }

  .subpages-grid {
    grid-template-columns: 1fr;
  }

  .notification {
    left: 1rem;
    right: 1rem;
  }
}

@media (max-width: 480px) {
  .user-badge {
    padding: 0.25rem;
  }

  .user-name,
  .admin-badge {
    display: none;
  }

  .btn-ghost span,
  .btn-secondary span,
  .btn-primary span {
    display: none;
  }

  .page-actions button {
    padding: 0.625rem;
  }
}