/* Lovable Design System - CSS Variables (HSL format for Tailwind) */

:root {
  /* Core Design Tokens - HSL format (no hsl() wrapper) */
  --background: 0 0% 98%;
  --foreground: 220 15% 25%;

  --card: 0 0% 100% / 0.85;
  --card-foreground: 220 15% 25%;
  
  /* Glassmorphism effect */
  --glass-blur: 12px;
  --glass-border: 0 0% 100% / 0.3;

  --popover: 0 0% 100%;
  --popover-foreground: 220 15% 25%;

  --primary: 214 84% 56%;
  --primary-foreground: 0 0% 100%;
  --primary-hover: 214 84% 50%;

  --secondary: 210 40% 96%;
  --secondary-foreground: 220 15% 25%;

  --muted: 210 40% 96%;
  --muted-foreground: 220 13% 46%;

  --accent: 214 32% 91%;
  --accent-foreground: 220 15% 25%;

  --destructive: 0 84% 60%;
  --destructive-foreground: 0 0% 100%;

  --border: 214 32% 91%;
  --input: 214 32% 91%;
  --ring: 214 84% 56%;

  --radius: 0.375rem;

  /* CRM specific tokens */
  --header-background: 0 0% 100%;
  --header-border: 214 32% 91%;
  --sidebar-background: 0 0% 100%;
  --sidebar-foreground: 220 15% 25%;
  --sidebar-primary: 214 84% 56%;
  --sidebar-primary-foreground: 0 0% 100%;
  --sidebar-accent: 210 40% 96%;
  --sidebar-accent-foreground: 220 15% 25%;
  --sidebar-border: 214 32% 91%;
  --sidebar-ring: 214 84% 56%;

  /* Custom gradients */
  --gradient-primary: linear-gradient(135deg, hsl(214 84% 56%), hsl(214 84% 50%));
  --gradient-subtle: linear-gradient(180deg, hsl(0 0% 100%), hsl(210 40% 98%));

  /* Shadows - softer for glass effect */
  --shadow-sm: 0 1px 3px 0 hsl(220 15% 25% / 0.04);
  --shadow-md: 0 4px 12px -2px hsl(220 15% 25% / 0.08);
  --shadow-lg: 0 12px 24px -4px hsl(220 15% 25% / 0.1);
  --shadow-glass: 0 8px 32px 0 hsl(220 15% 25% / 0.08);

  /* Transitions */
  --transition-smooth: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.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 47.4% 11.2%;
  --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%;
  --sidebar-background: 240 5.9% 10%;
  --sidebar-foreground: 240 4.8% 95.9%;
  --sidebar-primary: 224.3 76.3% 48%;
  --sidebar-primary-foreground: 0 0% 100%;
  --sidebar-accent: 240 3.7% 15.9%;
  --sidebar-accent-foreground: 240 4.8% 95.9%;
  --sidebar-border: 240 3.7% 15.9%;
  --sidebar-ring: 217.2 91.2% 59.8%;
}

/* Border and body defaults */
* {
  border-color: hsl(var(--border));
}

body {
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  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;
}

/* Reset & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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;
  color: var(--foreground);
  background-color: var(--background);
}

/* Input Range (Slider) Custom Styling */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: var(--muted);
  border-radius: 8px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--primary);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s ease;
}

input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.1);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--muted);
  border-radius: 4px;
}

/* ::-webkit-scrollbar-thumb {
  background: var(--gray-400);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gray-500);
} */

/* Focus Visible Ring */
.focus-visible\:outline-none:focus-visible {
  outline: 2px solid transparent;
  outline-offset: 2px;
}

.focus-visible\:ring-2:focus-visible {
  --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-visible\:ring-ring:focus-visible {
  --tw-ring-color: var(--ring);
}

.focus-visible\:ring-offset-2:focus-visible {
  --tw-ring-offset-width: 2px;
}

/* Transitions */
.transition-colors {
  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;
}

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

/* Hover Effects */
.hover\:bg-muted:hover {
  background-color: var(--muted);
}

.hover\:bg-primary:hover {
  background-color: var(--primary);
}

.hover\:bg-primary\/90:hover {
  background-color: rgba(99, 102, 241, 0.9);
}

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

/* Custom Utility Classes */
.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 0.125rem 0.5rem;
  font-size: 0.625rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

.status-pending {
  background-color: var(--amber-100);
  color: var(--amber-700);
}

.status-processing {
  background-color: var(--blue-100);
  color: var(--blue-700);
}

.status-success {
  background-color: var(--emerald-100);
  color: var(--emerald-700);
}

.status-failed {
  background-color: var(--red-100);
  color: var(--red-700);
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: var(--background);
  border-radius: 0.5rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  max-height: 90vh;
  overflow: auto;
  z-index: 51;
}

/* Loading Spinner */
.spinner {
  border: 2px solid var(--muted);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Fade In Animation */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.2s ease-out;
}

/* Ring Offset (for focus states) */
.ring-offset-background {
  --tw-ring-offset-color: var(--background);
}

/* Disabled State */
.disabled\:pointer-events-none:disabled {
  pointer-events: none;
}

.disabled\:opacity-50:disabled {
  opacity: 0.5;
}

/* Truncate Text */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Shadow Utilities */
.shadow-sm {
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.shadow {
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.shadow-md {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.shadow-lg {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Flex Gap Polyfill (if needed for older browsers) */
.gap-1 > * + * { margin-left: 0.25rem; }
.gap-2 > * + * { margin-left: 0.5rem; }
.gap-3 > * + * { margin-left: 0.75rem; }
.gap-4 > * + * { margin-left: 1rem; }

/* Print Styles */
@media print {
  .no-print {
    display: none !important;
  }
}
