/* 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);
}

/* Notification styles */
.theme-notification-success {
  background-color: var(--accent-green);
  color: var(--bg-primary);
}

.theme-notification-error {
  background-color: var(--accent-red);
  color: var(--bg-primary);
}

.theme-notification-warning {
  background-color: var(--accent-orange);
  color: var(--bg-primary);
}

.theme-notification-info {
  background-color: var(--accent-blue);
  color: var(--bg-primary);
}

/* 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;
}