/* ==========================================================================
   Receipt Splitter - Design System Styles
   ========================================================================== */

/* ==========================================================================
   CSS Custom Properties (Design Tokens)
   ========================================================================== */
:root {
  /* Color Palette */
  --color-primary-600: #2563eb;
  --color-primary-700: #1d4ed8;
  --color-success-600: #16a34a;
  --color-success-700: #15803d;
  --color-warning-600: #ea580c;
  --color-danger-600: #dc2626;
  --color-danger-700: #b91c1c;
  
  /* Text Colors */
  --color-text-primary: #111827;
  --color-text-secondary: #374151;
  --color-text-tertiary: #4b5563;
  --color-text-muted: #6b7280;
  
  /* Background Colors */
  --color-bg-primary: #ffffff;
  --color-bg-secondary: #f9fafb;
  --color-bg-tertiary: #f3f4f6;
  
  /* Border Colors */
  --color-border: #d1d5db;
  --color-border-focus: var(--color-primary-600);
  
  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  
  /* Typography */
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;
  
  /* Transitions */
  --transition-fast: 150ms ease-in-out;
  --transition-base: 200ms ease-in-out;
  --transition-slow: 300ms ease-in-out;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  
  /* Border Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
}

/* Dark mode preparation */
@media (prefers-color-scheme: dark) {
  :root.dark-mode {
    --color-text-primary: #f9fafb;
    --color-text-secondary: #e5e7eb;
    --color-text-tertiary: #d1d5db;
    --color-text-muted: #9ca3af;
    --color-bg-primary: #111827;
    --color-bg-secondary: #1f2937;
    --color-bg-tertiary: #374151;
    --color-border: #4b5563;
  }
}

/* ==========================================================================
   Tailwind Component Classes
   ========================================================================== */
@layer components {
  /* Buttons */
  .btn {
    @apply px-6 py-2 rounded-lg font-medium transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2;
  }
  
  .btn-primary {
    @apply btn bg-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500;
  }
  
  .btn-success {
    @apply btn bg-green-600 text-white hover:bg-green-700 focus:ring-green-500;
  }
  
  .btn-secondary {
    @apply btn bg-gray-200 text-gray-800 hover:bg-gray-300 focus:ring-gray-500;
  }
  
  .btn-danger {
    @apply btn bg-red-600 text-white hover:bg-red-700 focus:ring-red-500;
  }
  
  .btn-sm {
    @apply px-4 py-1.5 text-sm;
  }
  
  .btn-lg {
    @apply px-8 py-3 text-lg;
  }
  
  /* Form Inputs */
  .input-standard {
    @apply px-3 py-2 border border-gray-300 rounded-lg transition-all duration-200;
    @apply focus:ring-2 focus:ring-blue-500 focus:border-blue-500 focus:outline-none;
  }
  
  .input-readonly {
    @apply bg-gray-50 cursor-not-allowed;
  }
  
  .input-error {
    @apply border-red-500 focus:ring-red-500 focus:border-red-500;
  }
  
  .input-success {
    @apply border-green-500 focus:ring-green-500 focus:border-green-500;
  }
  
  /* Cards */
  .card {
    @apply bg-white rounded-lg shadow-lg p-6;
  }
  
  .card-compact {
    @apply bg-white rounded-lg shadow-lg p-4;
  }
  
  .card-hover {
    @apply hover:shadow-xl transition-shadow duration-200;
  }
  
  /* Page Layout */
  .page-container {
    @apply max-w-4xl mx-auto py-8 px-4 sm:px-6 lg:px-8;
  }
  
  .page-title {
    @apply text-3xl font-bold text-gray-900;
  }
  
  .section-header {
    @apply text-2xl font-semibold text-gray-900;
  }
  
  .subsection-header {
    @apply text-xl font-semibold text-gray-700;
  }
  
  /* Badges */
  .badge {
    @apply inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium;
  }
  
  .badge-blue {
    @apply badge bg-blue-100 text-blue-800;
  }
  
  .badge-green {
    @apply badge bg-green-100 text-green-800;
  }
  
  .badge-red {
    @apply badge bg-red-100 text-red-800;
  }
  
  .badge-yellow {
    @apply badge bg-yellow-100 text-yellow-800;
  }
  
  /* Alerts */
  .alert {
    @apply p-4 rounded-lg border;
  }
  
  .alert-info {
    @apply alert bg-blue-50 border-blue-200 text-blue-800;
  }
  
  .alert-success {
    @apply alert bg-green-50 border-green-200 text-green-800;
  }
  
  .alert-warning {
    @apply alert bg-yellow-50 border-yellow-200 text-yellow-800;
  }
  
  .alert-danger {
    @apply alert bg-red-50 border-red-200 text-red-800;
  }
  
  /* Loading States */
  .skeleton {
    @apply animate-pulse bg-gray-200 rounded;
  }
  
  .skeleton-text {
    @apply h-4 bg-gray-200 rounded animate-pulse;
  }
  
  .skeleton-box {
    @apply h-10 bg-gray-200 rounded animate-pulse;
  }
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Animation utility classes */
.animate-fade-in {
  animation: fadeIn var(--transition-base);
}

.animate-fade-out {
  animation: fadeOut var(--transition-base);
}

.animate-slide-down {
  animation: slideDown var(--transition-base);
}

.animate-slide-up {
  animation: slideUp var(--transition-base);
}

.animate-scale-in {
  animation: scaleIn var(--transition-base);
}

/* Smooth transitions for interactive elements */
.transition-smooth {
  transition: all var(--transition-base);
}

.transition-fast {
  transition: all var(--transition-fast);
}

.transition-slow {
  transition: all var(--transition-slow);
}

/* ==========================================================================
   Print Styles - Using Tailwind print: modifier
   ========================================================================== */

/* Tailwind print: modifier classes in HTML templates replace most print styles.
   These remaining styles handle special cases not easily done with utilities. */

@media print {
  /* Global print resets - things that need * selector */
  * {
    background: transparent !important;
    color: black !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }
  
  /* Ensure proper page breaks */
  .card {
    page-break-inside: avoid;
  }
  
  /* Show URLs for links */
  a[href]:after {
    content: " (" attr(href) ")";
  }
  
  /* Page margins */
  @page {
    margin: 1in;
  }
}

/* Print utility classes using Tailwind @layer */
@layer utilities {
  /* Elements to hide when printing - use class="print:hidden" in HTML instead */
  .no-print {
    @apply print:hidden;
  }
  
  /* Receipt print layout - use these with print: modifier in HTML */
  .receipt-print {
    @apply print:w-full print:max-w-none;
  }
  
  .receipt-print .page-container {
    @apply print:max-w-none print:p-0;
  }
  
  /* Receipt totals for print */
  .receipt-totals {
    @apply print:border-t-2 print:border-black print:pt-2.5 print:mt-5;
  }
  
  /* Card print styles */
  .card-print {
    @apply print:border print:border-black print:p-2.5 print:mb-2.5;
  }
  
  /* Typography for print - can be applied directly in HTML with print: modifier */
  .print-body {
    @apply print:text-base print:leading-relaxed;
  }
  
  .print-h1 {
    @apply print:text-2xl;
  }
  
  .print-h2 {
    @apply print:text-xl;
  }
  
  .print-h3 {
    @apply print:text-lg;
  }
  
  /* Monetary values for print */
  .print-mono {
    @apply print:font-mono;
  }
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

/* Focus visible for accessibility */
.focus-visible:focus {
  outline: 2px solid var(--color-primary-600);
  outline-offset: 2px;
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Prevent text selection on buttons */
button, .btn {
  user-select: none;
}

/* Improved focus styles */
:focus-visible {
  outline: 2px solid var(--color-primary-600);
  outline-offset: 2px;
}

/* Remove default focus for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}