/**
 * Game Mode Switcher & Settings Gear Styles
 * For Single Player Reversi/XOT mode switching
 */

/* ============================================
   Game Header Layout - Desktop (3-column grid for true center alignment)
   ============================================ */

.game-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
    /* Inherit margin-bottom from style.css, don't add extra spacing */
}

.game-header h2 {
    margin: 0;
    white-space: nowrap;
    justify-self: start;
}

/* Mode switcher - always centered */
.mode-switcher {
    justify-self: center;
}

/* Settings gear - always right aligned */
.settings-gear-container {
    justify-self: end;
}

/* ============================================
   Mode Switcher - Clean Traditional Design (White bg)
   ============================================ */

.mode-switcher {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.mode-switcher-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: linear-gradient(135deg, #ffffff 0%, #f7f7f7 100%);
    border: 2px solid #d1d5db;
    border-radius: 8px;
    color: #1f2937;
    font-size: 1rem;
    font-weight: 600;
    padding: 0.5rem 2.5rem 0.5rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 120px;
    text-align: center;
    letter-spacing: 0.5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.mode-switcher-select:hover {
    border-color: #1b8050;
    background: linear-gradient(135deg, #ffffff 0%, #f0f0f0 100%);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.mode-switcher-select:focus {
    outline: none;
    border-color: #1b8050;
    box-shadow: 0 0 0 3px rgba(27, 128, 80, 0.3);
}

/* Custom dropdown arrow */
.mode-switcher::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #6b7280;
    pointer-events: none;
    transition: border-color 0.2s ease;
}

.mode-switcher:hover::after {
    border-top-color: #1b8050;
}

/* Mode option styling */
.mode-switcher-select option {
    background: #ffffff;
    color: #1f2937;
    padding: 0.5rem;
}

/* XOT mode - same style as Reversi mode (no special indicator) */

/* ============================================
   Settings Gear Icon - Traditional Design (White bg)
   ============================================ */

.settings-gear-container {
    position: relative;
}

.settings-gear-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #ffffff 0%, #f7f7f7 100%);
    border: 2px solid #d1d5db;
    border-radius: 8px;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.settings-gear-btn:hover {
    background: linear-gradient(135deg, #ffffff 0%, #f0f0f0 100%);
    border-color: #1b8050;
    color: #1b8050;
    transform: rotate(45deg);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.settings-gear-btn:focus {
    outline: none;
    border-color: #1b8050;
    box-shadow: 0 0 0 3px rgba(27, 128, 80, 0.3);
}

.settings-gear-btn i {
    font-size: 1.1rem;
    transition: transform 0.3s ease;
}

.settings-gear-btn:hover i {
    transform: rotate(-45deg); /* Counter-rotate to stay upright */
}

/* ============================================
   Settings Dropdown Panel - Traditional Design (White bg)
   ============================================ */

.settings-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: linear-gradient(135deg, #ffffff 0%, #fafafa 100%);
    border: 2px solid #d1d5db;
    border-radius: 10px;
    padding: 1rem;
    min-width: 180px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

.settings-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.settings-dropdown-header {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #6b7280;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.settings-dropdown label {
    display: block;
    font-size: 0.85rem;
    color: #374151;
    margin-bottom: 0.5rem;
}

.settings-dropdown select {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #1f2937;
    font-size: 0.9rem;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.settings-dropdown select:hover {
    border-color: #1b8050;
}

.settings-dropdown select:focus {
    outline: none;
    border-color: #1b8050;
    box-shadow: 0 0 0 2px rgba(27, 128, 80, 0.2);
}

/* Custom arrow for dropdown select */
.difficulty-select-wrapper {
    position: relative;
}

.difficulty-select-wrapper::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid #6b7280;
    pointer-events: none;
}

/* ============================================
   Mobile Responsive - Header Layout
   ============================================ */

@media (max-width: 768px) {
    .game-header {
        /* Switch to flexbox on mobile for compact layout */
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-wrap: nowrap;
        gap: 0.5rem;
    }
    
    .game-header h2 {
        /* Keep original font size, only adjust layout */
        flex-shrink: 0;
        margin-right: auto;
        justify-self: unset;
    }
    
    /* Mode switcher and gear stay together on the right */
    .mode-switcher {
        flex-shrink: 0;
        justify-self: unset;
    }
    
    .settings-gear-container {
        flex-shrink: 0;
        justify-self: unset;
    }
    
    /* Compact mode switcher for mobile */
    .mode-switcher-select {
        font-size: 0.8rem;
        padding: 0.35rem 1.6rem 0.35rem 0.5rem;
        min-width: 80px;
        height: 32px;
    }
    
    .mode-switcher::after {
        right: 8px;
        border-left: 4px solid transparent;
        border-right: 4px solid transparent;
        border-top: 5px solid #a0aec0;
    }
    
    /* Compact gear button for mobile */
    .settings-gear-btn {
        width: 32px;
        height: 32px;
    }
    
    .settings-gear-btn i {
        font-size: 0.9rem;
    }
    
    .settings-dropdown {
        right: 0;
        min-width: 160px;
    }
}

@media (max-width: 480px) {
    .game-header {
        gap: 0.35rem;
    }
    
    .mode-switcher-select {
        font-size: 0.75rem;
        padding: 0.25rem 1.4rem 0.25rem 0.4rem;
        min-width: 65px;
        height: 28px;
        border-radius: 5px;
    }
    
    .mode-switcher::after {
        right: 6px;
        border-left: 3px solid transparent;
        border-right: 3px solid transparent;
        border-top: 4px solid #a0aec0;
    }
    
    .settings-gear-btn {
        width: 28px;
        height: 28px;
        border-radius: 5px;
    }
    
    .settings-gear-btn i {
        font-size: 0.8rem;
    }
}

/* Extra small screens */
@media (max-width: 360px) {
    .game-header {
        gap: 0.25rem;
    }
    
    .mode-switcher-select {
        font-size: 0.7rem;
        padding: 0.2rem 1.2rem 0.2rem 0.3rem;
        min-width: 55px;
        height: 26px;
    }
    
    .settings-gear-btn {
        width: 26px;
        height: 26px;
    }
    
    .settings-gear-btn i {
        font-size: 0.75rem;
    }
}

/* ============================================
   Tablet Styles
   ============================================ */

@media (min-width: 769px) and (max-width: 1024px) {
    .mode-switcher-select {
        font-size: 0.95rem;
        padding: 0.45rem 2.2rem 0.45rem 0.9rem;
        min-width: 110px;
    }
}

/* ============================================
   Dark Mode Adjustments
   ============================================ */

@media (prefers-color-scheme: dark) {
    .mode-switcher-select {
        background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
        border-color: #4a5568;
        color: #fff;
    }
    
    .mode-switcher-select option {
        background: #1a1a2e;
        color: #fff;
    }
    
    .settings-gear-btn {
        background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
        border-color: #4a5568;
        color: #a0aec0;
    }
    
    .settings-gear-btn:hover {
        color: #fff;
    }
    
    .settings-dropdown {
        background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
        border-color: #4a5568;
    }
    
    .settings-dropdown-header {
        color: #a0aec0;
        border-bottom-color: #4a5568;
    }
    
    .settings-dropdown label {
        color: #cbd5e0;
    }
    
    .settings-dropdown select {
        background: #2d3748;
        border-color: #4a5568;
        color: #fff;
    }
}

/* ============================================
   High Contrast Mode
   ============================================ */

@media (prefers-contrast: high) {
    .mode-switcher-select {
        border-width: 3px;
        font-weight: 700;
    }
    
    .settings-gear-btn {
        border-width: 3px;
    }
}

/* ============================================
   Reduced Motion
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .settings-gear-btn:hover {
        transform: none;
    }
    
    .settings-gear-btn:hover i {
        transform: none;
    }
    
    .settings-dropdown {
        transition: opacity 0.1s ease;
        transform: none;
    }
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    .mode-switcher,
    .settings-gear-container {
        display: none;
    }
}

/* ============================================
   Settings Dropdown Content Styles
   ============================================ */

/* Checkbox and setting items in dropdown */
.mute-setting,
.legal-hints-setting {
    padding-top: 0.75rem;
    margin-top: 0.75rem;
    border-top: 1px solid #e5e7eb;
}

/* First setting item after header - NO border/padding/margin */
.settings-dropdown .settings-dropdown-header + .mute-setting,
.settings-dropdown .settings-dropdown-header + .legal-hints-setting,
.settings-dropdown .settings-dropdown-header + div > .mute-setting:first-child,
.settings-dropdown .mute-setting:first-child,
.settings-dropdown .legal-hints-setting:first-child {
    margin-top: 0 !important;
    padding-top: 0 !important;
    border-top: none !important;
}

/* Checkbox 列(Mute 等):需壓過上方 .settings-dropdown label 的 display:block(0,1,1),
   否則勾選框/文字/info 圖示會擠成一團(單人頁曾因此走樣;線上頁靠頁內樣式僥倖蓋回) */
.settings-dropdown label.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0;
    cursor: pointer;
}

/* Checkbox label styling */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: #374151;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #1b8050;
}

.checkbox-text {
    flex-shrink: 0;
}

/* Info icon styling */
.info-icon {
    position: relative;
    color: #9ca3af;
    font-size: 0.85rem;
    cursor: help;
    transition: color 0.2s ease;
}

.info-icon:hover {
    color: #1b8050;
}

/* Info icon tooltip */
.info-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 10px;
    background: #1f2937;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 200;
    pointer-events: none;
}

/* Info icon tooltip arrow */
.info-icon::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 3px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1f2937;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 200;
}

.info-icon:hover::after,
.info-icon:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Dark mode for settings content */
@media (prefers-color-scheme: dark) {
    .mute-setting,
    .legal-hints-setting {
        border-top-color: #4a5568;
    }
    
    .checkbox-label {
        color: #cbd5e0;
    }
    
    .info-icon {
        color: #718096;
    }
}
