/* Enhanced Main Interface Styles - Fixed Modal System & Viewport Issues */
/* COMPLETE FILE - Updated with Enhanced Modal Scrolling System */

/* Import the base styles */
@import url('styles.css');

/* ========================================
   Loading Screen
   ======================================== */

.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    filter: brightness(0) invert(1);
}

.loading-text {
    font-size: 18px;
    margin-bottom: 20px;
    font-weight: 500;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========================================
   Main Container & Layout
   ======================================== */

.main-container {
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* ========================================
   Header
   ======================================== */

.main-header {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-logo {
    width: 50px;
    height: 50px;
    filter: brightness(0) invert(1);
}

.header-title h1 {
    margin: 0;
    color: white;
    font-size: 24px;
    font-weight: 600;
}

.location-subtitle {
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
}

.user-stats {
    display: flex;
    gap: 20px;
}

.stat-item {
    text-align: center;
    color: white;
}

.stat-number {
    display: block;
    font-size: 24px;
    font-weight: bold;
}

.stat-label {
    display: block;
    font-size: 12px;
    opacity: 0.8;
}

/* ========================================
   View Controls
   ======================================== */

.view-controls {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    border-radius: 15px;
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.view-toggle {
    display: flex;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
}

.view-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.view-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.view-btn.active {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-weight: 500;
}

.view-icon {
    font-size: 16px;
}

.search-container {
    display: flex;
    gap: 10px;
    flex: 1;
    max-width: 400px;
}

.search-input {
    flex: 1;
    padding: 10px 15px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 14px;
    backdrop-filter: blur(10px);
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.search-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.search-btn {
    padding: 10px 15px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.search-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

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

.filter-panel {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-label {
    color: white;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}

.filter-select {
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 14px;
    cursor: pointer;
    backdrop-filter: blur(10px);
    min-width: 120px;
}

.filter-select:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.25);
}

.filter-select option {
    background: #333;
    color: white;
}

.clear-filters-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    margin-left: auto;
}

.clear-filters-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ========================================
   Results Info & Location Controls
   ======================================== */

.results-info {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    border-radius: 10px;
    padding: 15px 20px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    flex-wrap: wrap;
    gap: 15px;
}

.location-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.location-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.location-icon {
    opacity: 0.8;
}

/* ========================================
   Content Area & Grid View
   ======================================== */

.content-area {
    position: relative;
}

.grid-view {
    display: block;
}

.grid-view.active {
    display: block;
}

.map-view {
    display: none;
}

.map-view.active {
    display: block;
}

.token-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

/* ========================================
   Token Cards
   ======================================== */

.token-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 
        0 1px 3px rgba(0, 0, 0, 0.055),
        0 4px 8px rgba(0, 0, 0, 0.044),
        0 8px 16px rgba(0, 0, 0, 0.033),
        0 16px 32px rgba(0, 0, 0, 0.022);
    transition: all 0.15s ease;
    cursor: pointer;
    position: relative;
    transform: translateY(0);
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    outline: none;
}

.token-card:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.066),
        0 8px 16px rgba(0, 0, 0, 0.055),
        0 16px 32px rgba(0, 0, 0, 0.044),
        0 24px 48px rgba(0, 0, 0, 0.033);
    background: rgba(255, 255, 255, 0.2);
}

.token-card:active {
    box-shadow: 
        0 1px 2px rgba(0, 0, 0, 0.08),
        0 2px 4px rgba(0, 0, 0, 0.06),
        0 3px 6px rgba(0, 0, 0, 0.04);
    transform: translateY(1px);
    transition: all 0.1s ease;
}

.token-image-container {
    width: 100%;
    height: 200px;
    overflow: hidden;
    position: relative;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* BASE IMAGE DISPLAY RULE - Dynamic positioning applied via JavaScript */
.token-image, .modal-target-image {
    width: 100%;
    height: 250px;
    object-fit: cover;
    object-position: center center; /* Default, overridden by JavaScript */
}

.token-image {
    height: 200px; /* Override for grid cards */
    transition: transform 0.3s ease, opacity 0.3s ease, filter 0.3s ease;
    display: block;
}

.token-image.token-placeholder {
    opacity: 0.35;
    object-fit: contain;
    object-position: center;
    padding: 10px;
    padding-top: 0px;
    margin-top: 0px;
    background: rgba(255, 255, 255, 0.1);
}

.token-image.token-loaded {
    opacity: 1;
    filter: none;
    object-fit: cover;
    padding: 0;
    background: none;
}

.token-image.token-error {
    opacity: 0.35;
    object-fit: contain;
    object-position: center;
    padding: 10px;
    padding-top: 0px;
    margin-top: 0px;
    background: rgba(255, 255, 255, 0.1);
    transition: none !important;
}

.token-card:hover .token-image:not(.token-error) {
    transform: scale(1.05);
}

.image-error-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    z-index: 2;
    pointer-events: none;
}

.token-content {
    padding: 20px;
    color: white;
}

.token-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.token-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    line-height: 1.2;
}

.token-subtitle {
    font-size: 12px;
    opacity: 0.7;
    margin: 2px 0 0 0;
}

.token-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    text-transform: capitalize;
}

.token-status.available {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.token-status.earned {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.token-status.redeemed {
    background: rgba(168, 85, 247, 0.2);
    color: #a855f7;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.token-description {
    font-size: 14px;
    line-height: 1.4;
    opacity: 0.9;
    margin-bottom: 15px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.token-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.token-meta-item {
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.target-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.target-category, .target-difficulty, .target-time {
    padding: 4px 10px;
    background: rgba(1, 9, 254, 0.1);
    border-radius: 15px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.token-vendors {
    font-size: 12px;
    opacity: 0.8;
}

.token-vendors strong {
    color: white;
}

.token-distance {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 500;
}

/* ========================================
   Map View Placeholder
   ======================================== */

.map-placeholder {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 60px 20px;
    text-align: center;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.map-placeholder-content {
    max-width: 400px;
    margin: 0 auto;
}

.map-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 20px;
}

.map-placeholder h3 {
    margin: 0 0 15px 0;
    font-size: 24px;
}

.map-placeholder p {
    margin: 10px 0;
    opacity: 0.8;
    line-height: 1.5;
}

/* ========================================
   No Results
   ======================================== */

.no-results {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 60px 20px;
    text-align: center;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.no-results-content {
    max-width: 400px;
    margin: 0 auto;
}

.no-results-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 20px;
    opacity: 0.6;
}

.no-results h3 {
    margin: 0 0 15px 0;
    font-size: 24px;
}

.no-results p {
    margin: 10px 0 30px 0;
    opacity: 0.8;
    line-height: 1.5;
}

.reset-btn {
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.reset-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* ========================================
   ENHANCED MODAL SCROLLING SYSTEM - FIXED
   ======================================== */

/* Ensure html and body can be locked without affecting modal */
html.modal-open,
body.modal-open {
    overflow: hidden !important;
    position: relative;
}

/* Modal backdrop - ensure it covers everything */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    box-sizing: border-box;
    
    /* Prevent any scrolling on the modal backdrop */
    overflow: hidden;
}

/* Modal content - proper flex layout for scrolling */
.modal-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    max-width: 600px;
    width: 100%;
    max-height: calc(100vh - 40px);
    
    /* Critical: Use flexbox for proper height management */
    display: flex;
    flex-direction: column;
    
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    
    /* Ensure modal content can receive touch events */
    touch-action: pan-y;
}

/* Fixed header - doesn't scroll */
.modal-header {
    padding: 20px 20px 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.05);
    
    /* Prevent touch events from bubbling */
    touch-action: none;
}

.modal-header h2 {
    margin: 0;
    color: #333;
    font-size: 20px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
}

/* Scrollable body - FIXED implementation */
.modal-body {
    padding: 20px;
    color: #333;
    position: relative;
    
    /* Critical scrolling properties */
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    
    /* Enhanced scrolling behavior */
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    
    /* Ensure touch events work properly */
    touch-action: pan-y;
    
    /* Create stacking context for scroll indicator */
    position: relative;
    z-index: 1;
}

/* Enhanced scrollbar styling */
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    transition: background 0.3s ease;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.4);
}

/* Scroll indicator for better UX */
.scroll-indicator {
    position: fixed;
    right: 25px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 60px;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.1),
        rgba(0, 0, 0, 0.3),
        rgba(0, 0, 0, 0.1)
    );
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 10;
}

/* Visual feedback when content is scrollable */
.modal-body.scrollable {
    /* Add subtle gradient to indicate more content */
    background: 
        linear-gradient(white 30%, transparent),
        linear-gradient(transparent, white 70%) 0 100%,
        radial-gradient(farthest-side at 50% 0, rgba(0,0,0,0.1), transparent),
        radial-gradient(farthest-side at 50% 100%, rgba(0,0,0,0.1), transparent) 0 100%;
    background-color: transparent;
    background-repeat: no-repeat;
    background-attachment: local, local, scroll, scroll;
    background-size: 100% 40px, 100% 40px, 100% 14px, 100% 14px;
}

/* Fixed footer - doesn't scroll */
.modal-footer {
    padding: 15px 20px 20px 20px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-shrink: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    
    /* Prevent touch events from bubbling */
    touch-action: none;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    flex: 1;
    max-width: 200px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
    min-width: 80px;
}

.btn-secondary:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Ensure buttons have proper touch targets */
.modal-footer .btn {
    min-height: 44px;
    touch-action: manipulation;
}

/* Token Detail Modal Specific */
.target-detail-content {
    display: block !important;
    width: 100% !important;
}

/* Optimized Modal Image Display */
#modalTargetImage {
    width: 100% !important;
    height: 200px !important; /* Reduced from 250px for better space usage */
    max-height: 200px !important;
    object-fit: cover !important;
    display: block !important;
    border-radius: 10px !important;
    margin-bottom: 15px !important; /* Reduced margin */
    overflow: hidden !important;
    /* Object position set dynamically by JavaScript */
}

.modal-target-image.token-placeholder,
.modal-target-image.token-error {
    opacity: 0.5;
    object-fit: contain;
    object-position: center;
    padding: 10px;
    background: rgba(0, 0, 0, 0.05);
}

.modal-target-image.token-loaded {
    opacity: 1;
    object-fit: cover;
    padding: 0;
    background: none;
}

.token-info {
    flex: 1;
    width: 100% !important;
    margin-top: 0 !important;
}

.token-info .token-meta {
    margin: 10px 0; /* Reduced from 15px for better spacing */
    display: flex;
    flex-wrap: wrap;
    gap: 8px; /* Reduced gap */
}

.token-info .token-meta-item {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
    padding: 3px 8px; /* Reduced padding */
}

/* Token preview in modal */
#tokenPreview {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    padding: 12px; /* Reduced from 15px */
    margin-top: 12px; /* Reduced from 15px */
}

/* Grid card images - ensure they also display correctly */
.token-image-container {
    width: 100% !important;
    height: 200px !important;
    overflow: hidden !important;
    position: relative !important;
}

.token-image {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

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

/* iPhone specific optimizations */
@media (max-width: 430px) and (max-height: 930px) {
    .modal {
        padding: 10px;
    }
    
    .modal-content {
        max-height: calc(100vh - 20px);
    }
    
    /* Reduce image height to make room for scrolling */
    #modalTargetImage {
        height: 180px !important;
    }
}

/* iPhone 13/14/15 series specific */
@media (max-width: 390px) and (max-height: 844px) {
    .modal-content {
        max-height: calc(100vh - 140px); /* More conservative for iPhone 13 */
    }
    
    .modal {
        padding: 5px; /* Minimal padding */
        align-items: flex-start; /* Align to top */
        padding-top: 30px; /* Some top spacing */
    }
}

/* Very small screens */
@media (max-width: 375px) {
    .modal {
        padding: 5px;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .modal-header {
        padding: 15px 15px 0 15px;
    }
    
    .modal-footer {
        padding: 10px 15px 15px 15px;
    }
}

/* Landscape orientation handling */
@media (max-height: 500px) and (orientation: landscape) {
    .modal {
        align-items: flex-start;
        padding-top: 10px;
    }
    
    .modal-content {
        max-height: calc(100vh - 20px);
    }
    
    #modalTargetImage {
        height: 120px !important;
    }
}

/* For short screens */
@media (max-height: 600px) {
    .modal {
        padding: 10px; /* Reduce modal padding on short screens */
        align-items: flex-start; /* Align to top instead of center */
        padding-top: 20px;
    }
    
    .modal-content {
        max-height: calc(100vh - 20px); /* Even tighter constraints */
    }
    
    #modalTargetImage {
        height: 150px !important; /* Further reduce image height */
    }
    
    .modal-header {
        padding: 15px 15px 0 15px; /* Reduce header padding */
    }
    
    .modal-body {
        padding: 15px; /* Reduce body padding */
    }
    
    .modal-footer {
        padding: 10px 15px 15px 15px; /* Reduce footer padding */
    }
}

/* For landscape orientation on phones */
@media (max-height: 500px) and (orientation: landscape) {
    #modalTargetImage {
        height: 120px !important; /* Very compact for landscape */
    }
    
    .modal-content {
        max-height: calc(100vh - 10px);
    }
    
    .modal-header h2 {
        font-size: 18px; /* Smaller header text */
        margin: 0;
    }
    
    .modal-body {
        padding: 10px; /* Minimal padding for landscape */
    }
    
    .token-info .token-meta {
        margin: 8px 0; /* Further reduce spacing */
    }
}

/* ========================================
   MODAL ACCESSIBILITY ENHANCEMENTS
   ======================================== */

/* Focus management within modal */
.modal-content *:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .modal-body {
        scroll-behavior: auto;
    }
    
    .scroll-indicator {
        transition: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .modal-body::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.8);
    }
    
    .scroll-indicator {
        background: #000;
    }
}

/* ========================================
   RESPONSIVE DESIGN - EXISTING RULES
   ======================================== */

@media (max-width: 768px) {
    .main-container {
        padding: 10px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .user-stats {
        justify-content: center;
    }
    
    .view-controls {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .search-container {
        max-width: none;
    }
    
    .filter-panel {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .filter-group {
        justify-content: space-between;
    }
    
    .filter-select {
        min-width: auto;
        flex: 1;
    }
    
    .token-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .target-detail-content {
        flex-direction: column;
    }
    
    .modal-target-image,
    #modalTargetImage {
        width: 100% !important;
        height: 200px !important;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .results-info {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .location-controls {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .header-logo {
        width: 40px;
        height: 40px;
    }
    
    .header-title h1 {
        font-size: 20px;
    }
    
    .view-btn {
        padding: 8px 15px;
        font-size: 13px;
    }
    
    .filter-label {
        font-size: 13px;
    }
    
    .filter-select {
        font-size: 13px;
        padding: 6px 10px;
    }
    
    .token-title {
        font-size: 16px;
    }
    
    .token-content {
        padding: 15px;
    }
    
    .modal-target-image,
    #modalTargetImage {
        height: 180px !important;
    }
}

/* ========================================
   PERFORMANCE & ACCESSIBILITY
   ======================================== */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .token-card {
        transition: none !important;
    }
    
    .token-card:hover {
        transform: none !important;
    }
    
    .token-image {
        transition: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .token-card {
        border: 2px solid rgba(255, 255, 255, 0.8);
    }
    
    .token-status {
        border-width: 2px;
    }
    
    .token-distance {
        background: rgba(0, 0, 0, 0.9);
        border: 1px solid white;
    }
}