﻿/**
 * モーダル・UIコンポーネント - 専用スタイル
 * 
 * 【適用範囲】
 * - 置き換え提案モーダル
 * - トーストメッセージ
 * - 分析中インジケーター
 * - プログレスバー
 */

/* === 放浪娘カラースキーム === */
:root {
  --color-bg: #FFFFFF;
  --color-bg-card: #F9FAFB;
  --color-border: #E5E7EB;
  --color-text-main: #333B4F;
  --color-text-sub: #374151;
  --color-accent-red: #E74C3C;
  --color-accent-blue: #3498DB;
  --color-accent-green: #2ECC71;
  --color-accent-purple: #9B59B6;
  --color-accent-orange: #F39C12;
  --color-gray: #6B7280;
  --color-gray-light: #F3F4F6;
  --color-table-stripe: #F5F5F5;
}

/* === モーダル基盤 === */
.modal, .ai-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.5);
    transition: opacity 0.3s;
}

.modal.modal-active, .ai-modal.modal-active, .modal.show, .ai-modal.show {
    display: flex;
    opacity: 1;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.modal-content {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    margin: auto;
    z-index: 10000;
    background: var(--color-bg-card);
    color: var(--color-text-main);
    border-radius: 8px;
    box-shadow: 0 2px 8px 0 rgba(51,59,79,0.08);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

/* === 置き換え提案モーダル === */
.replacement-modal .modal-content {
    padding: 0;
}

.modal-header {
    padding: 16px 20px;
    background: var(--color-bg);
    color: var(--color-text-main);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--color-accent-red);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    color: #374151;
    background: #f3f4f6;
}

.modal-body {
    padding: 20px;
}

/* === 置き換えサマリー === */
.replacement-summary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 20px;
    padding: 16px;
    background: #f9fafb;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.current-state,
.improved-state {
    text-align: center;
    min-width: 80px;
}

.current-state .label,
.improved-state .label {
    display: block;
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 4px;
    font-weight: 500;
}

.current-state .value {
    font-size: 18px;
    font-weight: 700;
    color: #ef4444;
}

.improved-state .value {
    font-size: 18px;
    font-weight: 700;
    color: #10b981;
}

.replacement-summary .arrow {
    font-size: 16px;
    color: #6b7280;
    font-weight: bold;
}

/* === 置き換え詳細 === */
.replacement-detail {
    margin-bottom: 16px;
}

.replacement-text {
    font-size: 16px;
    text-align: center;
    margin-bottom: 8px;
    padding: 12px;
    background: #f8fafc;
    border-radius: 6px;
}

.replacement-text .original {
    color: #ef4444;
    text-decoration: line-through;
    font-weight: 500;
}

.replacement-text .suggested,
.replacement-text .addition {
    color: #10b981;
    font-weight: 600;
}

.replacement-text .arrow {
    margin: 0 8px;
    color: #6b7280;
}

.reason-text {
    text-align: center;
    color: #6b7280;
    font-size: 14px;
    margin-bottom: 12px;
    font-style: italic;
}

/* === 追加効果 === */
.additional-benefits {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 8px;
}

.benefit-tag {
    background: #dbeafe;
    color: #1e40af;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    border: 1px solid #93c5fd;
}

/* === 信頼度インジケーター === */
.confidence-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: #f0fdf4;
    border-radius: 6px;
    margin-bottom: 16px;
    border: 1px solid #bbf7d0;
}

.confidence-label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
}

.confidence-value {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    min-width: 40px;
}

.confidence-bar {
    flex: 1;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    background: linear-gradient(90deg, #fbbf24, #10b981);
    transition: width 0.3s ease;
}

/* === モーダルフッター === */
.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: #f9fafb;
}

.btn-cancel,
.btn-apply {
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-weight: 500;
}

.btn-cancel {
    background: var(--color-accent-red);
    color: #fff;
}

.btn-cancel:hover {
    background: #e5e7eb;
    color: #374151;
}

.btn-apply {
    background: var(--color-accent-green);
    color: #fff;
}

.btn-apply:hover {
    background: #2563eb;
}

.btn-apply:active {
    background: #1d4ed8;
}

/* === 分析中インジケーター === */
.analyzing-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: #6b7280;
}

.analyzing-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.analyzing-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.analyzing-text {
    font-size: 14px;
    font-weight: 500;
}

/* === プログレスバー === */
.ai-progress-bar {
    margin: 8px 0;
}

.progress-label {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 4px;
    font-weight: 500;
}

.progress-track {
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 4px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #10b981);
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 11px;
    color: #6b7280;
    text-align: right;
    font-weight: 500;
}

/* === トーストメッセージ === */
.ai-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    max-width: 320px;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.ai-toast.toast-visible {
    opacity: 1;
    transform: translateX(0);
}

.ai-toast-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

.ai-toast-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.ai-toast-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fbbf24;
}

.ai-toast-error {
    background: #fecaca;
    color: #991b1b;
    border: 1px solid #f87171;
}

/* === 統計サマリー === */
.stats-summary {
    padding: 12px;
    background: #f9fafb;
    border-radius: 6px;
    margin: 8px 0;
    border: 1px solid #e5e7eb;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 12px;
}

.stats-item {
    text-align: center;
}

.stats-value {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
}

.stats-label {
    font-size: 11px;
    color: #6b7280;
    margin-top: 2px;
    font-weight: 500;
}

/* === 結果アニメーション === */
.result-appear {
    animation: gentle-fade-in 0.4s ease-out;
}

@keyframes gentle-fade-in {
    from { 
        opacity: 0; 
        transform: translateY(4px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

/* === レスポンシブ対応 === */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 10px;
        max-height: 90vh;
    }
    
    .replacement-summary {
        flex-direction: column;
        gap: 8px;
    }
    
    .replacement-summary .arrow {
        transform: rotate(90deg);
    }
    
    .ai-toast {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .modal-footer {
        flex-direction: column-reverse;
    }
    
    .btn-cancel,
    .btn-apply {
        width: 100%;
    }
    
    .modal-header {
        padding: 12px 16px;
    }
    
    .modal-body {
        padding: 16px;
    }
}

/* === アクセシビリティ対応 === */
.modal-content:focus-within {
    outline: none;
}

.ai-modal[aria-hidden="true"] {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .ai-modal,
    .ai-toast,
    .result-appear,
    .analyzing-spinner,
    .progress-fill,
    .confidence-fill {
        animation: none;
        transition: none;
    }
}

/* === 高コントラスト対応 === */
@media (prefers-contrast: high), (forced-colors: active) {
    .modal-content {
        border: 2px solid #000;
    }
    
    .btn-cancel,
    .btn-apply {
        border: 2px solid currentColor;
    }
    
    .confidence-bar,
    .progress-track {
        border: 1px solid #000;
    }
}

/* === 印刷対応 === */
@media print {
    .ai-modal,
    .ai-toast {
        display: none;
    }
}