/*
 * Virtual Real Estate Marketplace - Tailwind CSS Only Styles
 * Custom CSS for functionality that cannot be achieved with Tailwind classes alone
 * All layout and design uses Tailwind CSS
 */

/* ============================================
   1. CSS Variables / Custom Properties
   ============================================ */
:root {
  --color-primary: #0ea5e9;
  --color-accent: #7c3aed;
  --color-accent-light: #8b5cf6;
  --color-dark-900: #0f172a;
  --color-dark-800: #1e293b;
  --color-dark-700: #334155;
}

/* ============================================
   2. Global Resets & Base Styles
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  overflow-x: hidden !important;
  max-width: 100vw !important;
  min-height: 100vh;
}

/* Alpine.js cloak - hide elements until Alpine loads */
[x-cloak] { 
  display: none !important; 
}

/* Remove focus outline for mouse users, keep for keyboard */
:focus:not(:focus-visible) {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ============================================
   3. Custom Scrollbar
   ============================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #1e293b;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: #475569 #1e293b;
}

/* Light mode scrollbar */
.light ::-webkit-scrollbar-track,
html:not(.dark) ::-webkit-scrollbar-track {
  background: #f1f5f9;
}

.light ::-webkit-scrollbar-thumb,
html:not(.dark) ::-webkit-scrollbar-thumb {
  background: #cbd5e1;
}

.light ::-webkit-scrollbar-thumb:hover,
html:not(.dark) ::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ============================================
   4. Glassmorphism Utilities
   ============================================ */
.glass {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.dark .glass {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.glass-card {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
}

.dark .glass-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* ============================================
   5. Text Effects
   ============================================ */
.text-glow {
  text-shadow: 0 0 20px rgba(124, 58, 237, 0.5);
}

::selection {
  background: var(--color-accent);
  color: white;
}

::-moz-selection {
  background: var(--color-accent);
  color: white;
}

/* ============================================
   6. Custom Animations
   ============================================ */

/* Slide Up Animation */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-slide-up {
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Shimmer Animation */
@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

.animate-shimmer {
  animation: shimmer 2s infinite;
}

/* Gradient Animation */
@keyframes gradient-xy {
  0%, 100% {
    background-size: 400% 400%;
    background-position: left center;
  }
  50% {
    background-size: 200% 200%;
    background-position: right center;
  }
}

.animate-gradient-xy {
  animation: gradient-xy 15s ease infinite;
}

/* Float Animation */
@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-20px);
  }
}

.animate-float {
  animation: float 6s ease-in-out infinite;
}

/* Pulse Glow Animation */
@keyframes pulse-glow {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 20px rgba(124, 58, 237, 0.5);
  }
  50% {
    opacity: 0.5;
    box-shadow: 0 0 10px rgba(124, 58, 237, 0.2);
  }
}

.animate-pulse-glow {
  animation: pulse-glow 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Shake Animation */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
  20%, 40%, 60%, 80% { transform: translateX(2px); }
}

.shaking {
  display: inline-block;
  animation: shake 1.5s ease-in-out infinite;
}

/* Slide In Right Animation (for toasts) */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

/* Slide Down Animation */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   7. Word Breaking & Overflow Utilities
   ============================================ */
.break-all {
  word-break: break-all !important;
}

.overflow-wrap-anywhere {
  overflow-wrap: anywhere !important;
}

/* Coordinate display fix */
.font-mono.font-semibold,
.font-mono.font-bold {
  word-break: break-all;
  overflow-wrap: anywhere;
  max-width: 100%;
}

/* ============================================
   8. Form Styles
   ============================================ */
input, select, textarea {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Prevent iOS zoom on input focus */
@media screen and (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="password"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* ============================================
   9. Error/Alert Styles
   ============================================ */
.error-toast {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10000;
  min-width: 300px;
  max-width: 90vw;
  animation: slideInRight 0.3s ease-out;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.error-toast.hiding {
  animation: slideOutRight 0.3s ease-out forwards;
}

.error-message-container {
  position: relative;
  width: 100%;
  margin-bottom: 1rem;
  animation: slideDown 0.3s ease-out;
}

/* ============================================
   10. Mobile Responsive Fixes
   ============================================ */
@media (max-width: 768px) {
  /* Prevent horizontal scroll */
  body, html {
    overflow-x: hidden !important;
  }
  
  /* Ensure sections don't overflow */
  section {
    overflow-x: hidden;
    max-width: 100vw;
  }
  
  /* Glass card mobile adjustments */
  .glass-card {
    padding: 1rem;
    margin: 0;
    max-width: 100%;
  }
  
  /* Modal mobile fixes */
  .fixed.inset-0 {
    padding: 0.5rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Search filter buttons - make scrollable */
  #filterContainer {
    overflow-x: auto;
    max-width: 180px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  
  #filterContainer::-webkit-scrollbar {
    display: none;
  }
  
  /* Coordinate display smaller on mobile */
  .text-sm.font-bold,
  span.font-mono.font-semibold {
    font-size: 0.7rem;
    line-height: 1.4;
  }
}

@media (max-width: 480px) {
  /* Extra small screens */
  .glass-card {
    padding: 0.75rem;
  }
  
  /* Even smaller coordinate text */
  .text-sm.font-bold,
  span.font-mono.font-semibold {
    font-size: 0.625rem;
    line-height: 1.3;
  }
}

/* ============================================
   11. Print Styles
   ============================================ */
@media print {
  .fixed,
  .sticky,
  #mainHeader,
  #cookieConsent,
  .back-to-top {
    display: none !important;
  }
  
  body {
    background: white !important;
    color: black !important;
  }
  
  .glass-card {
    background: white !important;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
  }
}

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

/* Skip to content link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-primary);
  color: white;
  padding: 8px;
  z-index: 100;
}

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

/* High contrast mode support */
@media (prefers-contrast: high) {
  .glass-card {
    border-width: 2px;
  }
  
  button, a {
    border-width: 2px;
  }
}

/* ============================================
   13. Skeleton Loading
   ============================================ */
.skeleton-svg {
  animation: shimmer 2s infinite linear;
}

/* SVG skeleton gradient for dark mode */
.dark .skeleton-svg rect {
  fill: url(#shimmerDark);
}
