/**
 * UI/UX IMPROVEMENTS
 * 
 * Add this file after theme.css for enhanced user experience
 * Includes smooth transitions, better interactions, and modern design patterns
 */

/* ============================================
   SMOOTH TRANSITIONS
   ============================================ */

* {
  transition: all 0.2s ease;
}

/* Specific transition timing */
.btn,
.card,
input,
select {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   BUTTON IMPROVEMENTS
   ============================================ */

.btn,
.submit-btn,
button[type="submit"] {
  position: relative;
  overflow: hidden;
  transform: translateZ(0);
  will-change: transform;
}

.btn:hover,
.submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(255, 102, 0, 0.3) !important;
}

.btn:active,
.submit-btn:active {
  transform: translateY(0);
  box-shadow: 0 4px 12px rgba(255, 102, 0, 0.2) !important;
}

.btn:focus-visible,
.submit-btn:focus-visible {
  outline: 3px solid rgba(255, 102, 0, 0.5);
  outline-offset: 2px;
}

/* Button ripple effect */
.btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn:active::after {
  width: 300px;
  height: 300px;
}

/* Loading state */
.btn.loading,
.submit-btn.loading {
  color: transparent !important;
  pointer-events: none;
}

.btn.loading::before,
.submit-btn.loading::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  top: 50%;
  left: 50%;
  margin-left: -10px;
  margin-top: -10px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   INPUT IMPROVEMENTS
   ============================================ */

input[type="text"],
input[type="date"],
input[type="time"],
input[type="email"],
select,
textarea {
  transition: all 0.3s ease;
}

input:focus,
select:focus,
textarea:focus {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 102, 0, 0.15) !important;
}

/* Remove date input ordinal suffix (th, st, nd, rd) */
input[type="date"]::-webkit-datetime-edit-text {
  display: none !important;
  visibility: hidden !important;
}

input[type="date"]::-webkit-datetime-edit-month-field,
input[type="date"]::-webkit-datetime-edit-day-field,
input[type="date"]::-webkit-datetime-edit-year-field {
  padding: 0 2px;
}

/* Hide ordinal suffixes in date display text */
.dates-section *:not(input):not(select):not(button) {
  font-variant-numeric: tabular-nums !important;
}

/* Target the specific date display that shows "Oct 24th" */
input[type="date"] + *,
input[type="date"] ~ * {
  /* Remove any text nodes that might contain ordinals */
}

/* Additional targeting for rendered date text */
[class*="date"] span:after,
[class*="date"] span:before,
[class*="rental"] span:after,
[class*="rental"] span:before {
  content: none !important;
}

/* Better placeholder styling */
::placeholder {
  color: #8c8c8c !important;
  opacity: 1;
}

input:focus::placeholder {
  opacity: 0.5;
  transform: translateX(5px);
}

/* ============================================
   CARD IMPROVEMENTS
   ============================================ */

.card,
.container,
.location-input,
.dates-section {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12) !important;
}

/* ============================================
   FOCUS INDICATORS
   ============================================ */

*:focus-visible {
  outline: 3px solid #ff6600 !important;
  outline-offset: 2px;
}

/* Remove default focus outline */
*:focus:not(:focus-visible) {
  outline: none;
}

/* ============================================
   LOADING SKELETON
   ============================================ */

.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: 8px;
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 16px;
  margin-bottom: 8px;
}

.skeleton-title {
  height: 24px;
  width: 60%;
  margin-bottom: 16px;
}

.skeleton-button {
  height: 48px;
  width: 200px;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toast {
  background: white;
  padding: 16px 24px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  border-left: 4px solid #ff6600;
  animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 300px;
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.toast.success { border-left-color: #16a34a; }
.toast.error { border-left-color: #e74c3c; }
.toast.warning { border-left-color: #f39c12; }
.toast.info { border-left-color: #0d6efd; }

.toast-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.toast-message {
  flex: 1;
  color: #1f1f1f;
  font-size: 0.9375rem;
}

.toast-close {
  background: none;
  border: none;
  color: #5a5a5a;
  cursor: pointer;
  font-size: 1.25rem;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s;
}

.toast-close:hover {
  background: #f0f0f0;
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}

.toast.removing {
  animation: slideOut 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   FORM VALIDATION
   ============================================ */

.form-group.error input,
.form-group.error select {
  border-color: #e74c3c !important;
  background: #fff5f5 !important;
}

.form-group.valid input,
.form-group.valid select {
  border-color: #16a34a !important;
  background: #f0fdf4 !important;
}

.error-message {
  display: none;
  color: #e74c3c;
  font-size: 0.875rem;
  margin-top: 4px;
  animation: fadeIn 0.3s ease;
}

.form-group.error .error-message {
  display: block;
}

.success-message {
  display: none;
  color: #16a34a;
  font-size: 0.875rem;
  margin-top: 4px;
  animation: fadeIn 0.3s ease;
}

.form-group.valid .success-message {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   MOBILE OPTIMIZATIONS
   ============================================ */

@media (max-width: 768px) {
  /* Larger touch targets */
  .btn,
  .submit-btn,
  input,
  select,
  a {
    min-height: 44px;
    min-width: 44px;
  }
  
  .btn,
  .submit-btn {
    padding: 14px 24px;
    font-size: 1.125rem;
  }
  
  input,
  select {
    padding: 14px;
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  /* Toast notifications */
  .toast-container {
    top: 10px;
    right: 10px;
    left: 10px;
  }
  
  .toast {
    min-width: auto;
    max-width: none;
  }
}

/* ============================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================ */

/* Skip to main content link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #ff6600;
  color: white;
  padding: 8px 16px;
  z-index: 10000;
  text-decoration: none;
  border-radius: 0 0 4px 0;
}

.skip-link:focus {
  top: 0;
}

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .btn,
  .submit-btn {
    border: 2px solid currentColor;
  }
  
  input,
  select {
    border: 2px solid currentColor;
  }
}

/* ============================================
   SMOOTH SCROLLING
   ============================================ */

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* ============================================
   SELECTION STYLING
   ============================================ */

::selection {
  background: rgba(255, 102, 0, 0.2);
  color: #1f1f1f;
}

::-moz-selection {
  background: rgba(255, 102, 0, 0.2);
  color: #1f1f1f;
}

/* ============================================
   AUTOCOMPLETE IMPROVEMENTS
   ============================================ */

.pac-container {
  border-radius: 12px !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15) !important;
  border: 1px solid #e0e0e0 !important;
  margin-top: 4px !important;
  animation: fadeIn 0.2s ease;
}

.pac-item {
  padding: 12px 16px !important;
  border-bottom: 1px solid #f0f0f0 !important;
  cursor: pointer !important;
  transition: background 0.2s ease;
}

.pac-item:hover {
  background-color: rgba(255, 102, 0, 0.08) !important;
}

.pac-item:last-child {
  border-bottom: none !important;
}

.pac-item-query {
  font-weight: 600 !important;
  color: #1f1f1f !important;
}

.pac-matched {
  font-weight: 700 !important;
  color: #ff6600 !important;
}

/* ============================================
   PROGRESS INDICATOR
   ============================================ */

.progress-bar {
  width: 100%;
  height: 4px;
  background: #e0e0e0;
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 24px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff6600, #ff8533);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* Animated progress */
.progress-fill.animated {
  background: linear-gradient(90deg, #ff6600, #ff8533, #ff6600);
  background-size: 200% 100%;
  animation: progress 1.5s linear infinite;
}

@keyframes progress {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
