/* === shadcn/ui inspired design system === */

/* Light theme (default) */
:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 240 10% 3.9%;
  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;
  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --accent: 240 4.8% 95.9%;
  --accent-foreground: 240 5.9% 10%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 240 5.9% 10%;
  --radius: 0.5rem;
  --success: 142 76% 36%;
  --warning: 38 92% 50%;
}

/* Dark theme */
@media (prefers-color-scheme: dark) {
  :root {
    --background: 240 10% 3.9%;
    --foreground: 0 0% 98%;
    --card: 240 10% 3.9%;
    --card-foreground: 0 0% 98%;
    --popover: 240 10% 3.9%;
    --popover-foreground: 0 0% 98%;
    --primary: 0 0% 98%;
    --primary-foreground: 240 5.9% 10%;
    --secondary: 240 3.7% 15.9%;
    --secondary-foreground: 0 0% 98%;
    --muted: 240 3.7% 15.9%;
    --muted-foreground: 240 5% 64.9%;
    --accent: 240 3.7% 15.9%;
    --accent-foreground: 0 0% 98%;
    --destructive: 0 62.8% 30.6%;
    --destructive-foreground: 0 0% 98%;
    --border: 240 3.7% 15.9%;
    --input: 240 3.7% 15.9%;
    --ring: 240 4.9% 83.9%;
    --success: 142 76% 36%;
    --warning: 38 92% 50%;
  }
}

/* Manual dark mode toggle class */
.dark {
  --background: 240 10% 3.9%;
  --foreground: 0 0% 98%;
  --card: 240 10% 3.9%;
  --card-foreground: 0 0% 98%;
  --popover: 240 10% 3.9%;
  --popover-foreground: 0 0% 98%;
  --primary: 0 0% 98%;
  --primary-foreground: 240 5.9% 10%;
  --secondary: 240 3.7% 15.9%;
  --secondary-foreground: 0 0% 98%;
  --muted: 240 3.7% 15.9%;
  --muted-foreground: 240 5% 64.9%;
  --accent: 240 3.7% 15.9%;
  --accent-foreground: 0 0% 98%;
  --destructive: 0 62.8% 30.6%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 3.7% 15.9%;
  --input: 240 3.7% 15.9%;
  --ring: 240 4.9% 83.9%;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* === Typography === */
h1, h2, h3, h4, h5, h6 {
  color: hsl(var(--foreground));
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

a {
  color: hsl(var(--foreground));
  text-decoration: none;
  transition: color 0.15s;
}

a:hover {
  color: hsl(var(--muted-foreground));
}

p {
  color: hsl(var(--muted-foreground));
  line-height: 1.7;
}

small, .text-muted {
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}

/* === Layout === */
.container {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.main-content {
  padding-top: 5rem;
  padding-bottom: 3rem;
}

/* === Navbar === */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 3.5rem;
  padding: 0 1.5rem;
  background-color: hsl(var(--background) / 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid hsl(var(--border));
}

.navbar-brand {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  transition: background-color 0.15s, color 0.15s;
  color: hsl(var(--muted-foreground));
}

.nav-link:hover {
  background-color: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.nav-link svg {
  width: 1rem;
  height: 1rem;
}

/* === Card === */
.card {
  background-color: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.card-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  transition: color 0.15s;
}

.card-title:hover {
  color: hsl(var(--muted-foreground));
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}

.card-content {
  color: hsl(var(--muted-foreground));
  white-space: pre-line;
  font-size: 0.9375rem;
  line-height: 1.7;
}

/* === Avatar === */
.avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 9999px;
  object-fit: cover;
  border: 1px solid hsl(var(--border));
  background-color: hsl(var(--muted));
  padding: 0;
}

.avatar[src$=".svg"] {
  padding: 0.35rem;
  color: hsl(var(--muted-foreground));
}

.avatar-sm {
  width: 2rem;
  height: 2rem;
}

.avatar-lg {
  width: 5rem;
  height: 5rem;
}

/* === Button === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
  text-decoration: none;
  line-height: 1.25;
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

.btn-primary {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}

.btn-primary:hover {
  background-color: hsl(var(--primary) / 0.9);
  color: hsl(var(--primary-foreground));
}

.btn-secondary {
  background-color: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}

.btn-secondary:hover {
  background-color: hsl(var(--secondary) / 0.8);
  color: hsl(var(--secondary-foreground));
}

.btn-outline {
  background-color: transparent;
  border-color: hsl(var(--input));
  color: hsl(var(--foreground));
}

.btn-outline:hover {
  background-color: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.btn-destructive {
  background-color: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

.btn-destructive:hover {
  background-color: hsl(var(--destructive) / 0.9);
  color: hsl(var(--destructive-foreground));
}

.btn-ghost {
  background-color: transparent;
  color: hsl(var(--foreground));
}

.btn-ghost:hover {
  background-color: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.btn-sm {
  padding: 0.25rem 0.75rem;
  font-size: 0.8125rem;
}

/* === Form === */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
  color: hsl(var(--foreground));
}

.form-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.5;
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

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

.form-input.is-invalid {
  border-color: hsl(var(--destructive));
}

.form-input.is-invalid:focus {
  box-shadow: 0 0 0 2px hsl(var(--destructive) / 0.2);
}

textarea.form-input {
  min-height: 8rem;
  resize: vertical;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.form-check input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  border-radius: 0.25rem;
  border: 1px solid hsl(var(--input));
  accent-color: hsl(var(--primary));
}

.form-check label {
  font-size: 0.875rem;
  color: hsl(var(--foreground));
}

.invalid-feedback {
  font-size: 0.8125rem;
  color: hsl(var(--destructive));
  margin-top: 0.25rem;
}

.form-file {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}

/* === Alert/Flash === */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  border: 1px solid;
}

.alert-success {
  background-color: hsl(var(--success) / 0.1);
  border-color: hsl(var(--success) / 0.3);
  color: hsl(var(--success));
}

.alert-danger, .alert-error {
  background-color: hsl(var(--destructive) / 0.1);
  border-color: hsl(var(--destructive) / 0.3);
  color: hsl(var(--destructive));
}

.alert-warning {
  background-color: hsl(var(--warning) / 0.1);
  border-color: hsl(var(--warning) / 0.3);
  color: hsl(var(--warning));
}

.alert-info {
  background-color: hsl(var(--primary) / 0.1);
  border-color: hsl(var(--primary) / 0.3);
  color: hsl(var(--foreground));
}

/* === Badge === */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
  border: 1px solid hsl(var(--border));
  background-color: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}

/* === Separator === */
.separator {
  height: 1px;
  background-color: hsl(var(--border));
  margin: 1.5rem 0;
}
.card .separator {
  margin: 0.75rem 0;
}

/* === Pagination === */
.pagination {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}

.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  font-size: 0.875rem;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--input));
  color: hsl(var(--foreground));
  transition: background-color 0.15s;
}

.pagination a:hover {
  background-color: hsl(var(--accent));
}

.pagination .active {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}

.pagination .ellipsis {
  border: none;
  color: hsl(var(--muted-foreground));
}

/* === Modal/Dialog === */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background-color: hsl(var(--background) / 0.8);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
}

.modal-overlay:target {
  display: flex;
}

.modal {
  background-color: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 28rem;
  width: 90%;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.modal-body {
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* === Profile section === */
.profile-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.profile-info h2 {
  font-size: 1.5rem;
}

.profile-info p {
  font-size: 0.875rem;
}

/* === Page header === */
.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
}

.page-header p {
  margin-top: 0.25rem;
}

/* === Error page === */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 50vh;
  gap: 0.75rem;
}

.error-page h1 {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.05em;
}

.error-page p {
  font-size: 1rem;
  max-width: 24rem;
}

/* === Utility === */
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.gap-2 { gap: 0.5rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-center { text-align: center; }
.w-full { width: 100%; }

/* === Prose (Markdown) === */
.prose h1, .prose h2, .prose h3 { margin: 1rem 0 0.5rem; font-weight: 600; }
.prose h1 { font-size: 1.5rem; }
.prose h2 { font-size: 1.25rem; }
.prose h3 { font-size: 1.1rem; }
.prose p { margin: 0.5rem 0; }
.prose ul, .prose ol { padding-left: 1.5rem; margin: 0.5rem 0; }
.prose li { margin: 0.25rem 0; }
.prose code { background: hsl(var(--muted)); padding: 0.15rem 0.3rem; border-radius: 3px; font-size: 0.85em; }
.prose pre { background: hsl(var(--muted)); padding: 0.75rem; border-radius: var(--radius); overflow-x: auto; margin: 0.5rem 0; }
.prose pre code { background: none; padding: 0; }
.prose blockquote { border-left: 3px solid hsl(var(--border)); padding-left: 1rem; margin: 0.5rem 0; color: hsl(var(--muted-foreground)); }
.prose table { border-collapse: collapse; width: 100%; margin: 0.5rem 0; }
.prose th, .prose td { border: 1px solid hsl(var(--border)); padding: 0.4rem 0.6rem; text-align: left; }
.prose img { max-width: 100%; }
.prose a { color: hsl(var(--primary)); text-decoration: underline; }

/* === Stats Grid === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.stats-grid .card {
  text-align: center;
}

.stats-grid .card h2 {
  font-size: 2rem;
  margin-top: 0.25rem;
}
