/* Responsive CSS - Mobile and Tablet Optimizations */

/* Mobile First Approach */
@media (max-width: 480px) {
    /* Spacing adjustments */
    :root {
        --spacing-xs: 0.25rem;
        --spacing-sm: 0.75rem;
        --spacing-md: 1rem;
        --spacing-lg: 1.5rem;
        --spacing-xl: 2rem;
    }
    
    /* Main container */
    .main-container {
        padding: var(--spacing-sm);
    }
    
    /* Header */
    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-sm);
    }
    
    .dashboard-title {
        font-size: 1.8rem;
    }
    
    .dashboard-subtitle {
        font-size: 1rem;
    }
    
    .header-controls {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }
    
    .market-status,
    .last-updated {
        font-size: 0.8rem;
    }
    
    /* Market overview */
    .overview-stats {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm);
    }
    
    .stat-card {
        padding: var(--spacing-sm);
    }
    
    .stat-value {
        font-size: 1.4rem;
    }
    
    
    /* Crypto grid */
    .crypto-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }
    
    /* Crypto cards */
    .crypto-card {
        padding: var(--spacing-sm);
    }
    
    .card-header {
        margin-bottom: var(--spacing-sm);
    }
    
    .coin-icon {
        width: 40px;
        height: 40px;
    }
    
    .coin-details h3 {
        font-size: 1.1rem;
    }
    
    .current-price {
        font-size: 1.2rem;
    }
    
    .chart-container {
        height: 120px;
        margin: var(--spacing-sm) 0;
    }
    
    .indicators-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-xs);
    }
    
    .indicator-item {
        padding: var(--spacing-xs);
    }
    
    .levels-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-xs);
    }
    
    /* Modal */
    .modal-content {
        width: 100vw;
        height: 100vh;
        max-width: none;
        max-height: none;
        border-radius: 0;
    }
    
    .modal-header {
        padding: var(--spacing-sm);
    }
    
    .modal-coin-icon {
        width: 48px;
        height: 48px;
    }
    
    .modal-coin-info h2 {
        font-size: 1.5rem;
    }
    
    .modal-body {
        padding: var(--spacing-sm);
    }
    
    .modal-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm);
    }
    
    .modal-section {
        padding: var(--spacing-sm);
    }
    
    .price-grid,
    .signal-grid,
    .indicator-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-xs);
    }
    
    /* Footer */
    .footer-content {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }
    
    .disclaimer p {
        font-size: 0.9rem;
    }
}

/* Tablet Portrait */
@media (min-width: 481px) and (max-width: 768px) {
    .main-container {
        padding: var(--spacing-md);
    }
    
    .dashboard-title {
        font-size: 2.2rem;
    }
    
    .overview-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .crypto-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }
    
    
    .modal-content {
        width: 95vw;
        max-height: 95vh;
    }
    
    .modal-grid {
        grid-template-columns: 1fr;
    }
    
    .price-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Tablet Landscape */
@media (min-width: 769px) and (max-width: 1024px) {
    .overview-stats {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .crypto-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .modal-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .footer-content {
        grid-template-columns: 2fr 1fr;
    }
}

/* Desktop Small */
@media (min-width: 1025px) and (max-width: 1200px) {
    .crypto-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Desktop Large */
@media (min-width: 1201px) {
    .crypto-grid {
        grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    }
    
    .main-container {
        max-width: 1400px;
    }
}

/* Ultra Wide */
@media (min-width: 1600px) {
    .main-container {
        max-width: 1600px;
    }
    
    .crypto-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Height-based responsive adjustments */
@media (max-height: 600px) {
    .modal-content {
        max-height: 95vh;
    }
    
    .chart-container {
        height: 100px;
    }
    
    .dashboard-header {
        margin-bottom: var(--spacing-md);
    }
    
    .market-overview {
        margin-bottom: var(--spacing-md);
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .crypto-card:hover {
        transform: none;
    }
    
    .crypto-card:active {
        transform: scale(0.98);
    }
    
    .refresh-btn,
    .chart-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .modal-close {
        min-height: 44px;
        min-width: 44px;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .coin-icon,
    .modal-coin-icon {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Dark mode preference */
@media (prefers-color-scheme: dark) {
    /* Already using dark theme by default */
}

/* Light mode preference (if implemented in future) */
@media (prefers-color-scheme: light) {
    /* Light theme variables would go here */
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .loading-spinner {
        animation: none;
    }
    
    .status-indicator {
        animation: none;
    }
}

/* High contrast preference */
@media (prefers-contrast: high) {
    :root {
        --border-color: #ffffff;
        --text-primary: #ffffff;
        --text-secondary: #cccccc;
        --bg-card: #000000;
        --bg-secondary: #111111;
    }
}

/* Print styles */
@media print {
    .modal,
    .loading-screen,
    .refresh-btn,
    .chart-controls,
    .filter-controls,
    .sort-controls {
        display: none !important;
    }
    
    .main-container {
        max-width: none;
        padding: 0;
    }
    
    .crypto-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .crypto-card {
        break-inside: avoid;
        border: 1px solid #000;
    }
    
    .chart-container {
        display: none;
    }
    
    body {
        background: white;
        color: black;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .dashboard-header {
        margin-bottom: var(--spacing-sm);
    }
    
    .market-overview {
        margin-bottom: var(--spacing-sm);
    }
    
    .overview-stats {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .crypto-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .chart-container {
        height: 100px;
    }
    
    .modal-content {
        height: 100vh;
        overflow-y: auto;
    }
}

/* Accessibility improvements */
@media (forced-colors: active) {
    .signal-badge,
    .chart-btn.active {
        border: 2px solid;
    }
    
    .confidence-fill,
    .rsi-fill {
        border: 1px solid;
    }
}

/* Safari-specific adjustments */
@supports (-webkit-touch-callout: none) {
    .modal {
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-content {
        -webkit-overflow-scrolling: touch;
    }
}

/* Firefox-specific adjustments */
@-moz-document url-prefix() {
    .chart-container {
        min-height: 120px;
    }
}

/* Edge-specific adjustments */
@supports (-ms-ime-align: auto) {
    .crypto-grid {
        display: -ms-grid;
    }
}