/**
 * 🎨 会話フロースタジオ専用スタイル
 * AI支援分岐エディターのUIコンポーネント
 */

/* ======================
   フォント設定
   ====================== */
* {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

body {
    font-size: 14px;
    line-height: 1.5;
    color: #2c3e50;
    font-weight: 400;
}

/* ======================
   メインレイアウト
   ====================== */
.conversation-flow-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 70px);
    background: #f8f9fa;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
}

.flow-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: white;
    border-bottom: 1px solid #e9ecef;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
}

.flow-header h2 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.5rem;
    font-weight: 600;
}

.header-info {
    display: flex;
    gap: 0.5rem;
}

.info-badge {
    background: #e3f2fd;
    color: #1976d2;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
}

.header-controls {
    display: flex;
    gap: 0.75rem;
}

/* ======================
   3パネルレイアウト
   ====================== */
.flow-content {
    display: grid;
    grid-template-columns: 300px 1fr 350px;
    gap: 1rem;
    padding: 1rem;
    height: calc(100vh - 210px);
    overflow: hidden;
    flex: 1;
}

.left-panel, .center-panel, .right-panel {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
    flex-shrink: 0;
}

.panel-header h4 {
    margin: 0;
    font-size: 1.1rem;
    color: #495057;
}

/* ======================
   左パネル: フロー一覧
   ====================== */
.flow-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.flow-item {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.flow-item:hover {
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0,123,255,0.15);
}

.flow-item.selected {
    border-color: #007bff;
    background: #f8f9ff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}

.flow-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.flow-icon {
    font-size: 1.5rem;
}

.flow-info {
    flex: 1;
}

.flow-name {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.25rem;
}

.flow-type {
    font-size: 0.875rem;
    color: #6c757d;
}

.flow-status {
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.flow-status.draft {
    background: #fff3cd;
    color: #856404;
}

.flow-status.active {
    background: #d1ecf1;
    color: #0c5460;
}

.flow-stats {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.5rem;
    padding: 0.5rem 0;
    border-top: 1px solid #f1f3f4;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.stat-label {
    font-size: 0.75rem;
    color: #6c757d;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: #2c3e50;
}

.flow-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* ======================
   中央パネル: エディター
   ====================== */
.conversation-editor {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.no-flow-selected {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #6c757d;
    text-align: center;
}

.phases-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.phase-section {
    border: 1px solid #e9ecef;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin-bottom: 1rem;
}

.phase-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.phase-header h5 {
    margin: 0;
    color: #2c3e50;
    font-size: 1rem;
    font-weight: 600;
}

.phase-meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin: 0 1rem;
}

.phase-meta span {
    font-size: 0.875rem;
    color: #6c757d;
}

.conversations-container {
    padding: 1rem;
}

.no-conversations {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
}

.conversation-item {
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.conversation-item:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

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

.conversation-header h6 {
    margin: 0;
    color: #495057;
}

.conversation-controls {
    display: flex;
    gap: 0.5rem;
}

.scammer-message {
    margin-bottom: 1rem;
    padding: 1rem;
    background: #fff;
    border-radius: 8px;
    border-left: 4px solid #dc3545;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.message-text {
    color: #2c3e50;
    font-style: normal;
    font-size: 0.95rem;
    line-height: 1.5;
    font-weight: 400;
}

.user-responses {
    margin-bottom: 0.75rem;
}

.response-list {
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.response-item {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    border-left: 3px solid #28a745;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
}

.response-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.response-item.incorrect {
    border-left-color: #ffc107;
    background: #fffbf0;
}

.response-item.correct {
    border-left-color: #28a745;
    background: #f8fff4;
}

.response-text {
    display: block;
    margin-bottom: 0.25rem;
    color: #2c3e50;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
}

.response-meta {
    font-size: 0.8rem;
    color: #6c757d;
}

/* ======================
   右パネル: プレビュー
   ====================== */
.preview-panel {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.preview-content h5 {
    margin-top: 0;
    color: #2c3e50;
}

.flow-statistics {
    margin: 1.5rem 0;
}

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.stat-card {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 6px;
    text-align: center;
    border: 1px solid #e9ecef;
}

.stat-number {
    font-size: 1.5rem;
    font-weight: 600;
    color: #007bff;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.875rem;
    color: #6c757d;
}

.phase-overview {
    margin-top: 1.5rem;
}

.phase-overview h6 {
    margin-bottom: 1rem;
    color: #495057;
}

.phase-item {
    background: #f8f9fa;
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    border-left: 4px solid #007bff;
}

.phase-name {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.25rem;
}

.phase-goal {
    font-size: 0.875rem;
    color: #6c757d;
    margin-bottom: 0.25rem;
}

.phase-conversations {
    font-size: 0.75rem;
    color: #007bff;
    font-weight: 500;
}

/* ======================
   モーダルスタイル
   ====================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e9ecef;
}

.modal-header h4 {
    margin: 0;
    color: #2c3e50;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1rem 1.5rem;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #495057;
    font-weight: 500;
}

.form-control, .form-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.875rem;
}

.form-control:focus, .form-select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.25);
}

.settings-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
}

/* ======================
   AI生成モーダル
   ====================== */
.progress-container {
    margin-bottom: 1.5rem;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: #e9ecef;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 1rem;
    border: 1px solid #dee2e6;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #28a745, #20c997);
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
    animation: progress-glow 2s ease-in-out infinite alternate;
}

@keyframes progress-glow {
    from {
        box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
    }
    to {
        box-shadow: 0 2px 8px rgba(40, 167, 69, 0.6);
    }
}

.generation-status {
    text-align: center;
    color: #495057;
    font-weight: 500;
    margin-bottom: 1rem;
}

.generation-log {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 1rem;
    max-height: 200px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
}

.log-entry {
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    border-radius: 4px;
    background: #f8f9fa;
    border-left: 3px solid #007bff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
}

.log-entry.log-success {
    background: #d4edda;
    border-left-color: #28a745;
    color: #155724;
}

.log-entry.log-error {
    background: #f8d7da;
    border-left-color: #dc3545;
    color: #721c24;
}

.log-entry.log-warning {
    background: #fff3cd;
    border-left-color: #ffc107;
    color: #856404;
}

.log-entry.log-status {
    background: #e2e3e5;
    border-left-color: #6c757d;
    color: #495057;
}

.log-time {
    font-weight: bold;
    color: #6c757d;
    font-size: 0.7rem;
    min-width: 60px;
}

.log-icon {
    font-size: 1rem;
}

.log-message {
    flex: 1;
}

.log-entry:last-child {
    margin-bottom: 0;
}

/* ======================
   ケース選択モーダル
   ====================== */
.case-selection-modal {
    max-width: 800px;
    width: 95%;
    max-height: 90vh;
}

.modal-intro {
    text-align: center;
    margin-bottom: 1.5rem;
    color: #495057;
    font-size: 0.95rem;
    line-height: 1.5;
}

.case-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 60vh;
    overflow-y: auto;
    padding: 0.5rem;
}

.case-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1.5rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.case-item:hover {
    border-color: #007bff;
    box-shadow: 0 4px 12px rgba(0,123,255,0.15);
    transform: translateY(-2px);
}

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

.case-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
    flex: 1;
}

.case-difficulty {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.case-difficulty.beginner {
    background: #d4edda;
    color: #155724;
}

.case-difficulty.intermediate {
    background: #fff3cd;
    color: #856404;
}

.case-difficulty.advanced {
    background: #f8d7da;
    color: #721c24;
}

.case-category {
    font-size: 0.875rem;
    color: #007bff;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.case-description {
    color: #495057;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.case-objectives,
.case-warnings {
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    border-radius: 4px;
}

.case-objectives {
    background: #e3f2fd;
    border-left: 4px solid #2196f3;
}

.case-warnings {
    background: #fff3e0;
    border-left: 4px solid #ff9800;
}

.case-objectives strong,
.case-warnings strong {
    color: #2c3e50;
}

.select-case-btn {
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.75rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.select-case-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,123,255,0.3);
}

/* ======================
   自動消去通知システム
   ====================== */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    min-width: 300px;
    max-width: 500px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    z-index: 2000;
    animation: slideInRight 0.3s ease-out;
    border-left: 4px solid #007bff;
}

.notification-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    gap: 1rem;
}

.notification-message {
    flex: 1;
    font-size: 0.95rem;
    line-height: 1.4;
    color: #2c3e50;
}

.notification-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.notification-close:hover {
    background: #f1f3f4;
    color: #495057;
}

.notification-success {
    border-left-color: #28a745;
}

.notification-success .notification-message {
    color: #155724;
}

.notification-error {
    border-left-color: #dc3545;
}

.notification-error .notification-message {
    color: #721c24;
}

.notification-info {
    border-left-color: #17a2b8;
}

.notification-info .notification-message {
    color: #0c5460;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ======================
   ボタンスタイル
   ====================== */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
}

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

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #0056b3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

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

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #1e7e34;
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-info:hover:not(:disabled) {
    background: #117a8b;
}

.btn-warning {
    background: #ffc107;
    color: #212529;
}

.btn-warning:hover:not(:disabled) {
    background: #e0a800;
}

.btn-outline-primary {
    background: transparent;
    color: #007bff;
    border: 1px solid #007bff;
}

.btn-outline-primary:hover:not(:disabled) {
    background: #007bff;
    color: white;
}

.btn-outline-secondary {
    background: transparent;
    color: #6c757d;
    border: 1px solid #6c757d;
}

.btn-outline-secondary:hover:not(:disabled) {
    background: #6c757d;
    color: white;
}

.btn-outline-success {
    background: transparent;
    color: #28a745;
    border: 1px solid #28a745;
}

.btn-outline-success:hover:not(:disabled) {
    background: #28a745;
    color: white;
}

.btn-outline-danger {
    background: transparent;
    color: #dc3545;
    border: 1px solid #dc3545;
}

.btn-outline-danger:hover:not(:disabled) {
    background: #dc3545;
    color: white;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
}

.btn-xs {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* ======================
   入力サジェスト
   ====================== */
.suggestion-box {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 200px;
    overflow-y: auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.suggestion-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f8f9fa;
    font-size: 0.9rem;
    color: #2c3e50;
    transition: all 0.2s ease;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item.selected {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
}

.suggestion-item.selected {
    font-weight: 500;
}

/* 入力フィールドのフォーカス時のスタイル改善 */
input[data-suggestion-enabled]:focus,
textarea[data-suggestion-enabled]:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,0.25);
    outline: none;
}

/* ======================
   空状態
   ====================== */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
}

.empty-state p {
    margin-bottom: 1rem;
}

.error-state {
    text-align: center;
    padding: 2rem;
    color: #dc3545;
}

.error-state h3 {
    color: #dc3545;
    margin-bottom: 1rem;
}

.error-state details {
    margin: 1rem 0;
    text-align: left;
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
}

.error-state pre {
    font-size: 0.875rem;
    color: #495057;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
}

/* ======================
   レスポンシブデザイン
   ====================== */
@media (max-width: 1200px) {
    .flow-content {
        grid-template-columns: 280px 1fr 300px;
    }
}

@media (max-width: 992px) {
    .flow-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
    }
    
    .left-panel, .right-panel {
        max-height: 300px;
    }
}

@media (max-width: 768px) {
    .flow-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .header-controls {
        justify-content: center;
    }
    
    .flow-content {
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .panel-header {
        padding: 0.75rem;
    }
    
    .conversation-editor,
    .preview-panel {
        padding: 0.75rem;
    }
}
