/* Design System - Vercel-inspired Professional UI */

:root {
  /* Colors */
  --background: 0 0% 100%;
  --foreground: 0 0% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 0 0% 3.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 0 0% 3.9%;
  --primary: 0 0% 9%;
  --primary-foreground: 0 0% 98%;
  --secondary: 0 0% 96.1%;
  --secondary-foreground: 0 0% 9%;
  --muted: 0 0% 96.1%;
  --muted-foreground: 0 0% 45.1%;
  --accent: 0 0% 96.1%;
  --accent-foreground: 0 0% 9%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;
  --border: 0 0% 89.8%;
  --input: 0 0% 89.8%;
  --ring: 0 0% 3.9%;
  --radius: 0.5rem;
}

.dark {
  --background: 0 0% 3.9%;
  --foreground: 0 0% 98%;
  --card: 0 0% 3.9%;
  --card-foreground: 0 0% 98%;
  --popover: 0 0% 3.9%;
  --popover-foreground: 0 0% 98%;
  --primary: 0 0% 98%;
  --primary-foreground: 0 0% 9%;
  --secondary: 0 0% 14.9%;
  --secondary-foreground: 0 0% 98%;
  --muted: 0 0% 14.9%;
  --muted-foreground: 0 0% 63.9%;
  --accent: 0 0% 14.9%;
  --accent-foreground: 0 0% 98%;
  --destructive: 0 62.8% 30.6%;
  --destructive-foreground: 0 0% 98%;
  --border: 0 0% 14.9%;
  --input: 0 0% 14.9%;
  --ring: 0 0% 83.1%;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  border-color: hsl(var(--border));
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  line-height: 1.5;
}

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

h1 { font-size: 2.25rem; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

/* Button Component */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s ease;
  cursor: pointer;
  border: 1px solid transparent;
  outline: none;
  text-decoration: none;
  gap: 0.5rem;
}

.btn:disabled {
  pointer-events: none;
  opacity: 0.5;
}

.btn-primary {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  padding: 0.5rem 1rem;
  height: 2.5rem;
}

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

.btn-secondary {
  background-color: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  padding: 0.5rem 1rem;
  height: 2.5rem;
}

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

.btn-outline {
  border: 1px solid hsl(var(--input));
  background-color: transparent;
  padding: 0.5rem 1rem;
  height: 2.5rem;
}

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

.btn-ghost {
  background-color: transparent;
  padding: 0.5rem 1rem;
  height: 2.5rem;
}

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

.btn-destructive {
  background-color: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
  padding: 0.5rem 1rem;
  height: 2.5rem;
}

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

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

.btn-lg {
  height: 2.75rem;
  padding: 0.5rem 2rem;
  font-size: 0.9375rem;
}

/* Card Component */
.card {
  background-color: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border-radius: calc(var(--radius) + 2px);
  border: 1px solid hsl(var(--border));
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.card-header {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

@media (min-width: 768px) {
  .card-header {
    padding: 1.5rem;
  }
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

@media (min-width: 768px) {
  .card-title {
    font-size: 1.125rem;
    line-height: 1;
  }
}

.card-description {
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
}

@media (min-width: 768px) {
  .card-description {
    font-size: 0.875rem;
  }
}

.card-content {
  padding: 1rem;
  padding-top: 0;
}

@media (min-width: 768px) {
  .card-content {
    padding: 1.5rem;
    padding-top: 0;
  }
}

.card-footer {
  padding: 1rem;
  padding-top: 0;
  display: flex;
  align-items: center;
}

@media (min-width: 768px) {
  .card-footer {
    padding: 1.5rem;
    padding-top: 0;
  }
}

/* Input Component */
.input {
  display: flex;
  height: 2.5rem;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--input));
  background-color: transparent;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  transition: all 0.15s ease;
  outline: none;
}

.input:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 1px hsl(var(--ring));
}

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

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

.textarea {
  display: flex;
  min-height: 5rem;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--input));
  background-color: transparent;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  transition: all 0.15s ease;
  outline: none;
  resize: vertical;
}

.textarea:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 1px hsl(var(--ring));
}

/* Badge Component */
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.badge-default {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

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

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

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

/* Avatar Component */
.avatar {
  position: relative;
  display: flex;
  height: 2.5rem;
  width: 2.5rem;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 9999px;
}

.avatar-image {
  aspect-ratio: 1 / 1;
  height: 100%;
  width: 100%;
  object-fit: cover;
}

.avatar-fallback {
  display: flex;
  height: 100%;
  width: 100%;
  align-items: center;
  justify-content: center;
  background-color: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
  font-weight: 500;
}

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

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

.avatar-xl {
  height: 6rem;
  width: 6rem;
}

/* Separator */
.separator {
  flex-shrink: 0;
  background-color: hsl(var(--border));
  height: 1px;
  width: 100%;
}

.separator-vertical {
  height: 100%;
  width: 1px;
}

/* Container */
.container {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

@media (min-width: 640px) {
  .container {
    max-width: 640px;
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

@media (min-width: 768px) {
  .container {
    max-width: 768px;
  }
}

@media (min-width: 1024px) {
  .container {
    max-width: 1024px;
  }
}

@media (min-width: 1280px) {
  .container {
    max-width: 1280px;
  }
}

@media (min-width: 1536px) {
  .container {
    max-width: 1536px;
  }
}

/* Navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
  border-bottom: 1px solid hsl(var(--border));
  background-color: hsl(var(--background) / 0.95);
  backdrop-filter: blur(8px);
}

.navbar-container {
  display: flex;
  height: 3.5rem;
  align-items: center;
  justify-content: space-between;
  max-width: 1536px;
  margin: 0 auto;
  padding: 0 0.75rem;
}

@media (min-width: 768px) {
  .navbar-container {
    height: 4rem;
    padding: 0 1.5rem;
  }
}

.navbar-brand {
  font-size: 1rem;
  font-weight: 700;
  color: hsl(var(--foreground));
  text-decoration: none;
  letter-spacing: -0.025em;
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .navbar-brand {
    font-size: 1.25rem;
  }
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 0.125rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.navbar-nav::-webkit-scrollbar {
  display: none;
}

@media (min-width: 768px) {
  .navbar-nav {
    gap: 0.5rem;
    overflow-x: visible;
  }
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.375rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  border-radius: var(--radius);
  transition: all 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .nav-link {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
  }
}

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

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

/* Grid */
.grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 768px) {
  .grid {
    gap: 1.5rem;
  }
}

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

@media (min-width: 768px) {
  .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .lg\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lg\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .lg\:col-span-2 { grid-column: span 2 / span 2; }
}

/* Flex utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.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-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }

/* Spacing */
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.py-12 { padding-top: 3rem; padding-bottom: 3rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }

@media (max-width: 767px) {
  .py-8 { padding-top: 1rem; padding-bottom: 1rem; }
  .py-12 { padding-top: 2rem; padding-bottom: 2rem; }
}

/* Text utilities */
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }
.text-muted { color: hsl(var(--muted-foreground)); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* Width */
.w-full { width: 100%; }
.max-w-2xl { max-width: 42rem; }
.max-w-4xl { max-width: 56rem; }
.max-w-6xl { max-width: 72rem; }
.mx-auto { margin-left: auto; margin-right: auto; }

/* Rounded */
.rounded { border-radius: var(--radius); }
.rounded-full { border-radius: 9999px; }

/* Shadow */
.shadow-sm { box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05); }
.shadow { box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1); }
.shadow-md { box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1); }

/* Hover effects */
.hover-lift {
  transition: transform 0.15s ease;
}

.hover-lift:hover {
  transform: translateY(-2px);
}

/* Loading spinner */
.spinner {
  border: 2px solid hsl(var(--border));
  border-top-color: hsl(var(--foreground));
  border-radius: 50%;
  width: 1rem;
  height: 1rem;
  animation: spin 0.6s linear infinite;
}

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

/* Smooth transitions */
* {
  transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 150ms;
}

/* Mobile Responsive Utilities */
.flex-1 { flex: 1 1 0%; }
.text-center { text-align: center; }
.overflow-hidden { overflow: hidden; }
.overflow-y-auto { overflow-y: auto; }

/* Responsive text sizes */
@media (max-width: 767px) {
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }
  .text-2xl { font-size: 1.25rem; }
  .text-3xl { font-size: 1.5rem; }
}

/* Mobile-friendly forms */
@media (max-width: 767px) {
  .input, .textarea {
    font-size: 16px; /* Prevents zoom on iOS */
  }
}

/* Responsive badge */
@media (max-width: 767px) {
  .badge {
    font-size: 0.6875rem;
    padding: 0.125rem 0.5rem;
  }
}

/* Mobile button adjustments */
@media (max-width: 767px) {
  .btn {
    font-size: 0.8125rem;
  }
  .btn-sm {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
  }
}

/* Responsive avatar */
.avatar-xl {
  height: 5rem;
  width: 5rem;
}

@media (min-width: 768px) {
  .avatar-xl {
    height: 6rem;
    width: 6rem;
  }
}

/* Touch-friendly tap targets */
@media (max-width: 767px) {
  .btn, .nav-link, button, a {
    min-height: 44px; /* iOS recommended tap target */
  }
}

/* Prevent horizontal scroll */
body {
  overflow-x: hidden;
}

/* Responsive images */
img {
  max-width: 100%;
  height: auto;
}

/* Mobile-optimized scrolling */
@media (max-width: 767px) {
  .overflow-y-auto {
    -webkit-overflow-scrolling: touch;
  }
}

/* Hide scrollbar but keep functionality */
.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

/* Responsive gap utilities */
@media (max-width: 767px) {
  .gap-6 { gap: 1rem; }
  .gap-8 { gap: 1.5rem; }
}

/* Mobile-friendly hover states (disable on touch) */
@media (hover: none) {
  .hover-lift:hover {
    transform: none;
  }
}

/* Responsive max-width */
.max-w-2xl { max-width: 100%; }
.max-w-4xl { max-width: 100%; }
.max-w-6xl { max-width: 100%; }

@media (min-width: 768px) {
  .max-w-2xl { max-width: 42rem; }
  .max-w-4xl { max-width: 56rem; }
  .max-w-6xl { max-width: 72rem; }
}

/* Mobile navigation improvements */
@media (max-width: 767px) {
  .navbar-nav .btn {
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
    min-height: auto;
  }
}

/* Responsive form layouts */
@media (max-width: 767px) {
  form .flex {
    flex-direction: column;
  }
  
  form .flex.gap-2 {
    gap: 0.75rem;
  }
  
  form .btn {
    width: 100%;
  }
}

/* Better mobile card spacing */
@media (max-width: 767px) {
  .card + .card {
    margin-top: 1rem;
  }
}

/* Responsive utility classes */
@media (max-width: 767px) {
  .sm\:hidden { display: none; }
  .sm\:flex { display: flex; }
  .sm\:block { display: block; }
}

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

/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
  body {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
  }
  
  .navbar-container {
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
  }
}

/* Additional Mobile Optimizations */

/* Better word breaking for long text */
.break-words {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.break-all {
  word-break: break-all;
}

/* Responsive visibility utilities */
.hidden {
  display: none;
}

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

/* Mobile-optimized spacing */
@media (max-width: 767px) {
  .card-header {
    padding: 0.875rem;
  }
  
  .card-content {
    padding: 0.875rem;
    padding-top: 0;
  }
  
  .card-footer {
    padding: 0.875rem;
    padding-top: 0;
  }
}

/* Improved touch targets for mobile */
@media (max-width: 767px) {
  a, button, .btn, .nav-link {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  }
}

/* Prevent text size adjustment on orientation change */
html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Better mobile form inputs */
@media (max-width: 767px) {
  select, textarea, input[type="text"], input[type="email"], 
  input[type="password"], input[type="search"] {
    font-size: 16px !important; /* Prevents iOS zoom */
  }
}

/* Responsive flex utilities */
@media (max-width: 767px) {
  .sm\:flex-col {
    flex-direction: column;
  }
  
  .sm\:w-full {
    width: 100%;
  }
}

/* Mobile-friendly modal/overlay support */
@media (max-width: 767px) {
  .modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 100;
  }
}

/* Improved scrolling on iOS */
.smooth-scroll {
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* Better mobile table handling */
@media (max-width: 767px) {
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Responsive image containers */
.img-container {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.img-responsive {
  width: 100%;
  height: auto;
  display: block;
}

/* Mobile-optimized grid gaps */
@media (max-width: 767px) {
  .grid {
    gap: 0.75rem;
  }
}

/* Better mobile navigation */
@media (max-width: 767px) {
  .navbar {
    position: sticky;
    top: 0;
  }
  
  .navbar-container {
    padding: 0 0.5rem;
  }
}

/* Responsive padding utilities */
.p-safe {
  padding: max(1rem, env(safe-area-inset-top)) 
           max(1rem, env(safe-area-inset-right)) 
           max(1rem, env(safe-area-inset-bottom)) 
           max(1rem, env(safe-area-inset-left));
}

/* Mobile-friendly hover states */
@media (hover: hover) and (pointer: fine) {
  .hover\:scale-105:hover {
    transform: scale(1.05);
  }
}

/* Prevent layout shift */
* {
  min-width: 0;
  min-height: 0;
}

/* Better mobile button sizing */
@media (max-width: 767px) {
  .btn {
    padding: 0.625rem 1rem;
    min-height: 44px;
  }
  
  .btn-sm {
    padding: 0.5rem 0.75rem;
    min-height: 36px;
  }
}

/* Responsive text alignment */
@media (max-width: 767px) {
  .sm\:text-center {
    text-align: center;
  }
  
  .sm\:text-left {
    text-align: left;
  }
}

/* Mobile-optimized card layouts */
@media (max-width: 767px) {
  .card {
    margin-bottom: 0.75rem;
  }
}

/* Better mobile form layouts */
@media (max-width: 767px) {
  form .flex {
    flex-wrap: wrap;
  }
  
  form .input,
  form .textarea,
  form .btn {
    width: 100%;
  }
}

/* Landscape mobile optimization */
@media (max-width: 767px) and (orientation: landscape) {
  .navbar-container {
    height: 3rem;
  }
  
  .py-8 {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }
}

/* Print styles */
@media print {
  .navbar,
  .btn,
  form {
    display: none;
  }
  
  .card {
    break-inside: avoid;
  }
}
