/**
 * Default Theme - Ads Explorer
 * 
 * This file contains all the custom CSS styles for the default theme.
 * To create a new theme, copy this file and modify the styles as needed.
 */

/* ============================================
   Font Rendering & Sharpness
   ============================================ */

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* ============================================
   Typography & Fonts
   ============================================ */

body {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: "kern" 1;
    font-kerning: normal;
    -webkit-text-stroke: 0.01em transparent;
}

/* Apply IBM Plex Sans Arabic to text elements but exclude Font Awesome icons and logo */
*:not(.fa):not(.fas):not(.far):not(.fal):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-light):not(.fa-brands):not(.logo-text) {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Ensure filter buttons use IBM Plex Sans Arabic font */
.filter-chip, .filter-chip span, button:not(.logo-text) {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
}

/* Logo uses Alexandria font - MUST be AFTER the global rule to override */
.logo-text,
h1.logo-text,
header h1.logo-text,
#header-panel h1.logo-text,
div h1.logo-text {
    font-family: 'Alexandria', sans-serif !important;
    font-weight: 400 !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Force Alexandria font even if cached */
h1.logo-text {
    font-family: 'Alexandria', 'Arial', sans-serif !important;
    font-weight: 400 !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* ============================================
   Text Elements Sharpness
   ============================================ */

/* Sharper rendering for headings */
h1, h2, h3, h4, h5, h6 {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: "kern" 1;
    font-weight: 600;
}

/* Sharper rendering for body text */
p, span, div, a, button, input, select, textarea, label {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Small text - use optimizeSpeed for better performance */
small, .text-xs, .text-sm {
    text-rendering: optimizeSpeed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Arabic text optimization */
[dir="rtl"], [lang="ar"] {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "kern" 1, "liga" 1;
    font-variant-ligatures: common-ligatures;
}

/* Exclude icons from text rendering optimizations */
i[class*="fa-"], .fa-solid, .fa-regular, .fa-brands {
    text-rendering: auto;
    -webkit-font-smoothing: subpixel-antialiased;
    -moz-osx-font-smoothing: auto;
}

/* ============================================
   Performance Optimizations
   ============================================ */

/* Performance optimizations - exclude spinner */
*:not(.animate-spin) {
    -webkit-transform: translateZ(0);
    -moz-transform: translateZ(0);
    -ms-transform: translateZ(0);
    -o-transform: translateZ(0);
    transform: translateZ(0);
}

/* Optimize marker rendering */
.custom-marker {
    will-change: transform;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* ============================================
   Leaflet Popup Styling
   ============================================ */

/* Make Leaflet popup wrapper transparent */
.leaflet-popup-content-wrapper {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
}

.leaflet-popup-content {
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
}

.leaflet-popup-tip {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
}

/* Remove all shadows from popup */
.leaflet-popup {
    box-shadow: none !important;
    filter: none !important;
}

.leaflet-popup-pane {
    box-shadow: none !important;
}

/* Remove any remaining visual artifacts */
.leaflet-popup-content-wrapper,
.leaflet-popup-content,
.leaflet-popup-tip,
.leaflet-popup {
    -webkit-box-shadow: none !important;
    -moz-box-shadow: none !important;
    box-shadow: none !important;
    filter: none !important;
    -webkit-filter: none !important;
}

/* Complete Leaflet popup styling reset */
.leaflet-popup-content-wrapper {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

.leaflet-popup-content {
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
}

.leaflet-popup-tip {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
}

/* Remove all shadows from popup */
.leaflet-popup {
    box-shadow: none !important;
    filter: none !important;
    background: transparent !important;
}

.leaflet-popup-pane {
    box-shadow: none !important;
    background: transparent !important;
}

/* Remove any remaining visual artifacts */
.leaflet-popup-content-wrapper,
.leaflet-popup-content,
.leaflet-popup-tip,
.leaflet-popup {
    -webkit-box-shadow: none !important;
    -moz-box-shadow: none !important;
    box-shadow: none !important;
    filter: none !important;
    -webkit-filter: none !important;
    background: transparent !important;
}

/* Hide the popup arrow completely */
.leaflet-popup-tip-container {
    display: none !important;
}

.leaflet-popup-tip {
    display: none !important;
}

/* Popup styles */
.leaflet-popup-content {
    font-family: 'IBM Plex Sans Arabic', sans-serif;
    direction: rtl;
    text-align: right;
}

/* ============================================
   RTL & Layout
   ============================================ */

/* Custom Tailwind config for RTL */
.rtl {
    direction: rtl;
}

/* ============================================
   Scrollbar Styling
   ============================================ */

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #1e293b;
}

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

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

/* ============================================
   Focus & Interaction
   ============================================ */

/* Custom focus styles */
.focus-ring:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* ============================================
   Animations
   ============================================ */

/* Loading animation */
.loading {
    animation: spin 1s linear infinite;
}

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

/* ============================================
   Loading Indicator
   ============================================ */

.loading-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999999;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    display: none !important;
    align-items: center;
    justify-content: center;
    padding: 20px;
    pointer-events: none;
}

.loading-indicator:not(.hidden) {
    display: flex !important;
    pointer-events: auto;
}

.loading-indicator.hidden {
    display: none !important;
    pointer-events: none;
}

.loading-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 32px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(199, 210, 254, 0.5);
}

.loading-header {
    text-align: center;
    margin-bottom: 24px;
}

.loading-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    background: linear-gradient(to bottom right, #1e3a8a, #1e40af, #2563eb);
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(30, 64, 175, 0.4);
    margin-bottom: 16px;
}

.loading-icon i {
    font-size: 32px;
    color: white;
    animation: spin 3s linear infinite;
}

.loading-title {
    font-size: 20px;
    font-weight: 700;
    color: #f1f5f9;
    margin-bottom: 12px;
    background: linear-gradient(to right, #1e3a8a, #1e40af, #2563eb);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.loading-text {
    font-size: 14px;
    color: #475569;
    margin: 0;
    font-weight: 500;
}

.loading-progress-bar {
    width: 100%;
    height: 12px;
    background-color: #e2e8f0;
    border-radius: 9999px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.loading-progress {
    height: 100%;
    background: linear-gradient(to right, #1e3a8a, #1e40af, #2563eb);
    border-radius: 9999px;
    transition: width 0.5s ease-out;
    width: 0%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ============================================
   Map Container
   ============================================ */

/* Map container */
#map {
    height: 100vh;
    width: 100%;
    position: relative;
    z-index: 1;
}

/* Ensure loading indicator is above everything - at root level */
#loading-indicator {
    z-index: 999999 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
}

/* Ensure header is below loading indicator */
#header-panel,
#filter-panel {
    background: linear-gradient(to right, rgba(15, 23, 42, 0.60) 5%, rgba(30, 27, 75, 0.65) 25%, rgba(30, 27, 75, 0.68) 50%, rgba(30, 27, 75, 0.65) 75%, rgba(15, 23, 42, 0.60) 95%) !important;
}

#header-panel {
    z-index: 900 !important;
    position: absolute !important;
    top: 1.5rem !important; /* top-6 */
    left: 50% !important;
    transform: translateX(-50%) !important;
    overflow: visible !important;
    contain: layout style paint;
    isolation: isolate;
}

#filter-panel {
    position: absolute !important;
    bottom: 1.5rem !important; /* bottom-6 */
    left: 50% !important;
    transform: translateX(-50%) !important;
    contain: layout style paint;
    isolation: isolate;
}

/* Hidden elements use content-visibility for performance */
.hidden,
[style*="display: none"] {
    content-visibility: hidden;
    contain: layout style paint;
}

/* Modals - isolated containers */
.modal,
#filter-modal,
#change-password-modal,
#statistics-modal {
    contain: layout style paint;
    isolation: isolate;
}

/* Breakdown tooltip - must overlay header and map */
#breakdown-tooltip {
    z-index: 99999 !important;
    position: fixed !important;
    transition: opacity 0.2s ease, visibility 0.2s ease !important;
    pointer-events: auto !important; /* Allow hover on tooltip itself */
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.3) !important;
}

/* Ensure parent container doesn't create stacking context issues */
.h-screen.w-screen {
    position: relative !important;
    z-index: auto !important;
}

/* ============================================
   Leaflet Pane Z-Index Management
   ============================================ */

/* Ensure Leaflet panes are properly stacked - markers must be above tiles */
.leaflet-pane {
    z-index: auto !important;
}

.leaflet-tile-pane {
    z-index: 200 !important;
}

.leaflet-overlay-pane {
    z-index: 400 !important;
}

/* Marker pane must be above tiles and overlay pane */
.leaflet-marker-pane {
    z-index: 650 !important;
    visibility: visible !important;
    display: block !important;
}

.leaflet-shadow-pane {
    z-index: 500 !important;
}

.leaflet-control-pane {
    z-index: 1000 !important;
}

.leaflet-popup-pane {
    z-index: 700 !important;
}

/* ============================================
   Custom Popup Styling
   ============================================ */

.custom-popup {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
    direction: rtl !important;
    max-width: 280px !important;
    min-width: 240px !important;
}

.custom-popup .leaflet-popup-content-wrapper {
    border-radius: 6px !important;
    box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.1) !important;
    border: 1px solid #e5e7eb !important;
    padding: 0 !important;
}

.custom-popup .leaflet-popup-content {
    margin: 0 !important;
    padding: 6px !important;
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
    line-height: 1.3 !important;
}

.custom-popup .leaflet-popup-tip {
    background: white !important;
    border: 1px solid #e5e7eb !important;
}

.custom-popup .leaflet-popup-close-button {
    display: none !important;
}

/* Force button styling */
.custom-popup a {
    background-color: #2563eb !important;
    color: white !important;
    text-decoration: none !important;
}

.custom-popup a:hover {
    background-color: #1d4ed8 !important;
    color: white !important;
}

/* ============================================
   Custom Marker Styling
   ============================================ */

.custom-div-icon {
    background: transparent !important;
    border: none !important;
}

.custom-marker {
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 4px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    font-family: 'IBM Plex Sans Arabic', sans-serif;
    text-align: center;
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(6px);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    letter-spacing: 0.5px;
}

/* Custom marker styles */
.marker-sale {
    background-color: #3b82f6;
    border: 2px solid #1e40af;
}

.marker-rent {
    background-color: #10b981;
    border: 2px solid #047857;
}

/* ============================================
   Marker Cluster Styling - Professional & Clean
   ============================================ */

/* Override default Leaflet MarkerCluster styles */
.leaflet-marker-cluster {
    background: transparent !important;
    border: none !important;
}

/* Custom cluster icon container - Professional style */
.leaflet-marker-cluster div {
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
    font-weight: 600 !important;
    color: #ffffff !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) !important;
    transition: all 0.2s ease !important;
}

/* Small clusters (fewer items) - Medium-light blue gradient */
.leaflet-marker-cluster-small div {
    width: 40px !important;
    height: 40px !important;
    margin-left: -20px !important;
    margin-top: -20px !important;
    font-size: 12px !important;
    background: linear-gradient(135deg, #6366f1 0%, #818cf8 50%, #a5b4fc 100%) !important;
    border-color: #a5b4fc !important;
    border-width: 2px !important;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35), 0 1px 3px rgba(0, 0, 0, 0.15) !important;
}

.leaflet-marker-cluster-small:hover div {
    background: linear-gradient(135deg, #818cf8 0%, #a5b4fc 50%, #c7d2fe 100%) !important;
    border-color: #c7d2fe !important;
    box-shadow: 0 3px 10px rgba(99, 102, 241, 0.45), 0 1px 4px rgba(0, 0, 0, 0.2) !important;
    transform: scale(1.05) !important;
}

/* Medium clusters - Medium-dark blue gradient */
.leaflet-marker-cluster-medium div {
    width: 46px !important;
    height: 46px !important;
    margin-left: -23px !important;
    margin-top: -23px !important;
    font-size: 13px !important;
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 50%, #818cf8 100%) !important;
    border-color: #818cf8 !important;
    border-width: 2.5px !important;
    box-shadow: 0 3px 10px rgba(79, 70, 229, 0.4), 0 1px 4px rgba(0, 0, 0, 0.2) !important;
}

.leaflet-marker-cluster-medium:hover div {
    background: linear-gradient(135deg, #6366f1 0%, #818cf8 50%, #a5b4fc 100%) !important;
    border-color: #a5b4fc !important;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.5), 0 2px 5px rgba(0, 0, 0, 0.25) !important;
    transform: scale(1.08) !important;
}

/* Large clusters (more items) - Dark blue gradient */
.leaflet-marker-cluster-large div {
    width: 52px !important;
    height: 52px !important;
    margin-left: -26px !important;
    margin-top: -26px !important;
    font-size: 14px !important;
    background: linear-gradient(135deg, #1e293b 0%, #334155 50%, #475569 100%) !important;
    border-color: #6366f1 !important;
    border-width: 3px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(99, 102, 241, 0.25) !important;
}

.leaflet-marker-cluster-large:hover div {
    background: linear-gradient(135deg, #334155 0%, #475569 50%, #64748b 100%) !important;
    border-color: #818cf8 !important;
    box-shadow: 0 5px 14px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(99, 102, 241, 0.35) !important;
    transform: scale(1.1) !important;
}

/* Remove default cluster text styling */
.leaflet-marker-cluster span {
    line-height: 1 !important;
    text-align: center !important;
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
    font-weight: 600 !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
    text-rendering: optimizeLegibility !important;
}

/* ============================================
   Filter Panel
   ============================================ */

/* Filter panel background removed - using inline styles in map.html */

/* Filter toggle button */
#filter-toggle {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 9998 !important;
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
}

#filter-toggle {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* ============================================
   Leaflet Draw Controls
   ============================================ */

/* Leaflet.draw controls - FORCE VISIBILITY ALWAYS */
.leaflet-draw-toolbar {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    transform: none !important;
}

.leaflet-top.leaflet-right .leaflet-draw {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    transform: none !important;
}

/* Prevent Leaflet from hiding controls during zoom/pan */
.leaflet-zoom-animated .leaflet-draw-toolbar,
.leaflet-pan-anim .leaflet-draw-toolbar,
.leaflet-zoom-animated .leaflet-top.leaflet-right,
.leaflet-pan-anim .leaflet-top.leaflet-right {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    transform: none !important;
}

/* Force all leaflet-draw elements visible */
[class*="leaflet-draw"] {
    visibility: visible !important;
    opacity: 1 !important;
    display: block !important;
}

/* Prevent Leaflet from hiding controls during interactions */
.leaflet-zoom-anim .leaflet-draw-toolbar,
.leaflet-zoom-animated .leaflet-draw-toolbar,
.leaflet-pan-anim .leaflet-draw-toolbar {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Force visibility in all states */
.leaflet-container .leaflet-draw-toolbar,
.leaflet-container.leaflet-touch-zoom .leaflet-draw-toolbar,
.leaflet-container.leaflet-touch-drag .leaflet-draw-toolbar {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Hide all Leaflet controls completely */
.leaflet-control-container,
.leaflet-control,
.leaflet-control-zoom,
.leaflet-control-attribution,
.leaflet-control-layers,
.leaflet-control-scale,
.leaflet-control-fullscreen,
.leaflet-top,
.leaflet-bottom,
.leaflet-left,
.leaflet-right {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Hide control pane */
.leaflet-control-pane {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Ensure no controls appear during animations */
.leaflet-zoom-animated .leaflet-control-pane,
.leaflet-pan-anim .leaflet-control-pane,
.leaflet-zoom-animated .leaflet-control-container,
.leaflet-pan-anim .leaflet-control-container {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Prevent transforms from hiding toolbar controls (but allow for drawing) */
.leaflet-draw-toolbar,
.leaflet-draw-toolbar a {
    transform: none !important;
}

/* Don't prevent transforms on drawing guides/circles - they need transforms to work */
.leaflet-draw-guide-dash {
    pointer-events: none !important;
}

/* ============================================
   Filter Button Animations
   ============================================ */

/* Animated glow for apply filter button when filters are pending */
#apply-filters.pending-filters {
    position: relative;
    animation: subtle-glow 2s ease-in-out infinite;
}

@keyframes subtle-glow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4);
    }
    50% {
        box-shadow: 0 0 12px 4px rgba(99, 102, 241, 0.6), 0 0 20px 8px rgba(139, 92, 246, 0.3);
    }
}

/* ============================================
   Drawing Panel
   ============================================ */

/* Drawing panel positioning - below filter panel */
#drawing-panel {
    bottom: 208px; /* Increased by 30% from 160px (160 * 1.3 = 208) */
    left: 50%;
    transform: translateX(-50%);
    transform-origin: bottom center;
    --filter-panel-height: 300px; /* Default fallback value */
    --slide-distance: calc(var(--filter-panel-height) * 2); /* 50% of filter panel height */
    will-change: transform, opacity;
}

/* Keyframe animations for slide-from-bottom effect (50% of filter panel height) */
@keyframes spawn-from-tray {
    0%   { opacity: 0; transform: translateX(-50%) translateY(var(--slide-distance)) scale(0.96); }
    60%  { opacity: 0.05; transform: translateX(-50%) translateY(-8%) scale(1.02); } /* slight overshoot upward */
    100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

@keyframes despawn-to-tray {
    0%   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
    60%  { opacity: 0.05; transform: translateX(-50%) translateY(-8%); } /* slight overshoot upward */
    100% { opacity: 0; transform: translateX(-50%) translateY(var(--slide-distance)) scale(0.96); }
}

.animate-spawn-from-tray {
    animation: spawn-from-tray 0.42s cubic-bezier(0.22, 0.95, 0.57, 1.02) both;
    transform-origin: bottom center;
}

.animate-despawn-to-tray {
    animation: despawn-to-tray 0.28s cubic-bezier(0.3, 0.7, 0.4, 1) both; /* slightly longer for smoother exit */
    transform-origin: bottom center;
}

/* Hidden state */
#drawing-panel.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .animate-spawn-from-tray,
    .animate-despawn-to-tray {
        animation: none !important;
        transform: translate(-50%, 0) !important;
        opacity: 1 !important;
    }
}

/* ============================================
   Header and Filter Panel Entrance Animation
   ============================================ */

/* Initial state: at starting positions (off-screen), 95% transparent */
#header-panel:not(.revealed) {
    opacity: 0.05 !important;
    top: 1.5rem !important;
    left: 50% !important;
    transform: translateX(-50%) translateY(-100%) !important;
    will-change: transform, opacity;
    backface-visibility: hidden;
    contain: layout style paint;
    isolation: isolate;
}

/* Filter panel initial state: at starting position (off-screen below), 95% transparent */
#filter-panel:not(.revealed) {
    opacity: 0.05 !important;
    bottom: 1.5rem !important;
    left: 50% !important;
    transform: translateX(-50%) translateY(100%) !important;
    will-change: transform, opacity;
    backface-visibility: hidden;
    contain: layout style paint;
    isolation: isolate;
}

/* Reveal animation keyframes - header moves down from top, filter moves up from bottom */
@keyframes reveal-header {
    from {
        opacity: 0.05;
        transform: translateX(-50%) translateY(-100%);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes reveal-filter {
    from {
        opacity: 0.05;
        transform: translateX(-50%) translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Apply animation when revealed - use high specificity with GPU acceleration */
#header-panel.revealed {
    animation: reveal-header 2s cubic-bezier(0.23, 1, 0.32, 1) forwards;
    animation-fill-mode: forwards;
    will-change: transform, opacity;
    backface-visibility: hidden;
    contain: layout style paint;
    isolation: isolate;
    top: 1.5rem !important; /* Ensure top position is maintained */
    left: 50% !important;
    transform: translateX(-50%) !important; /* Base transform, animation adds to this */
}

/* Remove will-change after animation completes */
#header-panel.revealed.animation-complete {
    will-change: auto;
}

#filter-panel.revealed {
    animation: reveal-filter 2s cubic-bezier(0.23, 1, 0.32, 1) forwards;
    animation-fill-mode: forwards;
    will-change: transform, opacity;
    backface-visibility: hidden;
    contain: layout style paint;
    isolation: isolate;
    bottom: 1.5rem !important; /* Ensure bottom position is maintained */
    left: 50% !important;
    transform: translateX(-50%) !important; /* Base transform, animation adds to this */
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    #header-panel:not(.revealed),
    #filter-panel:not(.revealed) {
        opacity: 1 !important;
        top: auto !important;
        bottom: auto !important;
        transform: translate(-50%, 0) !important;
    }
    
    #header-panel.revealed,
    #filter-panel.revealed {
        animation: none !important;
    }
}

/* ============================================
   Toast Notifications
   ============================================ */

/* Toast Notification Styles */
#toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 500px;
    width: 90%;
    pointer-events: none;
}

.toast {
    background: linear-gradient(135deg, rgba(51, 65, 85, 0.95) 0%, rgba(30, 41, 59, 0.95) 100%);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    padding: 14px 18px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    pointer-events: auto;
    animation: toast-slide-in 0.35s cubic-bezier(0.22, 0.95, 0.57, 1.02);
    direction: rtl;
}

.toast.toast-success {
    border-right: 3px solid #10b981;
}

.toast.toast-error {
    border-right: 3px solid #ef4444;
}

.toast.toast-warning {
    border-right: 3px solid #f59e0b;
}

.toast.toast-info {
    border-right: 3px solid #3b82f6;
}

.toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.toast-success .toast-icon {
    color: #10b981;
}

.toast-error .toast-icon {
    color: #ef4444;
}

.toast-warning .toast-icon {
    color: #f59e0b;
}

.toast-info .toast-icon {
    color: #3b82f6;
}

.toast-message {
    flex: 1;
    color: #f1f5f9;
    font-size: 14px;
    line-height: 1.5;
}

.toast-close {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
    font-size: 16px;
}

.toast-close:hover {
    color: #f1f5f9;
    background: rgba(148, 163, 184, 0.1);
}

@keyframes toast-slide-in {
    0% {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toast-slide-out {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
}

.toast.toast-exiting {
    animation: toast-slide-out 0.25s cubic-bezier(0.3, 0.7, 0.4, 1) forwards;
}

/* ============================================
   Color Input Styling
   ============================================ */

/* Color input styling - ensure inner color square has rounded corners */
input[type="color"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
    border-radius: inherit;
    overflow: hidden;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: inherit;
}

input[type="color"]::-moz-color-swatch {
    border: none;
    border-radius: inherit;
}

/* Specific border radius for different containers */
input[type="color"].rounded-2xl,
input[type="color"].rounded-2xl::-webkit-color-swatch,
input[type="color"].rounded-2xl::-moz-color-swatch {
    border-radius: 1rem; /* rounded-2xl = 1rem */
}

input[type="color"].rounded-xl,
input[type="color"].rounded-xl::-webkit-color-swatch,
input[type="color"].rounded-xl::-moz-color-swatch {
    border-radius: 0.75rem; /* rounded-xl = 0.75rem */
}

input[type="color"].rounded-lg,
input[type="color"].rounded-lg::-webkit-color-swatch,
input[type="color"].rounded-lg::-moz-color-swatch {
    border-radius: 0.5rem; /* rounded-lg = 0.5rem */
}

/* ============================================
   Modal Animations
   ============================================ */

/* Confirmation modal animation */
@keyframes scale-in {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

/* ============================================
   Tooltip Styles
   ============================================ */

.tooltip-container {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}

.tooltip-icon {
    cursor: help;
    color: #94a3b8;
    transition: color 0.2s;
    display: inline-block;
}

.tooltip-icon:hover {
    color: #6366f1;
}

.tooltip-content {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    right: 50%;
    transform: translateX(50%);
    background: linear-gradient(to bottom, #1e293b, #0f172a);
    color: #f1f5f9;
    text-align: right;
    padding: 12px 16px;
    border-radius: 12px;
    white-space: normal;
    width: 280px;
    font-size: 13px;
    line-height: 1.6;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    pointer-events: none;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.tooltip-content::before {
    content: "";
    position: absolute;
    top: 100%;
    right: 50%;
    transform: translateX(50%);
    border: 6px solid transparent;
    border-top-color: #1e293b;
}

.tooltip-container:hover .tooltip-content {
    display: block;
}

.tooltip-title {
    font-weight: 600;
    color: #fbbf24;
    margin-bottom: 6px;
    font-size: 14px;
}

.tooltip-text {
    color: #e2e8f0;
    margin: 0;
}

/* ============================================
   Responsive Design
   ============================================ */

/* Mobile responsive */
@media (max-width: 768px) {
    .filter-panel {
        /* Mobile styles handled by Tailwind classes */
    }
    
    /* Header adjustments for mobile */
    #header-panel {
        width: 95% !important;
        padding: 0.5rem !important;
    }
    
    #header-panel .flex {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    /* Filter panel mobile adjustments */
    #filter-panel {
        width: 95% !important;
        padding: 0.75rem !important;
    }
    
    /* Modal adjustments */
    .fixed.inset-0 {
        padding: 1rem !important;
    }
    
    /* Statistics modal mobile */
    #statistics-modal > div {
        max-height: 95vh !important;
        width: 100% !important;
    }
    
    /* Touch-friendly buttons */
    button, .filter-chip {
        min-height: 44px;
        min-width: 44px;
    }
}

@media (max-width: 640px) {
    /* Stack header elements vertically on very small screens */
    #header-panel .flex.items-center.justify-between {
        flex-direction: column;
        gap: 1rem;
    }
    
    /* Make filter chips scrollable on mobile */
    #filter-panel .flex.flex-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
}


