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

/* Viewport and scrolling fixes */
html, body {
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
  min-height: 100vh;
  position: relative;
}

* {
  box-sizing: border-box;
}

/* Mobile-first responsive design */
#root {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  min-height: 100vh;
}

/* Prevent horizontal scroll issues */
.container {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  padding-left: 1rem;
  padding-right: 1rem;
}

/* Mobile optimized layouts */
@media (max-width: 768px) {
  .container {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  
  /* Ensure all cards fit on small screens */
  .card {
    max-width: 100% !important;
    margin-left: auto;
    margin-right: auto;
  }
  
  /* Mobile button sizing */
  .btn {
    min-height: 44px; /* iOS touch target size */
    padding: 0.75rem 1rem;
  }
  
  /* Mobile form controls */
  input, select, textarea {
    font-size: 16px; /* Prevent zoom on iOS */
    max-width: 100%;
  }
  
  /* Mobile grid layouts */
  .grid {
    gap: 0.75rem !important;
  }
  
  /* Mobile text sizing */
  h1 {
    font-size: 1.5rem !important;
    line-height: 2rem !important;
  }
  
  h2 {
    font-size: 1.25rem !important;
    line-height: 1.75rem !important;
  }
  
  /* Mobile spacing */
  .space-y-6 > * + * {
    margin-top: 1rem !important;
  }
  
  .space-y-4 > * + * {
    margin-top: 0.75rem !important;
  }
}

/* Ensure no horizontal overflow */
.overflow-x-hidden {
  overflow-x: hidden !important;
  max-width: 100% !important;
}

/* Mobile-specific card improvements */
@media (max-width: 640px) {
  .card-content {
    padding: 0.75rem !important;
  }
  
  /* Button groups on mobile */
  .button-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
  }
  
  .button-group .btn {
    width: 100%;
    justify-content: center;
  }
}

/* Force text containment for Replit environment */
.quick-actions-card {
  overflow: hidden !important;
  max-width: 320px !important;
  width: 100% !important;
  position: relative !important;
}

.quick-actions-content {
  display: grid !important;
  grid-template-columns: auto 1fr !important;
  gap: 1rem !important;
  overflow: hidden !important;
  max-width: 100% !important;
  padding: 1.5rem !important;
}

.quick-actions-text {
  min-width: 0 !important;
  overflow: hidden !important;
  max-width: 100% !important;
  word-break: break-word !important;
  overflow-wrap: break-word !important;
}

.quick-actions-title {
  font-size: 0.875rem !important;
  line-height: 1.25rem !important;
  margin: 0 !important;
  margin-bottom: 0.25rem !important;
  max-width: 100% !important;
  overflow: hidden !important;
  word-break: break-word !important;
}

.quick-actions-description {
  font-size: 0.75rem !important;
  line-height: 1rem !important;
  margin: 0 !important;
  max-width: 100% !important;
  overflow: hidden !important;
  word-break: break-word !important;
}

:root {
  --background: hsl(248, 6%, 96%);
  --foreground: hsl(24, 9.8%, 10%);
  --muted: hsl(60, 4.8%, 95.9%);
  --muted-foreground: hsl(25, 5.3%, 44.7%);
  --popover: hsl(0, 0%, 100%);
  --popover-foreground: hsl(20, 14.3%, 4.1%);
  --card: hsl(0, 0%, 100%);
  --card-foreground: hsl(20, 14.3%, 4.1%);
  --border: hsl(20, 5.9%, 90%);
  --input: hsl(20, 5.9%, 90%);
  --primary: hsl(217, 91%, 60%);
  --primary-foreground: hsl(210, 40%, 98%);
  --secondary: hsl(142, 76%, 36%);
  --secondary-foreground: hsl(210, 40%, 98%);
  --accent: hsl(45, 93%, 47%);
  --accent-foreground: hsl(24, 9.8%, 10%);
  --destructive: hsl(0, 84.2%, 60.2%);
  --destructive-foreground: hsl(60, 9.1%, 97.8%);
  --ring: hsl(20, 14.3%, 4.1%);
  --radius: 0.5rem;
  
  /* Custom app colors */
  --surface: hsl(0, 0%, 100%);
  --gradient-start: hsl(240, 60%, 70%);
  --gradient-end: hsl(280, 50%, 60%);
}

.dark {
  --background: hsl(240, 10%, 3.9%);
  --foreground: hsl(0, 0%, 98%);
  --muted: hsl(240, 3.7%, 15.9%);
  --muted-foreground: hsl(240, 5%, 64.9%);
  --popover: hsl(240, 10%, 3.9%);
  --popover-foreground: hsl(0, 0%, 98%);
  --card: hsl(240, 10%, 3.9%);
  --card-foreground: hsl(0, 0%, 98%);
  --border: hsl(240, 3.7%, 15.9%);
  --input: hsl(240, 3.7%, 15.9%);
  --primary: hsl(217, 91%, 60%);
  --primary-foreground: hsl(210, 40%, 98%);
  --secondary: hsl(142, 76%, 36%);
  --secondary-foreground: hsl(210, 40%, 98%);
  --accent: hsl(45, 93%, 47%);
  --accent-foreground: hsl(0, 0%, 98%);
  --destructive: hsl(0, 62.8%, 30.6%);
  --destructive-foreground: hsl(0, 0%, 98%);
  --ring: hsl(240, 4.9%, 83.9%);
  --radius: 0.5rem;
}

@layer base {
  * {
    @apply border-border;
  }

  body {
    @apply font-sans antialiased bg-background text-foreground;
    font-family: 'Inter', system-ui, sans-serif;
  }
}

@layer components {
  .gradient-bg {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  }
  
  .scan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: 8px;
  }
  
  .scan-point {
    aspect-ratio: 1;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
  }
  
  .scan-point.completed {
    background: var(--secondary);
    color: white;
  }
  
  .scan-point.current {
    background: var(--accent);
    color: white;
    animation: pulse 2s infinite;
  }
  
  .scan-point.pending {
    background: hsl(0, 0%, 90%);
    color: hsl(0, 0%, 40%);
  }
  
  .measurement-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-left: 4px solid var(--primary);
  }
  
  .hoof-3d-preview {
    background: linear-gradient(45deg, hsl(200, 100%, 97%), hsl(200, 100%, 92%));
    border: 2px dashed var(--primary);
    border-radius: 12px;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
  }
  
  .scan-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: hsla(217, 91%, 60%, 0.1);
    backdrop-filter: blur(1px);
  }
}

@keyframes pulse {
  0%, 100% { 
    transform: scale(1); 
  }
  50% { 
    transform: scale(1.1); 
  }
}
