/* ============================================================================
   DARK MODE STYLES - Comprehensive dark mode theme
   ============================================================================ */

/* Apply dark mode when .dark-mode class is present on body */
body.dark-mode {
    background: #2c3e50 !important;
    color: #ecf0f1 !important;
}

/* ============================================================================
   MAIN LAYOUT DARK MODE
   ============================================================================ */

body.dark-mode .game-container {
    background: #2c3e50 !important;
}

body.dark-mode .game-layout {
    background: #2c3e50 !important;
}

/* Canvas container dark mode */
body.dark-mode .canvas-container {
    background: #2c3e50 !important;
}

body.dark-mode #gameCanvas {
    background: #2c3e50 !important;
}

/* ============================================================================
   LISTS SECTION DARK MODE
   ============================================================================ */

body.dark-mode .lists-section {
    background: rgba(44, 62, 80, 0.95) !important;
    backdrop-filter: blur(10px) !important;
    border-top: 1px solid #7f8c8d !important;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3) !important;
    color: #ecf0f1 !important;
}

body.dark-mode .lists-section.collapsed {
    background: rgba(44, 62, 80, 0.95) !important;
}

body.dark-mode .lists-message {
    background: rgba(52, 73, 94, 0.8) !important;
    border: 1px solid #7f8c8d !important;
    color: #ecf0f1 !important;
}

/* ============================================================================
   LIST CONTAINERS AND ITEMS DARK MODE
   ============================================================================ */

body.dark-mode .list-container {
    background: rgba(52, 73, 94, 0.9) !important;
    border: 1px solid #7f8c8d !important;
    color: #ecf0f1 !important;
}

body.dark-mode .list-container:hover {
    background: rgba(52, 73, 94, 1) !important;
    border-color: #95a5a6 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

body.dark-mode .list-container.highlight-grid {
    background: rgba(52, 152, 219, 0.25) !important;
    border-color: #3498db !important;
    box-shadow: 0 0 20px rgba(52, 152, 219, 0.4) !important;
}

/* Section headers dark mode */
body.dark-mode .section-header {
    color: #ecf0f1 !important;
}

body.dark-mode .section-header.active-section {
    background: rgba(76, 175, 80, 0.2) !important;
    color: #a5d6a7 !important;
}

body.dark-mode .section-header.other-section {
    background: rgba(33, 150, 243, 0.2) !important;
    color: #90caf9 !important;
}

body.dark-mode .section-header.completed-section {
    background: rgba(156, 39, 176, 0.2) !important;
    color: #ce93d8 !important;
}

body.dark-mode .section-header h4 {
    color: inherit !important;
}

/* Title styling */
body.dark-mode .title-container h3 {
    color: #ecf0f1 !important;
}

body.dark-mode .title-container h3:hover {
    background-color: rgba(52, 152, 219, 0.2) !important;
    color: #3498db !important;
}

body.dark-mode .puzzle-title-clickable {
    color: #ecf0f1 !important;
}

/* Completion indicators */
body.dark-mode .completion-indicator.completed {
    color: #a5d6a7 !important;
}

body.dark-mode .count {
    color: #95a5a6 !important;
}

body.dark-mode .percentage {
    color: #7f8c8d !important;
}

/* ============================================================================
   WORD LIST DARK MODE
   ============================================================================ */

body.dark-mode .wordList li {
    background-color: #34495e !important;
    border: 1px solid #7f8c8d !important;
    color: #ecf0f1 !important;
}

body.dark-mode .wordList li:hover {
    background-color: #3c5a78 !important;
    border-color: #95a5a6 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

body.dark-mode .wordList li.word-found {
    background-color: rgba(76, 175, 80, 0.3) !important;
    border-color: #a5d6a7 !important;
    color: #a5d6a7 !important;
}

body.dark-mode .wordList li.word-found-teammate {
    background-color: rgba(33, 150, 243, 0.3) !important;
    border-color: #90caf9 !important;
    color: #90caf9 !important;
}

body.dark-mode .loading-placeholder {
    background-color: #34495e !important;
    color: #7f8c8d !important;
}

body.dark-mode .error-item {
    background-color: rgba(231, 76, 60, 0.3) !important;
    color: #e74c3c !important;
    border-color: #e74c3c !important;
}

/* ============================================================================
   BUTTONS AND CONTROLS DARK MODE
   ============================================================================ */

body.dark-mode .btn {
    background: #34495e !important;
    color: #ecf0f1 !important;
    border: 1px solid #7f8c8d !important;
}

body.dark-mode .btn:hover {
    background: #3c5a78 !important;
    border-color: #95a5a6 !important;
}

body.dark-mode .btn-primary {
    background: #3498db !important;
    border-color: #2980b9 !important;
}

body.dark-mode .btn-primary:hover {
    background: #2980b9 !important;
    border-color: #1f5f8b !important;
}

body.dark-mode .btn-success {
    background: #27ae60 !important;
    border-color: #229954 !important;
}

body.dark-mode .btn-success:hover {
    background: #229954 !important;
    border-color: #1e7e34 !important;
}

body.dark-mode .btn-secondary {
    background: #6c757d !important;
    border-color: #5a6268 !important;
}

body.dark-mode .btn-secondary:hover {
    background: #5a6268 !important;
    border-color: #484e53 !important;
}

/* Toggle buttons */
body.dark-mode .wordlist-toggle {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%) !important;
    border: 1px solid #2980b9 !important;
}

body.dark-mode .wordlist-toggle:hover:not(:disabled) {
    background: linear-gradient(135deg, #2980b9 0%, #1f5f8b 100%) !important;
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.4) !important;
}

body.dark-mode .lists-toggle,
body.dark-mode .controls-toggle {
    background: rgba(52, 73, 94, 0.95) !important;
    color: #ecf0f1 !important;
    border: 1px solid #7f8c8d !important;
}

body.dark-mode .lists-toggle:hover,
body.dark-mode .controls-toggle:hover {
    background: rgba(52, 73, 94, 1) !important;
    color: #ecf0f1 !important;
    border-color: #95a5a6 !important;
}

/* ============================================================================
   FLOATING UI ELEMENTS DARK MODE
   ============================================================================ */

body.dark-mode .control-group {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%) !important;
    border: 1px solid #7f8c8d !important;
    color: #ecf0f1 !important;
}

body.dark-mode .control-group:hover {
    background: linear-gradient(135deg, #34495e 0%, #3c5a78 100%) !important;
    border-color: #95a5a6 !important;
}

body.dark-mode .control-group label {
    color: #ecf0f1 !important;
}

body.dark-mode #inviteFriendsBtn {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%) !important;
    border: 1px solid #7f8c8d !important;
    color: #ecf0f1 !important;
}

body.dark-mode #inviteFriendsBtn:hover {
    background: linear-gradient(135deg, #34495e 0%, #3c5a78 100%) !important;
    border-color: #95a5a6 !important;
}

body.dark-mode .stats-panel {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%) !important;
    border: 1px solid #7f8c8d !important;
    color: #ecf0f1 !important;
}

body.dark-mode .stats-panel:hover {
    background: linear-gradient(135deg, #34495e 0%, #3c5a78 100%) !important;
    border-color: #95a5a6 !important;
}

body.dark-mode .stats-panel p {
    color: rgba(236, 240, 241, 0.8) !important;
}

body.dark-mode .stat-item span {
    color: #ecf0f1 !important;
}

body.dark-mode .settings-button {
    background: rgba(52, 73, 94, 0.9) !important;
    border: 2px solid #7f8c8d !important;
    color: #ecf0f1 !important;
}

body.dark-mode .settings-button:hover {
    background: rgba(52, 73, 94, 1) !important;
    border-color: #95a5a6 !important;
}

/* ============================================================================
   SCROLL CONTROLS DARK MODE
   ============================================================================ */

body.dark-mode .scroll-controls .btn {
    background: rgba(52, 73, 94, 0.9) !important;
    border: 1px solid #7f8c8d !important;
    backdrop-filter: blur(10px) !important;
}

body.dark-mode .scroll-controls .btn:hover {
    background: rgba(52, 73, 94, 1) !important;
    border-color: #95a5a6 !important;
}

/* ============================================================================
   MODAL DARK MODE
   ============================================================================ */

body.dark-mode .invite-modal {
    background-color: rgba(0, 0, 0, 0.7) !important;
}

body.dark-mode .invite-modal-content {
    background-color: #2c3e50 !important;
    color: #ecf0f1 !important;
    border: 1px solid #7f8c8d !important;
}

body.dark-mode .invite-modal-header h2 {
    color: #ecf0f1 !important;
}

body.dark-mode .invite-modal-header p {
    color: #bdc3c7 !important;
}

body.dark-mode .invite-url-container {
    background: #34495e !important;
    border: 2px solid #7f8c8d !important;
    color: #ecf0f1 !important;
}

body.dark-mode .close-modal {
    color: #95a5a6 !important;
}

body.dark-mode .close-modal:hover {
    color: #ecf0f1 !important;
}

/* Form elements in modal */
body.dark-mode .form-group label {
    color: #ecf0f1 !important;
}

body.dark-mode .form-group input,
body.dark-mode .form-group textarea {
    background: #34495e !important;
    border: 1px solid #7f8c8d !important;
    color: #ecf0f1 !important;
}

body.dark-mode .form-group input:focus,
body.dark-mode .form-group textarea:focus {
    border-color: #3498db !important;
    background: #3c5a78 !important;
    outline: none !important;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.3) !important;
}

body.dark-mode .form-group input::placeholder,
body.dark-mode .form-group textarea::placeholder {
    color: #95a5a6 !important;
}

/* Modal tips section */
body.dark-mode .invite-modal-content div[style*="background: #e7f3ff"] {
    background: rgba(52, 152, 219, 0.2) !important;
    color: #ecf0f1 !important;
    border: 1px solid #3498db !important;
}

/* ============================================================================
   NOTIFICATIONS DARK MODE
   ============================================================================ */

body.dark-mode .teammate-notification {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%) !important;
    border: 1px solid #7f8c8d !important;
    color: #ecf0f1 !important;
}

body.dark-mode .teammate-notification.success {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%) !important;
}

body.dark-mode .teammate-notification.info {
    background: linear-gradient(135deg, #3498db 0%, #5dade2 100%) !important;
}

body.dark-mode .notification-text .puzzle-link {
    color: #85c1e9 !important;
    border-bottom-color: rgba(133, 193, 233, 0.5) !important;
}

body.dark-mode .notification-text .puzzle-link:hover {
    color: #ecf0f1 !important;
    border-bottom-color: #ecf0f1 !important;
}

body.dark-mode .notification-close {
    color: rgba(236, 240, 241, 0.7) !important;
}

body.dark-mode .notification-close:hover {
    background: rgba(236, 240, 241, 0.1) !important;
    color: #ecf0f1 !important;
}

/* ============================================================================
   GAME MESSAGES DARK MODE
   ============================================================================ */

body.dark-mode .game-message-success {
    background-color: rgba(39, 174, 96, 0.2) !important;
    color: #a5d6a7 !important;
    border: 1px solid #27ae60 !important;
}

body.dark-mode .game-message-error {
    background-color: rgba(231, 76, 60, 0.2) !important;
    color: #ef9a9a !important;
    border: 1px solid #e74c3c !important;
}

body.dark-mode .game-message-warning {
    background-color: rgba(241, 196, 15, 0.2) !important;
    color: #f4d03f !important;
    border: 1px solid #f1c40f !important;
}

body.dark-mode .game-message-info {
    background-color: rgba(52, 152, 219, 0.2) !important;
    color: #85c1e9 !important;
    border: 1px solid #3498db !important;
}

/* ============================================================================
   ROW MESSAGE POPUP DARK MODE
   ============================================================================ */

body.dark-mode .row-message-popup {
    background: rgba(44, 62, 80, 0.98) !important;
    border: 1px solid #7f8c8d !important;
}

body.dark-mode .row-message-header {
    border-bottom: 1px solid #7f8c8d !important;
}

body.dark-mode .row-title {
    color: #ecf0f1 !important;
}

body.dark-mode .close-row-popup {
    color: #95a5a6 !important;
}

body.dark-mode .close-row-popup:hover {
    background: rgba(236, 240, 241, 0.1) !important;
    color: #ecf0f1 !important;
}

body.dark-mode .row-instruction {
    color: #bdc3c7 !important;
}

body.dark-mode .row-message-text {
    background: rgba(52, 152, 219, 0.2) !important;
    border-left: 4px solid #3498db !important;
    color: #ecf0f1 !important;
}

/* ============================================================================
   SCROLLBARS DARK MODE
   ============================================================================ */

body.dark-mode .lists-section::-webkit-scrollbar-track {
    background: rgba(44, 62, 80, 0.3) !important;
}

body.dark-mode .lists-section::-webkit-scrollbar-thumb {
    background: rgba(127, 140, 141, 0.5) !important;
}

body.dark-mode .lists-section::-webkit-scrollbar-thumb:hover {
    background: rgba(127, 140, 141, 0.7) !important;
}

/* ============================================================================
   USER INFO ELEMENTS DARK MODE
   ============================================================================ */

body.dark-mode .user-info-panel input {
    background: #34495e !important;
    border: 1px solid #7f8c8d !important;
    color: #ecf0f1 !important;
}

body.dark-mode .user-info-panel input:focus {
    border-color: #3498db !important;
    background: #3c5a78 !important;
    outline: none !important;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.3) !important;
}

body.dark-mode .team-member {
    background-color: rgba(39, 174, 96, 0.2) !important;
    color: #a5d6a7 !important;
}

body.dark-mode .individual-player {
    background-color: rgba(52, 73, 94, 0.8) !important;
    color: #ecf0f1 !important;
}

/* ============================================================================
   COLOR PICKER DARK MODE
   ============================================================================ */

body.dark-mode .color-picker {
    border: 2px solid #7f8c8d !important;
}

body.dark-mode .color-picker:hover {
    border-color: #95a5a6 !important;
}

/* ============================================================================
   ACHIEVEMENT SYSTEM DARK MODE
   ============================================================================ */

body.dark-mode .achievement-notification {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%) !important;
    border: 2px solid #7f8c8d !important;
}

body.dark-mode .achievements-container {
    background: #2c3e50 !important;
    color: #ecf0f1 !important;
}

body.dark-mode .achievement-group-title {
    color: #ecf0f1 !important;
    border-bottom: 2px solid #7f8c8d !important;
}

body.dark-mode .achievement-item {
    background: #34495e !important;
    border: 2px solid #7f8c8d !important;
    color: #ecf0f1 !important;
}

body.dark-mode .achievement-item.unlocked {
    border-color: #27ae60 !important;
    background: linear-gradient(135deg, rgba(39, 174, 96, 0.2) 0%, rgba(46, 204, 113, 0.1) 100%) !important;
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.3) !important;
}

body.dark-mode .achievement-item.locked {
    border-color: #7f8c8d !important;
    background: #2c3e50 !important;
    opacity: 0.6 !important;
}

body.dark-mode .achievement-item .achievement-name {
    color: #ecf0f1 !important;
}

body.dark-mode .achievement-item.locked .achievement-name {
    color: #95a5a6 !important;
}

body.dark-mode .achievement-item .achievement-description {
    color: #bdc3c7 !important;
}

body.dark-mode .achievement-item.locked .achievement-description {
    color: #7f8c8d !important;
}

body.dark-mode .achievement-badge {
    background: #27ae60 !important;
    border: 2px solid #2c3e50 !important;
}

/* ============================================================================
   ANIMATIONS AND EFFECTS DARK MODE
   ============================================================================ */

body.dark-mode .stats-diff-positive {
    color: #a5d6a7 !important;
}

body.dark-mode .stats-diff-negative {
    color: #ef9a9a !important;
}

/* Loading animations */
body.dark-mode .loading-placeholder {
    background-color: #34495e !important;
    color: #7f8c8d !important;
}

@keyframes dark-mode-pulse {
    from { opacity: 0.4; }
    to { opacity: 0.8; }
}

body.dark-mode .loading-placeholder {
    animation: dark-mode-pulse 1.5s ease-in-out infinite alternate !important;
}

/* ============================================================================
   RESPONSIVE DARK MODE ADJUSTMENTS
   ============================================================================ */

@media (max-width: 768px) {
    body.dark-mode .control-group,
    body.dark-mode #inviteFriendsBtn,
    body.dark-mode .stats-panel {
        backdrop-filter: blur(12px) !important;
        background: linear-gradient(135deg, rgba(44, 62, 80, 0.95) 0%, rgba(52, 73, 94, 0.95) 100%) !important;
    }
}

@media (max-width: 480px) {
    body.dark-mode .control-group,
    body.dark-mode #inviteFriendsBtn,
    body.dark-mode .stats-panel {
        backdrop-filter: blur(10px) !important;
        background: linear-gradient(135deg, rgba(44, 62, 80, 0.9) 0%, rgba(52, 73, 94, 0.9) 100%) !important;
    }
}

/* ============================================================================
   ACCESSIBILITY DARK MODE ENHANCEMENTS
   ============================================================================ */

@media (prefers-contrast: high) {
    body.dark-mode {
        background: #000000 !important;
        color: #ffffff !important;
    }
    
    body.dark-mode .list-container {
        border: 2px solid #ffffff !important;
    }
    
    body.dark-mode .btn {
        border: 2px solid #ffffff !important;
    }
}

/* Focus indicators in dark mode */
body.dark-mode .btn:focus,
body.dark-mode .wordlist-toggle:focus,
body.dark-mode input:focus,
body.dark-mode textarea:focus {
    outline: 2px solid #3498db !important;
    outline-offset: 2px !important;
}

/* ============================================================================
   PRINT MODE DARK MODE OVERRIDE
   ============================================================================ */

@media print {
    body.dark-mode {
        background: white !important;
        color: black !important;
    }
    
    body.dark-mode * {
        background: white !important;
        color: black !important;
        border-color: black !important;
    }
}