/* Tailwind v3 entry */
@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
  /* BLDX brand tokens */
  --bv-primary: #2563eb;
  --bv-primary-600: #2563eb;
  --bv-primary-700: #1d4ed8;
  --bv-bg: #ffffff;
  --bv-ink: #0f172a;
  --bv-muted: #64748b;
  --bv-border: #e2e8f0;
  --bv-accent: #9333ea ;
  --bv-gold: #fbbf24;

  /* Generic tokens (for compatibility) */
  --background: #ffffff;
  --foreground: #0f172a;
  --color-background: var(--background);
  --color-foreground: var(--foreground);

  /* Legacy support (will phase out) */
  --primary-color: var(--bv-primary);
  --secondary-color: var(--bv-muted);
  --color-light: #fafafa;
  --color-dark: #1a1a1a;

  /* Font variables */
  --font-sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system,
    Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, "Helvetica Neue", Arial,
    "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: "Roboto Mono", ui-monospace, "SF Mono", "Monaco", monospace;

  /* Helpful defaults */
  accent-color: var(--bv-primary);
}

html,
body {
  padding: 0;
  margin: 0;
  background: var(--bv-bg);
  color: var(--bv-ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Prevent horizontal overflow from fixed/translated elements */
  overflow-x: hidden;
}

* {
  box-sizing: border-box;
}

/* Hide scrollbars but keep scrollable */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none; /* IE and Edge */
  scrollbar-width: none; /* Firefox */
}

/* Quality-of-life defaults */
::selection {
  background: color-mix(in oklab, var(--bv-primary) 85%, white);
  color: #fff;
}

img,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Component utilities using Tailwind's layers */
@layer components {
  .btn {
    @apply inline-flex items-center justify-center rounded-lg font-semibold transition-all focus:outline-none focus:ring-2 ring-offset-1;
  }
  .btn-primary {
    @apply btn text-white bg-primary-600 hover:bg-primary-700 focus:ring-primary-500;
  }
  .btn-danger {
    @apply btn text-white bg-error-600 hover:bg-error-700 focus:ring-error-500;
  }
  .btn-ghost {
    @apply btn text-secondary-600 hover:text-secondary-800 hover:bg-secondary-100/60 focus:ring-secondary-300;
  }

  /* Tutorial pulse animation */
  .tutorial-pulse {
    position: relative;
    border-radius: 6px;
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(0,0,0,0); /* subtle placeholder glow */
    animation: tutorial-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  }
  
  /* Tutorial highlight - elevates target above overlay */
  .tutorial-highlight {
    position: relative !important;
    z-index: 10001 !important; /* Above overlay (9998) and dialog (9999) */
    outline: 2px solid var(--primary-color) !important;
    outline-offset: 2px !important;
    border-radius: 8px !important;
    box-shadow: 0 0 0 8px color-mix(in srgb, var(--primary-color) 12%, transparent);
  }
  
  /* Tutorial dialog focus styles */
  .tutorial-dialog:focus-visible {
    outline: 2px solid rgba(59, 130, 246, 0.5);
    outline-offset: 2px;
  }
}

@keyframes tutorial-pulse {
  0% { box-shadow: 0 0 0 2px var(--primary-color), 0 0 0 10px color-mix(in srgb, var(--primary-color) 20%, transparent); }
  70% { box-shadow: 0 0 0 2px var(--primary-color), 0 0 0 18px color-mix(in srgb, var(--primary-color) 0%, transparent); }
  100% { box-shadow: 0 0 0 2px var(--primary-color), 0 0 0 18px color-mix(in srgb, var(--primary-color) 0%, transparent); }
}

/* Construction-specific patterns */
.construction-grid {
  background-image:
    linear-gradient(#e5e7eb 1px, transparent 1px),
    linear-gradient(90deg, #e5e7eb 1px, transparent 1px);
  background-size: 20px 20px;
}

.blueprint-lines {
  background:
    linear-gradient(
      90deg,
      transparent 24px,
      #e0f2fe 25px,
      #e0f2fe 26px,
      transparent 27px
    ),
    linear-gradient(
      transparent 24px,
      #e0f2fe 25px,
      #e0f2fe 26px,
      transparent 27px
    );
  background-size: 25px 25px;
}

.technical-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  line-height: 1.2;
}

.construction-numbers {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: 0.025em;
}

/* Progress bars for construction */
.progress-construction {
  background-color: #f3f4f6;
  height: 0.5rem;
  position: relative;
  overflow: hidden;
  border-radius: 0.25rem;
  width: 100%;
}

.progress-construction::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: repeating-linear-gradient(
    45deg,
    var(--bv-gold),
    var(--bv-gold) 10px,
    #d97706 10px,
    #d97706 20px
  );
  width: var(--progress-width, 0%);
  transition: width 300ms ease-out;
}

/* Status badges */
.status-construction {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.375rem 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-radius: 0.25rem;
  border: 1px solid currentColor;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), inset 0 1px 0 rgb(255 255 255 / 0.2);
  min-height: 1.75rem;
}

.dashed-border {
  border-style: dashed;
  border-width: 2px;
  border-color: var(--bv-border);
}

/* Tenant theming utilities */
.tenant-primary {
  background-color: var(--bv-primary);
}

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

.tenant-primary-border {
  border-color: var(--bv-primary);
}

/* Auth form styles */
.auth-input-field {
  width: 100%;
  padding: 0.875rem 1rem;
  border-radius: 0.25rem;
  background-color: white;
  border: 1px solid var(--bv-border);
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
  outline: none;
  transition: all 150ms ease;
}

.auth-input-field:focus {
  border-color: var(--bv-primary);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--bv-primary) 20%, transparent);
}

.auth-button {
  width: 100%;
  padding: 0.875rem 1rem;
  border-radius: 0.375rem;
  font-weight: 600;
  transition: all 150ms ease;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
  background-color: var(--bv-primary);
  color: white;
}

.auth-button:hover:not(:disabled) {
  background-color: var(--bv-primary-700);
}

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