/**
 * Cross-browser compatibility layer for AgentStack
 * Provides vendor prefixes for older Safari, Mobile browsers, Firefox
 * Tests: Chrome, Safari, Firefox, Edge, Mobile browsers
 */

/* Fallback for older browsers that don't support custom properties */
:root {
  --primary-color: #FF6B35;
  --dark-bg: #0A0A0A;
  --card-bg: #151515;
}

/* Flexbox with vendor prefixes for older Safari (iOS) */
.flex-center,
.app-layout,
.sidebar,
.sidebar-logo,
.nav-item,
.form-group,
.login-box,
.modal-overlay,
.tab-content,
.recovery-header {
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
}

.sidebar-logo {
  -webkit-flex-direction: column;
  -ms-flex-direction: column;
  flex-direction: column;
}

/* Transform animations - required for Safari and older browsers */
.btn:hover:not(:disabled) {
  -webkit-transform: translateY(-2px);
  -moz-transform: translateY(-2px);
  -ms-transform: translateY(-2px);
  -o-transform: translateY(-2px);
  transform: translateY(-2px);
}

.modal-overlay.active {
  -webkit-transform: opacity 0.3s ease-in-out;
  -moz-transform: opacity 0.3s ease-in-out;
  transform: opacity 0.3s ease-in-out;
}

/* Gradients with vendor prefixes for Safari, Firefox */
.login-box {
  background: -webkit-linear-gradient(145deg, #151515 0%, #0D0D0D 100%);
  background: -moz-linear-gradient(145deg, #151515 0%, #0D0D0D 100%);
  background: -o-linear-gradient(145deg, #151515 0%, #0D0D0D 100%);
  background: linear-gradient(145deg, #151515 0%, #0D0D0D 100%);
}

.btn {
  background: -webkit-linear-gradient(135deg, #FF6B35 0%, #E55A1F 100%);
  background: -moz-linear-gradient(135deg, #FF6B35 0%, #E55A1F 100%);
  background: linear-gradient(135deg, #FF6B35 0%, #E55A1F 100%);
}

/* Box shadows with vendor prefixes */
.btn:hover:not(:disabled),
.login-box,
.card {
  -webkit-box-shadow: 0 8px 24px rgba(255, 107, 53, 0.3);
  -moz-box-shadow: 0 8px 24px rgba(255, 107, 53, 0.3);
  box-shadow: 0 8px 24px rgba(255, 107, 53, 0.3);
}

/* Box sizing for all browsers */
*,
*::before,
*::after {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

/* Smooth scrolling for Safari and older Chrome */
html {
  -webkit-scroll-behavior: smooth;
  scroll-behavior: smooth;
}

/* Focus outlines for accessibility across browsers */
input:focus,
button:focus,
a:focus {
  outline: 2px solid #FF6B35;
  outline-offset: 2px;
}

/* Appearance normalization for mobile browsers */
input,
button,
textarea,
select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  font-family: inherit;
  font-size: 16px; /* Prevents zoom on iOS input focus */
}

/* Button styling for mobile */
button,
input[type="button"],
input[type="submit"] {
  cursor: pointer;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Cursor compatibility */
.cursor-pointer {
  cursor: pointer;
}

.cursor-default {
  cursor: default;
}

/* Text selection styling */
::selection {
  background-color: rgba(255, 107, 53, 0.3);
  color: inherit;
}

::-moz-selection {
  background-color: rgba(255, 107, 53, 0.3);
  color: inherit;
}

/* Placeholder styling for cross-browser support */
::placeholder {
  color: #555;
  opacity: 1; /* Firefox needs explicit opacity */
}

::-webkit-input-placeholder {
  color: #555;
  opacity: 1;
}

:-moz-placeholder {
  color: #555;
  opacity: 1;
}

::-moz-placeholder {
  color: #555;
  opacity: 1;
}

:-ms-input-placeholder {
  color: #555;
  opacity: 1;
}

/* Backdrop filter fallback for browsers that don't support it */
@supports not (backdrop-filter: blur(10px)) {
  .modal-overlay {
    background: rgba(0, 0, 0, 0.7);
  }
}

@supports (backdrop-filter: blur(10px)) {
  .modal-overlay {
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    background: rgba(0, 0, 0, 0.3);
  }
}

/* Grid support fallback */
@supports not (display: grid) {
  .dashboard-grid {
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-flex-wrap: wrap;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
  }
}

/* Media queries for responsive cross-browser support */
@media (max-width: 768px) {
  body {
    font-size: 14px; /* Avoid too-small text on mobile */
  }

  input {
    font-size: 16px; /* Prevents iOS zoom on input focus */
  }

  .mobile-fullwidth {
    width: 100% !important;
  }
}

/* Reduced motion preferences for accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  body {
    background: #0A0A0A;
    color: #FAFAFA;
  }
}

@media (prefers-color-scheme: light) {
  body {
    background: #FFFFFF;
    color: #000000;
  }
}

/* High contrast mode support */
@media (prefers-contrast: more) {
  button,
  .btn {
    border: 2px solid #FF6B35;
  }

  a {
    text-decoration: underline;
  }
}
