@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  :root {
    --background: 0 0% 100%;
    --foreground: 222.2 84% 4.9%;
    --card: 0 0% 100%;
    --card-foreground: 222.2 84% 4.9%;
    --popover: 0 0% 100%;
    --popover-foreground: 222.2 84% 4.9%;
    --primary: 222.2 47.4% 11.2%;
    --primary-foreground: 210 40% 98%;
    --secondary: 210 40% 96%;
    --secondary-foreground: 222.2 84% 4.9%;
    --muted: 210 40% 96%;
    --muted-foreground: 215.4 16.3% 46.9%;
    --accent: 210 40% 96%;
    --accent-foreground: 222.2 84% 4.9%;
    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 210 40% 98%;
    --border: 214.3 31.8% 91.4%;
    --input: 214.3 31.8% 91.4%;
    --ring: 222.2 84% 4.9%;
    --radius: 0.5rem;
  }

  .dark {
    --background: 222.2 84% 4.9%;
    --foreground: 210 40% 98%;
    --card: 222.2 84% 4.9%;
    --card-foreground: 210 40% 98%;
    --popover: 222.2 84% 4.9%;
    --popover-foreground: 210 40% 98%;
    --primary: 210 40% 98%;
    --primary-foreground: 222.2 84% 4.9%;
    --secondary: 217.2 32.6% 17.5%;
    --secondary-foreground: 210 40% 98%;
    --muted: 217.2 32.6% 17.5%;
    --muted-foreground: 215 20.2% 65.1%;
    --accent: 217.2 32.6% 17.5%;
    --accent-foreground: 210 40% 98%;
    --destructive: 0 62.8% 30.6%;
    --destructive-foreground: 210 40% 98%;
    --border: 217.2 32.6% 17.5%;
    --input: 217.2 32.6% 17.5%;
    --ring: 212.7 26.8% 83.9%;
  }
}

@layer base {
  * {
    border-color: hsl(var(--border));
  }
  
  body {
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
  }
}

@layer components {
  /* Button styles matching your existing design */
  .btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
  }
  
  .btn-primary:hover {
    background-color: hsl(var(--primary) / 0.9);
    transform: translateY(-1px);
  }
  
  .btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background-color: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
    border: 1px solid hsl(var(--border));
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
  }
  
  .btn-secondary:hover {
    background-color: hsl(var(--secondary) / 0.8);
    transform: translateY(-1px);
  }

  /* Card styles matching your existing design */
  .card {
    background-color: hsl(var(--card));
    color: hsl(var(--card-foreground));
    border: 1px solid hsl(var(--border));
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    transition: all 0.2s;
  }

  .card-hover:hover {
    box-shadow: 0 10px 25px -5px rgb(0 0 0 / 0.1), 0 4px 6px -2px rgb(0 0 0 / 0.05);
    transform: translateY(-2px);
  }

  /* Navigation styles */
  .nav-link {
    color: hsl(var(--foreground));
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.2s;
    font-weight: 500;
  }

  .nav-link:hover {
    background-color: hsl(var(--muted));
    color: hsl(var(--primary));
  }

  .nav-link.active {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
  }
}

@layer utilities {
  /* Layout utilities */
  .container {
    max-width: 80rem; /* match Next.js max-w-7xl */
    margin: 0 auto;
    padding: 0 1rem; /* base px-4 */
  }

  @media (min-width: 640px) {
    .container {
      padding: 0 1.5rem;
    }
  }

  @media (min-width: 1024px) {
    .container {
      padding: 0 2rem;
    }
  }

  /* Typography matching your existing styles */
  .prose {
    max-width: none;
    color: hsl(var(--foreground));
  }

  .prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
    color: hsl(var(--foreground));
    font-weight: 700;
    margin-top: 2rem;
    margin-bottom: 1rem;
    line-height: 1.2;
  }

  .prose h1 { font-size: 2.5rem; }
  .prose h2 { font-size: 2rem; }
  .prose h3 { font-size: 1.75rem; }
  .prose h4 { font-size: 1.5rem; }
  
  .prose p {
    margin-bottom: 1.5rem;
    color: hsl(var(--muted-foreground));
    font-size: 1.125rem;
    line-height: 1.75;
  }

  .prose ul, .prose ol {
    margin-bottom: 1.5rem;
    padding-left: 2rem;
  }

  .prose li {
    margin-bottom: 0.5rem;
    color: hsl(var(--muted-foreground));
  }

  .prose a {
    color: hsl(var(--primary));
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
  }

  .prose a:hover {
    color: hsl(var(--primary) / 0.8);
    text-decoration: underline;
  }

  .prose blockquote {
    border-left: 4px solid hsl(var(--primary));
    padding-left: 1.5rem;
    margin: 2rem 0;
    font-style: italic;
    color: hsl(var(--muted-foreground));
    background-color: hsl(var(--muted) / 0.5);
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
  }

  .prose code {
    background-color: hsl(var(--muted));
    color: hsl(var(--foreground));
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
  }

  .prose pre {
    background-color: hsl(var(--muted));
    border: 1px solid hsl(var(--border));
    border-radius: 0.5rem;
    padding: 1.5rem;
    overflow-x: auto;
    margin: 1.5rem 0;
  }

  .prose pre code {
    background: none;
    padding: 0;
    color: hsl(var(--foreground));
  }

  /* Animation */
  .animate-fadeIn {
    animation: fadeIn 0.6s ease-out forwards;
  }

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

  /* Theme toggle */
  .theme-toggle {
    background: none;
    border: 2px solid hsl(var(--border));
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: hsl(var(--foreground));
    transition: all 0.2s;
  }

  .theme-toggle:hover {
    background-color: hsl(var(--muted));
    border-color: hsl(var(--primary));
  }

  /* Additional spacing utilities */
  .min-h-screen {
    min-height: 100vh;
  }

  .sticky {
    position: sticky;
  }

  .top-0 {
    top: 0;
  }

  .z-50 {
    z-index: 50;
  }

  .backdrop-blur {
    backdrop-filter: blur(8px);
  }

  .bg-background\/95 {
    background-color: hsl(var(--background) / 0.95);
  }

  .border-b {
    border-bottom-width: 1px;
  }

  .border-border {
    border-color: hsl(var(--border));
  }

  .flex {
    display: flex;
  }

  .hidden {
    display: none;
  }

  @media (min-width: 768px) {
    .md\:flex {
      display: flex;
    }
    .md\:hidden {
      display: none;
    }
  }

  @media (min-width: 640px) {
    .sm\:block {
      display: block;
    }
  }

  .items-center {
    align-items: center;
  }

  .justify-between {
    justify-content: space-between;
  }

  .justify-center {
    justify-content: center;
  }

  .gap-1 {
    gap: 0.25rem;
  }

  .gap-2 {
    gap: 0.5rem;
  }

  .gap-4 {
    gap: 1rem;
  }

  .gap-6 {
    gap: 1.5rem;
  }

  .gap-8 {
    gap: 2rem;
  }

  .h-16 {
    height: 4rem;
  }

  .h-4 {
    height: 1rem;
  }

  .h-5 {
    height: 1.25rem;
  }

  .w-4 {
    width: 1rem;
  }

  .w-5 {
    width: 1.25rem;
  }

  .w-64 {
    width: 16rem;
  }

  .w-1 {
    width: 0.25rem;
  }

  .h-full {
    height: 100%;
  }

  .w-full {
    width: 100%;
  }

  .max-w-3xl {
    max-width: 48rem;
  }

  .max-w-4xl {
    max-width: 56rem;
  }

  .max-w-6xl {
    max-width: 72rem;
  }

  .max-w-none {
    max-width: none;
  }

  .mx-auto {
    margin-left: auto;
    margin-right: auto;
  }

  .ml-auto {
    margin-left: auto;
  }

  .mb-2 {
    margin-bottom: 0.5rem;
  }

  .mb-3 {
    margin-bottom: 0.75rem;
  }

  .mb-4 {
    margin-bottom: 1rem;
  }

  .mb-6 {
    margin-bottom: 1.5rem;
  }

  .mb-8 {
    margin-bottom: 2rem;
  }

  .mb-12 {
    margin-bottom: 3rem;
  }

  .mb-16 {
    margin-bottom: 4rem;
  }

  .mt-12 {
    margin-top: 3rem;
  }

  .mt-16 {
    margin-top: 4rem;
  }

  .mt-24 {
    margin-top: 6rem;
  }

  .py-1\.5 {
    padding-top: 0.375rem;
    padding-bottom: 0.375rem;
  }

  .py-12 {
    padding-top: 3rem;
    padding-bottom: 3rem;
  }

  .py-16 {
    padding-top: 4rem;
    padding-bottom: 4rem;
  }

  .px-3 {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .px-4 {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .px-6 {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }

  .px-8 {
    padding-left: 2rem;
    padding-right: 2rem;
  }

  .p-6 {
    padding: 1.5rem;
  }

  .p-8 {
    padding: 2rem;
  }

  .pt-4 {
    padding-top: 1rem;
  }

  .pt-8 {
    padding-top: 2rem;
  }

  .text-sm {
    font-size: 0.875rem;
    line-height: 1.25rem;
  }

  .text-lg {
    font-size: 1.125rem;
    line-height: 1.75rem;
  }

  .text-xl {
    font-size: 1.25rem;
    line-height: 1.75rem;
  }

  .text-2xl {
    font-size: 1.5rem;
    line-height: 2rem;
  }

  .text-3xl {
    font-size: 1.875rem;
    line-height: 2.25rem;
  }

  .text-4xl {
    font-size: 2.25rem;
    line-height: 2.5rem;
  }

  .text-5xl {
    font-size: 3rem;
    line-height: 1;
  }

  @media (min-width: 768px) {
    .md\:text-2xl {
      font-size: 1.5rem;
      line-height: 2rem;
    }

    .md\:text-3xl {
      font-size: 1.875rem;
      line-height: 2.25rem;
    }

    .md\:text-5xl {
      font-size: 3rem;
      line-height: 1;
    }

    .md\:p-8 {
      padding: 2rem;
    }

    .md\:col-span-2 {
      grid-column: span 2 / span 2;
    }

    .md\:grid-cols-4 {
      grid-template-columns: repeat(4, minmax(0, 1fr));
    }
  }

  @media (min-width: 1024px) {
    .lg\:text-3xl {
      font-size: 1.875rem;
      line-height: 2.25rem;
    }
  }

  .font-bold {
    font-weight: 700;
  }

  .font-semibold {
    font-weight: 600;
  }

  .font-medium {
    font-weight: 500;
  }

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

  .text-foreground {
    color: hsl(var(--foreground));
  }

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

  .text-muted-foreground {
    color: hsl(var(--muted-foreground));
  }

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

  .hover\:text-primary\/80:hover {
    color: hsl(var(--primary) / 0.8);
  }

  .transition-colors {
    transition-property: color;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
  }

  .transition-all {
    transition-property: all;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
  }

  .duration-200 {
    transition-duration: 200ms;
  }

  .duration-300 {
    transition-duration: 300ms;
  }

  .transform {
    transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
  }

  .scale-y-0 {
    --tw-scale-y: 0;
    transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
  }

  .group:hover .group-hover\:scale-y-100 {
    --tw-scale-y: 1;
    transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
  }

  .group:hover .group-hover\:text-primary {
    color: hsl(var(--primary));
  }

  .group\/link:hover .group-hover\/link\:translate-x-1 {
    --tw-translate-x: 0.25rem;
    transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
  }

  .origin-bottom {
    transform-origin: bottom;
  }

  .transition-transform {
    transition-property: transform;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
  }

  .space-y-4 > :not([hidden]) ~ :not([hidden]) {
    --tw-space-y-reverse: 0;
    margin-top: calc(1rem * calc(1 - var(--tw-space-y-reverse)));
    margin-bottom: calc(1rem * var(--tw-space-y-reverse));
  }

  .space-y-8 > :not([hidden]) ~ :not([hidden]) {
    --tw-space-y-reverse: 0;
    margin-top: calc(2rem * calc(1 - var(--tw-space-y-reverse)));
    margin-bottom: calc(2rem * var(--tw-space-y-reverse));
  }

  .space-y-2 > :not([hidden]) ~ :not([hidden]) {
    --tw-space-y-reverse: 0;
    margin-top: calc(0.5rem * calc(1 - var(--tw-space-y-reverse)));
    margin-bottom: calc(0.5rem * var(--tw-space-y-reverse));
  }

  .grid {
    display: grid;
  }

  .grid-cols-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
  }

  .relative {
    position: relative;
  }

  .absolute {
    position: absolute;
  }

  .top-0 {
    top: 0;
  }

  .left-0 {
    left: 0;
  }

  .right-3 {
    right: 0.75rem;
  }

  .top-1\/2 {
    top: 50%;
  }

  .-translate-y-1\/2 {
    --tw-translate-y: -50%;
    transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
  }

  .overflow-hidden {
    overflow: hidden;
  }

  .rounded-md {
    border-radius: 0.375rem;
  }

  .border {
    border-width: 1px;
  }

  .border-t {
    border-top-width: 1px;
  }

  .bg-muted {
    background-color: hsl(var(--muted));
  }

  .bg-muted\/30 {
    background-color: hsl(var(--muted) / 0.3);
  }

  .bg-gradient-to-b {
    background-image: linear-gradient(to bottom, var(--tw-gradient-stops));
  }

  .from-primary {
    --tw-gradient-from: hsl(var(--primary));
    --tw-gradient-to: hsl(var(--primary) / 0);
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
  }

  .to-blue-500 {
    --tw-gradient-to: #3b82f6;
  }

  .focus\:outline-none:focus {
    outline: 2px solid transparent;
    outline-offset: 2px;
  }

  .focus\:ring-2:focus {
    --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
    --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);
    box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
  }

  .focus\:ring-primary\/50:focus {
    --tw-ring-color: hsl(var(--primary) / 0.5);
  }

  .focus\:border-primary:focus {
    border-color: hsl(var(--primary));
  }

  .fill-none {
    fill: none;
  }

  .stroke-current {
    stroke: currentColor;
  }

  .stroke-2 {
    stroke-width: 2;
  }

  .stroke-linecap-round {
    stroke-linecap: round;
  }

  .stroke-linejoin-round {
    stroke-linejoin: round;
  }

  .inline {
    display: inline;
  }

  .inline-flex {
    display: inline-flex;
  }

  .mr-2 {
    margin-right: 0.5rem;
  }

  .flex-wrap {
    flex-wrap: wrap;
  }

  .text-xs {
    font-size: 0.75rem;
    line-height: 1rem;
  }

  .leading-relaxed {
    line-height: 1.625;
  }

  .shadow-sm {
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  }

  .group {
    /* Group class for hover states */
  }

  .group\/link {
    /* Group class for link hover states */
  }

  .text-decoration-none {
    text-decoration: none;
  }

  .cursor-pointer {
    cursor: pointer;
  }

  .select-none {
    user-select: none;
  }

  .appearance-none {
    appearance: none;
  }

  .resize-none {
    resize: none;
  }

  .list-none {
    list-style-type: none;
  }

  .whitespace-nowrap {
    white-space: nowrap;
  }

  .break-words {
    overflow-wrap: break-word;
  }

  .text-ellipsis {
    text-overflow: ellipsis;
  }

  .capitalize {
    text-transform: capitalize;
  }

  .lowercase {
    text-transform: lowercase;
  }

  .uppercase {
    text-transform: uppercase;
  }

  .italic {
    font-style: italic;
  }

  .not-italic {
    font-style: normal;
  }

  .tabular-nums {
    font-variant-numeric: tabular-nums;
  }

  .antialiased {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  .subpixel-antialiased {
    -webkit-font-smoothing: auto;
    -moz-osx-font-smoothing: auto;
  }
}
