/* Theme Variables */
:root {
  /* Light theme colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --border-primary: #e5e7eb;
  --border-secondary: #d1d5db;
  --accent-blue: #3b82f6;
  --accent-blue-hover: #2563eb;
  --accent-green: #10b981;
  --accent-green-hover: #059669;
  --accent-red: #ef4444;
  --accent-red-hover: #dc2626;
  --accent-purple: #8b5cf6;
  --accent-purple-hover: #7c3aed;
  --accent-orange: #f59e0b;
  --accent-orange-hover: #d97706;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

/* Dark theme colors */
[data-theme="dark"] {
  --bg-primary: #111827;
  --bg-secondary: #1f2937;
  --bg-tertiary: #374151;
  --text-primary: #f9fafb;
  --text-secondary: #d1d5db;
  --text-tertiary: #9ca3af;
  --border-primary: #374151;
  --border-secondary: #4b5563;
  --accent-blue: #60a5fa;
  --accent-blue-hover: #3b82f6;
  --accent-green: #34d399;
  --accent-green-hover: #10b981;
  --accent-red: #f87171;
  --accent-red-hover: #ef4444;
  --accent-purple: #a78bfa;
  --accent-purple-hover: #8b5cf6;
  --accent-orange: #fbbf24;
  --accent-orange-hover: #f59e0b;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.5);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.6), 0 8px 10px -6px rgb(0 0 0 / 0.6);
}

/* Base theme styles */
.theme-bg-primary { background-color: var(--bg-primary); }
.theme-bg-secondary { background-color: var(--bg-secondary); }
.theme-bg-tertiary { background-color: var(--bg-tertiary); }

/* Opacity variants for backgrounds */
.theme-bg-primary-95 { background-color: rgba(255, 255, 255, 0.95); }
[data-theme="dark"] .theme-bg-primary-95 { background-color: rgba(17, 24, 39, 0.95); }

/* Login page background */
.theme-login-bg { background: linear-gradient(to bottom right, #e5e7eb, #d1d5db); }
[data-theme="dark"] .theme-login-bg { background: linear-gradient(to bottom right, #111827, #1f2937); }

.theme-text-primary { color: var(--text-primary); }
.theme-text-secondary { color: var(--text-secondary); }
.theme-text-tertiary { color: var(--text-tertiary); }

.theme-border-primary { border-color: var(--border-primary); }
.theme-border-secondary { border-color: var(--border-secondary); }
.theme-border-color { border-color: var(--border-primary); }

.theme-shadow-sm { box-shadow: var(--shadow-sm); }
.theme-shadow-md { box-shadow: var(--shadow-md); }
.theme-shadow-lg { box-shadow: var(--shadow-lg); }
.theme-shadow-xl { box-shadow: var(--shadow-xl); }

/* Button styles */
.theme-btn-primary {
  background-color: var(--accent-blue);
  color: var(--bg-primary);
  border: 1px solid var(--accent-blue);
}

.theme-btn-primary:hover {
  background-color: var(--accent-blue-hover);
  border-color: var(--accent-blue-hover);
}

.theme-btn-secondary {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
}

.theme-btn-secondary:hover {
  background-color: var(--bg-tertiary);
  border-color: var(--border-secondary);
}

.theme-btn-success {
  background-color: var(--accent-green);
  color: var(--bg-primary);
  border: 1px solid var(--accent-green);
}

.theme-btn-success:hover {
  background-color: var(--accent-green-hover);
  border-color: var(--accent-green-hover);
}

.theme-btn-warning {
  background-color: var(--accent-orange);
  color: var(--bg-primary);
  border: 1px solid var(--accent-orange);
}

.theme-btn-warning:hover {
  background-color: var(--accent-orange-hover);
  border-color: var(--accent-orange-hover);
}

.theme-btn-danger {
  background-color: var(--accent-red);
  color: var(--bg-primary);
  border: 1px solid var(--accent-red);
}

.theme-btn-danger:hover {
  background-color: var(--accent-red-hover);
  border-color: var(--accent-red-hover);
}

/* Form elements */
.theme-input {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
}

.theme-input::placeholder {
  color: var(--text-tertiary);
  font-size: 0.875em;
  font-style: italic;
  opacity: 0.7;
}

/* Global placeholder styling */
::placeholder {
  color: var(--text-tertiary);
  font-size: 0.875em;
  font-style: italic;
  opacity: 0.7;
}

.theme-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
}

/* Card styles */
.theme-card {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-primary);
  box-shadow: var(--shadow-sm);
}

/* Menu styles */
.theme-menu-item {
  color: var(--text-secondary);
}

.theme-menu-item:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

.theme-menu-item.active {
  background-color: rgba(59, 130, 246, 0.2);
  color: var(--accent-blue);
}

[data-theme="dark"] .theme-menu-item.active {
  background-color: rgba(96, 165, 250, 0.15);
  color: var(--accent-blue);
}

/* Hover states */
.theme-bg-hover:hover {
  background-color: var(--bg-secondary);
}

.theme-hover-border:hover {
  border-color: var(--accent-blue);
}

/* Focus ring styles */
.theme-focus-ring:focus {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

/* Accent background */
.theme-accent-bg {
  background-color: var(--accent-blue);
}

/* Drag and drop states */
.theme-drag-over {
  border-color: var(--accent-blue) !important;
  background-color: var(--bg-secondary);
}

/* Glass-effect toast notifications.
   Each variant uses a semantic accent colour at low alpha over a blurred
   backdrop, so page content glows through the card. The icon and close
   button inherit the full-strength accent; only the message text uses the
   darker readable colour (lightened in dark mode).
   Rules also target `.flex-1` inside the box for backward-compat with
   legacy inline callers that don't use `.theme-notification-message`. */

/* Container: fixed top-right, stacks multiple toasts with a small gap. */
#toast_container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 24rem;
  width: calc(100% - 2rem);
  pointer-events: none;
}
#toast_container > * { pointer-events: auto; }

.theme-notification-success,
.theme-notification-error,
.theme-notification-warning,
.theme-notification-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 0.75rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.10), 0 4px 6px -4px rgba(0, 0, 0, 0.10);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--toast-accent);
}

.theme-notification-success {
  --toast-accent: #10b981;
  --toast-text:   #065f46;
  background-color: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.30);
}

.theme-notification-error {
  --toast-accent: #ef4444;
  --toast-text:   #991b1b;
  background-color: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.30);
}

.theme-notification-warning {
  --toast-accent: #f59e0b;
  --toast-text:   #92400e;
  background-color: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.30);
}

.theme-notification-info {
  --toast-accent: #3b82f6;
  --toast-text:   #1e40af;
  background-color: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.30);
}

/* Same translucent bg/border in dark mode — only the readable text lightens. */
[data-theme="dark"] .theme-notification-success { --toast-text: #6ee7b7; }
[data-theme="dark"] .theme-notification-error   { --toast-text: #fca5a5; }
[data-theme="dark"] .theme-notification-warning { --toast-text: #fcd34d; }
[data-theme="dark"] .theme-notification-info    { --toast-text: #93c5fd; }

/* Message text: 14px semibold in the readable text colour.
   Both .theme-notification-message (new markup) and .flex-1 (legacy markup)
   receive the treatment. */
.theme-notification-success .theme-notification-message,
.theme-notification-error   .theme-notification-message,
.theme-notification-warning .theme-notification-message,
.theme-notification-info    .theme-notification-message,
.theme-notification-success .flex-1,
.theme-notification-error   .flex-1,
.theme-notification-warning .flex-1,
.theme-notification-info    .flex-1 {
  flex: 1 1 0%;
  font-size: 14px;
  font-weight: 600;
  color: var(--toast-text);
  line-height: 1.4;
}

/* Close button: full-strength accent at 60% opacity, 100% on hover. */
.theme-notification-success button,
.theme-notification-error button,
.theme-notification-warning button,
.theme-notification-info button {
  color: var(--toast-accent);
  opacity: 0.6;
  transition: opacity 150ms ease-out;
  flex-shrink: 0;
}
.theme-notification-success button:hover,
.theme-notification-error button:hover,
.theme-notification-warning button:hover,
.theme-notification-info button:hover {
  opacity: 1;
}

/* Icon SVG (direct child): 20px, doesn't shrink. */
.theme-notification-success > svg,
.theme-notification-error   > svg,
.theme-notification-warning > svg,
.theme-notification-info    > svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Transition for smooth theme switching */
html {
  transition: background-color 0.3s ease, color 0.3s ease;
}

*:not(.modal-overlay):not(.modal-content) {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Override Tailwind classes with theme variables when needed */
.theme-override {
  background-color: var(--bg-primary) !important;
  color: var(--text-primary) !important;
}

/* Current file badge - green bordered with theme-aware colors */
.theme-current-file-badge {
  background-color: #ffffff !important;
  color: #111827 !important;
  border: 2px solid #22c55e !important;
}

[data-theme="dark"] .theme-current-file-badge {
  background-color: rgba(34, 197, 94, 0.2) !important;
  color: #4ade80 !important;
  border-color: #4ade80 !important;
}

/* Own message bubble - indigo tinted */
.theme-own-message {
  background-color: #eef2ff;
  border-color: #c7d2fe;
}

[data-theme="dark"] .theme-own-message {
  background-color: rgba(99, 102, 241, 0.25);
  border-color: rgba(129, 140, 248, 0.4);
}

/* Needs reply border - overrides theme border colors */
.needs-reply-border {
  border-color: #ef4444 !important;
  border-width: 2px !important;
}

/* Own message inner elements (reply quotes, file cards) */
.theme-own-message-inner {
  background-color: #e0e7ff;
  border-color: #a5b4fc;
}

[data-theme="dark"] .theme-own-message-inner {
  background-color: rgba(99, 102, 241, 0.3);
  border-color: rgba(129, 140, 248, 0.5);
}

/* Logo - blend for both light and dark mode */
.theme-logo {
  filter: brightness(1.05) contrast(1.1);
  mix-blend-mode: multiply;
}

[data-theme="dark"] .theme-logo {
  filter: invert(1);
  mix-blend-mode: screen;
}

/* Selected tree item - explicit text colors for cross-browser compatibility */
.theme-tree-item-selected {
  background-color: #eef2ff !important; /* indigo-50 */
}

.theme-tree-item-selected,
.theme-tree-item-selected span:not([style*="color"]),
.theme-tree-item-selected p:not([style*="color"]) {
  color: #3730a3 !important; /* indigo-800 for good contrast */
}

[data-theme="dark"] .theme-tree-item-selected {
  background-color: rgba(79, 70, 229, 0.3) !important; /* indigo-600 with opacity */
}

[data-theme="dark"] .theme-tree-item-selected,
[data-theme="dark"] .theme-tree-item-selected span:not([style*="color"]),
[data-theme="dark"] .theme-tree-item-selected p:not([style*="color"]) {
  color: #c7d2fe !important; /* indigo-200 for visibility */
}

/* Select dropdown options - theme-aware styling */
select option {
  background-color: #ffffff;
  color: #111827;
}

[data-theme="dark"] select option {
  background-color: #1f2937;
  color: #f9fafb;
}

/* Needs Reply - red border indicator */
.border-needs-reply {
  border-color: #ef4444 !important; /* red-500 */
  border-width: 2px !important;
}

[data-theme="dark"] .border-needs-reply {
  border-color: #f87171 !important; /* red-400 */
}

/* Poked - red border indicator for attention */
.border-poked {
  border-color: #ef4444 !important; /* red-500 */
  border-width: 2px !important;
}

[data-theme="dark"] .border-poked {
  border-color: #f87171 !important; /* red-400 */
}

/* Buzz animation for attention */
@keyframes buzz {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
  20%, 40%, 60%, 80% { transform: translateX(2px); }
}

.animate-buzz {
  animation: buzz 0.4s ease-in-out;
}

/* Slow ping animation for poked project icons */
@keyframes ping-slow {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.15);
    opacity: 0.7;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.animate-ping-slow {
  animation: ping-slow 1s ease-in-out infinite;
}

/* Billing balance amount - black in light mode, yellow in dark mode */
.billing-balance-amount {
  color: #000000;
}

[data-theme="dark"] .billing-balance-amount {
  color: #facc15; /* yellow-400 */
}

/* User type conditional visibility - for broadcast partials without current_user */
/* Show detailer-only elements when user is a detailer */
body[data-user-detailer="true"] .detailer-only {
  display: inline-flex !important;
}

body[data-user-detailer="true"] .non-detailer-only {
  display: none !important;
}

/* Prominent input border - for highlighting important fields like List Price */
.theme-input-prominent {
  background-color: var(--bg-primary) !important;
  color: var(--text-primary) !important;
  border: 2px solid #3b82f6 !important; /* blue-500 */
}

.theme-input-prominent:focus {
  border-color: #1d4ed8 !important; /* blue-700 */
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.2) !important;
}

[data-theme="dark"] .theme-input-prominent {
  border-color: #60a5fa !important; /* blue-400 */
}

[data-theme="dark"] .theme-input-prominent:focus {
  border-color: #93c5fd !important; /* blue-300 */
  box-shadow: 0 0 0 3px rgb(96 165 250 / 0.25) !important;
}
/* Full-viewport loading overlay shown during Turbo page navigations.
   Delayed via JS so it doesn't flash on fast transitions. Three
   concentric conic-gradient rings rotating at different speeds and
   directions read as "fancy" without a JS-heavy animation library. */
.page-loader-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  background-color: rgba(15, 23, 42, 0.55);        /* slate-900 @ 55% */
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease-out;
}
.page-loader-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}
.page-loader-overlay .page-loader-rings {
  position: relative;
  width: 128px;
  height: 128px;
  filter: drop-shadow(0 0 32px rgba(168, 85, 247, 0.35));
}
.page-loader-overlay .page-loader-ring {
  position: absolute;
  inset: 0;
  border-radius: 9999px;
  mask: radial-gradient(circle, transparent 62%, black 63%);
  -webkit-mask: radial-gradient(circle, transparent 62%, black 63%);
  animation: page-loader-spin 1.4s linear infinite;
}
.page-loader-overlay .page-loader-ring--outer {
  background: conic-gradient(from 0deg,
    transparent 0deg 60deg,
    #a855f7 120deg 240deg,   /* purple-500 */
    transparent 300deg 360deg);
  animation-duration: 2.2s;
  animation-direction: reverse;
}
.page-loader-overlay .page-loader-ring--middle {
  inset: 14px;
  background: conic-gradient(from 90deg,
    transparent 0deg 90deg,
    #ec4899 150deg 210deg,   /* pink-500 */
    transparent 270deg 360deg);
  animation-duration: 1.6s;
}
.page-loader-overlay .page-loader-ring--inner {
  inset: 30px;
  background: conic-gradient(from 180deg,
    transparent 0deg 30deg,
    #38bdf8 90deg 270deg,    /* sky-400 */
    transparent 330deg 360deg);
  animation-duration: 1s;
  animation-direction: reverse;
}
.page-loader-overlay .page-loader-label {
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  animation: page-loader-pulse 1.6s ease-in-out infinite;
}
@keyframes page-loader-spin {
  to { transform: rotate(360deg); }
}
@keyframes page-loader-pulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}
