/* Additional UI components and styles */

/* Mobile-specific optimizations */
@media (max-width: 768px) {
    .game-header {
        padding: 0.5rem;
    }
    
    .game-nav {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.25rem;
        width: 100%;
    }
    
    .nav-btn {
        padding: 0.5rem;
        font-size: 0.8rem;
    }
    
    .side-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 250px;
        width: 100%;
        z-index: 100;
        transform: translateY(200px);
        transition: transform 0.3s ease;
    }
    
    .side-panel.mobile-expanded {
        transform: translateY(0);
    }
    
    .mobile-panel-handle {
        position: absolute;
        top: -40px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0, 0, 0, 0.8);
        color: white;
        border: none;
        padding: 0.5rem 1rem;
        border-radius: 10px 10px 0 0;
        cursor: pointer;
    }
    
    .resource-display {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
        font-size: 0.9rem;
    }
    
    .build-categories {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-bg: #1a1a1a;
        --secondary-bg: #2d2d2d;
        --text-primary: #ffffff;
        --text-secondary: #b3b3b3;
        --accent-color: #4facfe;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }
    
    .nav-btn.active {
        background: white;
        color: black;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Loading states */
.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

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

/* 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.95);
    color: white;
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
    max-width: 300px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

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

/* Enhanced tooltips for infrastructure items */
.infrastructure-item .tooltip::after {
    white-space: normal;
    width: 250px;
    text-align: left;
    line-height: 1.4;
}

.upgrade-btn.tooltip::after {
    white-space: normal;
    width: 220px;
    text-align: center;
    font-weight: bold;
    background: linear-gradient(135deg, rgba(0, 123, 255, 0.9), rgba(0, 86, 179, 0.9));
}

/* Progress indicators */
.progress-ring {
    width: 30px;
    height: 30px;
}

.progress-ring-circle {
    fill: none;
    stroke: #4facfe;
    stroke-width: 2;
    stroke-linecap: round;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
    transition: stroke-dasharray 0.3s;
}

/* Notification badges */
.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: bold;
}

/* Context menu */
.context-menu {
    position: fixed;
    background: rgba(0, 0, 0, 0.9);
    border-radius: 8px;
    padding: 0.5rem 0;
    min-width: 150px;
    z-index: 10000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    display: none;
}

.context-menu-item {
    padding: 0.5rem 1rem;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s;
}

.context-menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.context-menu-separator {
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0.5rem 0;
}

/* Drag and drop styles */
.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.drop-zone {
    border: 2px dashed #4facfe;
    background: rgba(79, 172, 254, 0.1);
}

.drop-zone.valid {
    border-color: #00b894;
    background: rgba(0, 184, 148, 0.1);
}

.drop-zone.invalid {
    border-color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
}

/* Keyboard navigation improvements */
.keyboard-navigation button:focus,
.keyboard-navigation input:focus,
.keyboard-navigation select:focus {
    outline: 2px solid #4facfe;
    outline-offset: 2px;
}

/* Debug Panel Styles */
.debug-panel {
    margin-top: 1rem;
    border: 1px solid #444;
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.1);
}

.debug-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid #444;
    cursor: pointer;
}

.debug-header h4 {
    margin: 0;
    font-size: 0.9rem;
    color: #ccc;
}

.debug-toggle {
    background: none;
    border: none;
    color: #ccc;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0;
}

.debug-toggle:hover {
    color: #fff;
}

.debug-content {
    padding: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
}

.debug-content.collapsed {
    display: none;
}

.debug-section {
    margin-bottom: 0.8rem;
}

.debug-section:last-child {
    margin-bottom: 0;
}

.debug-section h5 {
    margin: 0 0 0.3rem 0;
    font-size: 0.8rem;
    color: #aaa;
    font-weight: 600;
}

.debug-info {
    font-size: 0.75rem;
    color: #ddd;
    line-height: 1.3;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.3rem;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    white-space: pre-wrap;
}

.debug-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.debug-btn {
    background: #333;
    color: #fff;
    border: 1px solid #555;
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: background 0.2s;
}

.debug-btn:hover {
    background: #444;
}

.debug-btn:active {
    background: #222;
}

/* Resource Generation Panel */
.resource-generation-panel {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #444;
    border-radius: 4px;
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.resource-generation-panel h4 {
    color: #00ff88;
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    font-weight: bold;
}

.resource-generation-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
}

.resource-gen-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.2rem 0;
}

.resource-gen-label {
    color: #ccc;
    font-size: 0.75rem;
}

.resource-gen-value {
    color: #00ff88;
    font-weight: bold;
    font-size: 0.75rem;
    font-family: 'Consolas', 'Monaco', monospace;
}

.resource-gen-value.positive {
    color: #00ff88;
}

.resource-gen-value.negative {
    color: #ff4444;
}

.resource-gen-value.zero {
    color: #888;
}

/* Print styles */
@media print {
    .screen:not(.active) {
        display: none !important;
    }
    
    .no-print {
        display: none !important;
    }
    
    .game-container {
        print-color-adjust: exact;
    }
    
    .debug-panel {
        display: none !important;
    }
}

/* Enhanced Game List Styles */
.game-item {
    border-left: 4px solid #00ff00;
    transition: all 0.3s ease;
}

.game-item:hover {
    transform: translateX(5px);
    background-color: rgba(0, 255, 0, 0.1);
}

.game-item.my-game {
    border-left-color: #00ff00;
}

.game-item.joinable-game {
    border-left-color: #ffff00;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.game-header h3 {
    margin: 0;
    color: #00ff00;
    font-family: 'Courier New', monospace;
}

.game-status {
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
}

.game-status.waiting_for_players {
    background-color: #ffaa00;
    color: #000;
}

.game-status.active {
    background-color: #00ff00;
    color: #000;
}

.game-status.paused {
    background-color: #ff6600;
    color: #fff;
}

.game-details {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.game-info p {
    margin: 0.25rem 0;
    color: #ccc;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.game-info strong {
    color: #00ff00;
}

.game-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.rejoin-btn, .join-btn {
    padding: 0.5rem 1rem;
    border: 2px solid #00ff00;
    background: rgba(0, 255, 0, 0.1);
    color: #00ff00;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    font-size: 0.8rem;
}

.rejoin-btn:hover, .join-btn:hover {
    background: #00ff00;
    color: #000;
    box-shadow: 0 0 10px #00ff00;
}

.join-btn {
    border-color: #ffff00;
    color: #ffff00;
    background: rgba(255, 255, 0, 0.1);
}

.join-btn:hover {
    background: #ffff00;
    color: #000;
    box-shadow: 0 0 10px #ffff00;
}

/* Map size selection enhancement */
#map-size option {
    color: #000;
    background: #fff;
}

/* Mobile responsive adjustments for game list */
@media (max-width: 768px) {
    .game-details {
        flex-direction: column;
        align-items: stretch;
    }
    
    .game-actions {
        margin-top: 0.5rem;
        flex-direction: row;
        justify-content: stretch;
    }
    
    .rejoin-btn, .join-btn {
        flex: 1;
        padding: 0.75rem;
    }
}
