/* Global styles for AutoHub application */
/* This file is referenced in index.html and provides base styling */

/* Reset and base styles */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Ensure proper scrolling behavior */
html {
  scroll-behavior: smooth;
  /* Enable momentum scrolling on iOS */
  -webkit-overflow-scrolling: touch;
}

/* Ensure body can scroll properly on mobile */
body {
  /* Enable touch scrolling */
  -webkit-overflow-scrolling: touch;
  /* Allow all touch actions */
  touch-action: manipulation;
  /* Ensure proper overflow behavior */
  overflow-x: hidden;
  overflow-y: auto;
}

/* Global custom dark scrollbar - Applied to all scrollable elements */
* {
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: #374151 #0f111a; /* thumb track - Firefox */
}

*::-webkit-scrollbar {
  width: 6px; /* Thin scrollbar for vertical */
  height: 6px; /* Thin scrollbar for horizontal */
}

*::-webkit-scrollbar-track {
  background: #0f111a; /* Match darkest bg */
}

*::-webkit-scrollbar-thumb {
  background-color: #374151; /* gray-700 */
  border-radius: 20px;
}

*::-webkit-scrollbar-thumb:hover {
  background-color: #4b5563; /* gray-600 - slightly lighter on hover */
}

/* Loading states */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Hide scrollbar utility */
.scrollbar-hide {
  -ms-overflow-style: none;  /* Internet Explorer 10+ */
  scrollbar-width: none;  /* Firefox */
}
.scrollbar-hide::-webkit-scrollbar {
  display: none;  /* Safari and Chrome */
}

/* Custom dark scrollbar for modals and containers */
.custom-scrollbar {
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: #374151 #0f111a; /* thumb track - Firefox */
}

.custom-scrollbar::-webkit-scrollbar {
  width: 6px; /* Thin scrollbar */
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: #0f111a; /* Match darkest bg */
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background-color: #374151; /* gray-700 */
  border-radius: 20px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background-color: #4b5563; /* gray-600 - slightly lighter on hover */
}

/* Ensure main containers allow proper scrolling */
#root {
  /* Enable touch scrolling */
  -webkit-overflow-scrolling: touch;
  /* Allow all touch actions */
  touch-action: manipulation;
  /* Ensure proper height */
  min-height: 100vh;
  /* Ensure proper overflow behavior */
  overflow-x: hidden;
  overflow-y: auto;
}

/* Normalize select element appearance across browsers */
/* Fix Safari 3D effect to match Chrome's flat appearance */
select {
  /* Remove default browser styling */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  
  /* Remove Safari's 3D effect and border styling */
  background-image: none;
  border-radius: inherit;
  
  /* Ensure consistent background and border */
  background-color: inherit;
  border: inherit;
  
  /* Add custom dropdown arrow */
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
  
  /* Ensure padding accounts for the arrow */
  padding-right: 32px;
  
  /* Remove focus outline and use consistent focus styling */
  outline: none;
}

/* Ensure focus states work consistently */
select:focus {
  /* Use the same focus styling as other form elements */
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
  border-color: #3b82f6;
}

/* For dark theme selects (most common in the app) */
select[class*="bg-gray"] {
  color: white;
}

/* Ensure the arrow color matches the text color */
select[class*="text-white"] {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
}

/* For disabled selects */
select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Print styles */
@media print {
  body {
    background: white !important;
    color: black !important;
  }
  
  /* Ensure selects print properly */
  select {
    background-image: none !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* Customer View Mode - Hide sidebar */
body.customer-view aside {
  display: none !important;
}

/* Customer View Mode - Adjust main content to full width */
body.customer-view main,
body.customer-view > div > div[class*="ml-"],
body.customer-view [class*="xl:ml-"] {
  margin-left: 0 !important;
  padding-top: 0 !important;
}

/* Email content styling for HTML emails in chat */
.email-content {
  font-family: inherit;
  color: inherit;
}

.email-content p {
  margin: 0.5em 0;
}

.email-content a {
  color: #60a5fa;
  text-decoration: underline;
}

.email-content a:hover {
  color: #93c5fd;
}

.email-content img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 0.5em 0;
}

.email-content ul,
.email-content ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

.email-content li {
  margin: 0.25em 0;
}

.email-content blockquote {
  border-left: 3px solid #4b5563;
  padding-left: 1em;
  margin: 0.5em 0;
  color: #9ca3af;
}

.email-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.5em 0;
}

.email-content th,
.email-content td {
  border: 1px solid #4b5563;
  padding: 0.5em;
  text-align: left;
}

.email-content th {
  background-color: rgba(75, 85, 99, 0.3);
  font-weight: 600;
}

.email-content h1,
.email-content h2,
.email-content h3,
.email-content h4,
.email-content h5,
.email-content h6 {
  margin: 0.75em 0 0.5em 0;
  font-weight: 600;
  line-height: 1.3;
}

.email-content h1 { font-size: 1.5em; }
.email-content h2 { font-size: 1.3em; }
.email-content h3 { font-size: 1.1em; }
.email-content h4 { font-size: 1em; }

.email-content code {
  background-color: rgba(0, 0, 0, 0.3);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
}

.email-content pre {
  background-color: rgba(0, 0, 0, 0.3);
  padding: 1em;
  border-radius: 4px;
  overflow-x: auto;
  margin: 0.5em 0;
}

.email-content pre code {
  background-color: transparent;
  padding: 0;
}

.email-content hr {
  border: none;
  border-top: 1px solid #4b5563;
  margin: 1em 0;
}

.email-content strong,
.email-content b {
  font-weight: 600;
}

.email-content em,
.email-content i {
  font-style: italic;
}

/* Email-specific tags */
.email-content center {
  text-align: center;
  display: block;
}

.email-content font {
  display: inline;
}

/* Table alignment attributes */
.email-content td[align="center"],
.email-content th[align="center"] {
  text-align: center;
}

.email-content td[align="left"],
.email-content th[align="left"] {
  text-align: left;
}

.email-content td[align="right"],
.email-content th[align="right"] {
  text-align: right;
}

/* Vertical alignment attributes */
.email-content td[valign="top"],
.email-content th[valign="top"] {
  vertical-align: top;
}

.email-content td[valign="middle"],
.email-content th[valign="middle"] {
  vertical-align: middle;
}

.email-content td[valign="bottom"],
.email-content th[valign="bottom"] {
  vertical-align: bottom;
}

/* Calendar animations */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* Utility class for slide-in animation */
.animate-slideInRight {
  animation: slideInRight 0.2s ease-out;
}

.animate-slideOutRight {
  animation: slideOutRight 0.2s ease-out;
}

/* Date and DateTime input styling - Make calendar icon white/visible */
input[type="date"],
input[type="datetime-local"] {
  /* Make the calendar icon white for dark theme */
  color-scheme: dark;
  position: relative;
}

/* For WebKit browsers (Chrome, Safari, Edge) - More specific and forceful */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(1) brightness(1.5) !important;
  cursor: pointer !important;
  opacity: 1 !important;
  background: transparent !important;
  color: white !important;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover {
  filter: invert(1) brightness(2) !important;
}

/* Ensure the input text is white */
input[type="date"],
input[type="datetime-local"] {
  color: white !important;
}

/* For Firefox */
input[type="date"]::-moz-calendar-picker-indicator,
input[type="datetime-local"]::-moz-calendar-picker-indicator {
  filter: invert(1) brightness(1.5) !important;
  cursor: pointer !important;
}

/* Additional fix for dark backgrounds */
input[type="date"][class*="bg-"],
input[type="datetime-local"][class*="bg-"] {
  color-scheme: dark !important;
}

input[type="date"][class*="bg-"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"][class*="bg-"]::-webkit-calendar-picker-indicator {
  filter: invert(1) brightness(2) contrast(1.2) !important;
}

/* Safe area inset for mobile devices with notches/home indicators */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .safe-area-inset-bottom {
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
  }
}

/* Ensure mobile bottom navigation doesn't overlap with home indicator */
@media (max-width: 767px) {
  body {
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
}
