/* Additional Responsive and Performance Styles */

/* Performance optimizations */
.low-performance * {
    animation-duration: 2s !important;
    transition-duration: 0.1s !important;
}

.low-performance .stars,
.low-performance .stars2,
.low-performance .stars3 {
    animation: none;
}

.low-performance .caustics-overlay {
    display: none;
}

.low-performance .aquarium-overlay::before {
    animation: none;
}

.low-performance .lamp-glow {
    animation: none;
}

/* Mobile-specific optimizations */
.mobile-optimized .environment-card {
    margin-bottom: 20px;
}

.mobile-optimized #aquarium-canvas {
    height: 250px;
}

.mobile-optimized #lava-lamp-canvas {
    width: 200px;
    height: 400px;
}

.mobile-optimized .control-section {
    padding: 10px;
    margin-bottom: 15px;
}

.mobile-optimized .preset-buttons {
    grid-template-columns: 1fr;
    gap: 8px;
}

.mobile-optimized .preset-btn {
    padding: 12px;
    font-size: 0.9rem;
}

/* Low memory optimizations */
.low-memory .aquarium-container {
    box-shadow: 0 0 15px rgba(0, 150, 200, 0.2);
}

.low-memory .environment-card {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.low-memory .stars3 {
    display: none;
}

/* Slow connection optimizations */
.slow-connection .caustics-overlay {
    display: none;
}

.slow-connection .lamp-glow {
    display: none;
}

/* Enhanced mobile controls */
@media (max-width: 768px) {
    .control-group label {
        font-size: 0.85rem;
        margin-bottom: 8px;
    }
    
    .control-group select,
    .control-group input[type="range"] {
        padding: 10px;
        font-size: 0.9rem;
        border-radius: 8px;
    }
    
    .species-toggle {
        display: flex;
        align-items: center;
        padding: 8px;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 6px;
        margin-bottom: 5px;
        cursor: pointer;
        transition: background 0.2s ease;
    }
    
    .species-toggle:hover {
        background: rgba(255, 255, 255, 0.1);
    }
    
    .species-toggle input {
        margin-right: 8px;
    }
    
    .species-toggle span {
        font-size: 0.8rem;
        color: #ccc;
    }
    
    .species-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 5px;
    }
    
    .feeding-buttons {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .feed-btn {
        padding: 10px;
        background: linear-gradient(45deg, #1a1a2e, #16213e);
        border: 1px solid #00d4ff;
        color: #00d4ff;
        border-radius: 6px;
        cursor: pointer;
        font-size: 0.8rem;
        transition: all 0.3s ease;
    }
    
    .feed-btn:hover,
    .feed-btn:active {
        background: linear-gradient(45deg, #00d4ff, #0099cc);
        color: #000;
        transform: scale(1.02);
    }
    
    .view-buttons {
        display: grid;
        grid-template-columns: 1fr;
        gap: 6px;
    }
    
    .view-btn {
        padding: 8px;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.2);
        color: #ccc;
        border-radius: 6px;
        cursor: pointer;
        font-size: 0.8rem;
        transition: all 0.3s ease;
    }
    
    .view-btn.active,
    .view-btn:hover {
        background: rgba(0, 212, 255, 0.2);
        border-color: #00d4ff;
        color: #00d4ff;
    }
}

/* Ultra-small screens */
@media (max-width: 360px) {
    .sidebar {
        width: 100vw;
    }
    
    .main-header h1 {
        font-size: 1.6rem;
    }
    
    .main-header p {
        font-size: 0.9rem;
    }
    
    .environment-card {
        padding: 10px;
    }
    
    .environment-card h2 {
        font-size: 1.3rem;
    }
    
    #aquarium-canvas {
        height: 200px;
    }
    
    #lava-lamp-canvas {
        width: 150px;
        height: 300px;
    }
    
    .lamp-base,
    .lamp-top {
        width: 170px;
    }
    
    .control-section {
        padding: 8px;
    }
    
    .control-section h3 {
        font-size: 1rem;
    }
    
    .sidebar-header h2 {
        font-size: 1rem;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .environments-container {
        flex-direction: row;
        gap: 20px;
        justify-content: center;
        align-items: flex-start;
    }
    
    .environment-card {
        flex: 1;
        max-width: 45%;
    }
    
    #aquarium-canvas {
        height: 200px;
    }
    
    #lava-lamp-canvas {
        width: 150px;
        height: 300px;
    }
    
    .main-header {
        margin: 20px 0;
    }
    
    .main-header h1 {
        font-size: 1.8rem;
    }
}

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

/* Dark mode preferences */
@media (prefers-color-scheme: dark) {
    /* Already optimized for dark mode */
}

/* Light mode fallback (if user prefers light) */
@media (prefers-color-scheme: light) {
    body {
        background: #000;
        color: #fff;
    }
    
    .sidebar {
        background: rgba(15, 15, 30, 0.95);
    }
    
    .environment-card {
        background: rgba(255, 255, 255, 0.05);
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .stars,
    .stars2,
    .stars3 {
        animation: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .sidebar {
        background: rgba(0, 0, 0, 0.95);
        border-right: 3px solid #fff;
    }
    
    .control-section {
        border: 2px solid #fff;
        background: rgba(0, 0, 0, 0.8);
    }
    
    .preset-btn,
    .feed-btn,
    .view-btn {
        border: 2px solid #fff;
        background: #000;
        color: #fff;
    }
    
    .preset-btn:hover,
    .feed-btn:hover,
    .view-btn:hover {
        background: #fff;
        color: #000;
    }
}

/* Focus indicators for keyboard navigation */
button:focus,
select:focus,
input:focus {
    outline: 2px solid #00d4ff;
    outline-offset: 2px;
}

/* Loading states */
.loading {
    opacity: 0.5;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #00d4ff;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Error states */
.error {
    border: 2px solid #ff4444;
    background: rgba(255, 68, 68, 0.1);
}

.error-message {
    color: #ff4444;
    font-size: 0.8rem;
    margin-top: 5px;
}

/* Success states */
.success {
    border: 2px solid #44ff44;
    background: rgba(68, 255, 68, 0.1);
}

/* Tooltip styles */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

.tooltip:hover::after {
    opacity: 1;
}

/* Print styles */
@media print {
    .sidebar,
    .sidebar-toggle-main,
    .main-footer {
        display: none;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    body {
        background: #fff;
        color: #000;
    }
    
    .stars-container {
        display: none;
    }
}

