/**
 * CPSearch Settings - 設定画面スタイル
 * Issue #37: マーケットプレイスソート設定UI
 */

/* 設定ボタン */
.settings-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
}

.settings-button:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    color: #fff;
    transform: translateY(-1px);
}

.settings-button:focus {
    outline: 2px solid rgba(255, 255, 255, 0.6);
    outline-offset: 2px;
}

.settings-button svg {
    transition: transform 0.2s ease;
}

.settings-button:hover svg {
    transform: rotate(90deg);
}

/* モーダル */
.settings-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.settings-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.settings-modal-content {
    position: relative;
    background: #fff;
    border-radius: 12px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* モーダルヘッダー */
.settings-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 24px 0 24px;
    border-bottom: 1px solid #e1e5e9;
    padding-bottom: 16px;
    margin-bottom: 24px;
}

.settings-modal-header h2 {
    margin: 0;
    color: #2c3e50;
    font-size: 24px;
    font-weight: 600;
}

.settings-modal-close {
    background: none;
    border: none;
    color: #7f8c8d;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.settings-modal-close:hover {
    background: #f8f9fa;
    color: #2c3e50;
}

.settings-modal-close:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* モーダルボディ */
.settings-modal-body {
    padding: 0 24px 24px 24px;
    max-height: calc(90vh - 120px);
    overflow-y: auto;
}

.settings-description {
    margin: 0 0 24px 0;
    color: #7f8c8d;
    font-size: 14px;
    line-height: 1.5;
}

.settings-description p {
    margin: 0 0 12px 0;
}

.settings-notice {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    font-size: 13px;
    color: #6c757d;
}

.settings-notice svg {
    flex-shrink: 0;
    margin-top: 2px;
    color: #6c757d;
}

.settings-notice span {
    line-height: 1.4;
}

/* ローディング */
.settings-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 40px 0;
    color: #7f8c8d;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* エラー */
.settings-error {
    text-align: center;
    padding: 40px 0;
    color: #e74c3c;
}

.settings-error p {
    margin: 0 0 16px 0;
}

.retry-button {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s ease;
}

.retry-button:hover {
    background: #c0392b;
}

/* 設定フォーム */
.settings-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.marketplace-settings {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.marketplace-setting {
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 16px;
    background: #f8f9fa;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-label {
    font-weight: 600;
    color: #2c3e50;
    font-size: 16px;
}

.setting-select {
    padding: 10px 12px;
    border: 1px solid #bdc3c7;
    border-radius: 6px;
    background: white;
    font-size: 14px;
    color: #2c3e50;
    transition: border-color 0.2s ease;
}

.setting-select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.setting-help {
    font-size: 12px;
    color: #95a5a6;
    font-style: italic;
}

/* アクションボタン */
.settings-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 16px;
    border-top: 1px solid #e1e5e9;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 120px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background: #ecf0f1;
    color: #2c3e50;
    border: 1px solid #bdc3c7;
}

.btn-secondary:hover:not(:disabled) {
    background: #d5dbdb;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2980b9;
}

.btn:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* トースト通知 */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 6px;
    color: white;
    font-size: 14px;
    z-index: 1100;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    max-width: 300px;
    word-wrap: break-word;
}

.toast.show {
    transform: translateX(0);
}

.toast-success {
    background: #27ae60;
}

.toast-error {
    background: #e74c3c;
}

.toast-info {
    background: #3498db;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .settings-modal {
        padding: 10px;
    }
    
    .settings-modal-content {
        max-width: 100%;
        max-height: 95vh;
    }
    
    .settings-modal-header {
        padding: 16px 16px 0 16px;
    }
    
    .settings-modal-body {
        padding: 0 16px 16px 16px;
    }
    
    .settings-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    .settings-button {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .settings-button span {
        display: none;
    }
}

/* ダークモード対応 */
@media (prefers-color-scheme: dark) {
    .settings-modal-content {
        background: #2c3e50;
        color: #ecf0f1;
    }
    
    .settings-modal-header h2 {
        color: #ecf0f1;
    }
    
    .settings-modal-header {
        border-bottom-color: #34495e;
    }
    
    .marketplace-setting {
        background: #34495e;
        border-color: #34495e;
    }
    
    .setting-label {
        color: #ecf0f1;
    }
    
    .setting-select {
        background: #34495e;
        border-color: #7f8c8d;
        color: #ecf0f1;
    }
    
    .settings-actions {
        border-top-color: #34495e;
    }
}

/* アクセシビリティ */
@media (prefers-reduced-motion: reduce) {
    .settings-modal-content,
    .toast,
    .settings-button svg,
    .loading-spinner {
        animation: none;
        transition: none;
    }
}

/* 高コントラスト対応 */
@media (prefers-contrast: high) {
    .settings-button {
        border: 2px solid #000;
    }
    
    .settings-modal-content {
        border: 2px solid #000;
    }
    
    .setting-select:focus {
        outline: 3px solid #000;
    }
}