/* リセット & ベーススタイル */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

/* 認証・読み込み画面 */
.full-screen-center {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
    width: 100%;
    color: white;
    text-align: center;
}

.login-card {
    max-width: 400px;
    width: 90%;
    text-align: center;
    color: #333;
}

.login-card h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: #667eea;
}

.login-card h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.login-card p {
    margin-bottom: 2rem;
    color: #666;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.8rem;
}

/* ヘッダー */
header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* カード */
.card {
    background: white;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.card h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.8rem;
}

.card h3 {
    color: #555;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

/* フォーム */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-group textarea {
    resize: vertical;
}

/* ボタン */
.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-block;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

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

.btn-secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    margin: 5px;
}

.btn-secondary:hover {
    background: #667eea;
    color: white;
}

/* プログレス表示 */
.progress-info {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
}

.time-display {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: #333;
}

#elapsed-time {
    color: #667eea;
    font-weight: bold;
    font-size: 1.5rem;
}

.status-display {
    margin-bottom: 20px;
}

.status-stages {
    margin-top: 15px;
}

.status-stage {
    padding: 12px 16px;
    margin-bottom: 10px;
    border-radius: 8px;
    background: white;
    border: 2px solid #e0e0e0;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s;
}

.status-stage.active {
    background: #fff3cd;
    border-color: #ffc107;
    animation: pulse 1.5s infinite;
}

.status-stage.completed {
    background: #d4edda;
    border-color: #28a745;
}

.status-stage .status-icon {
    font-size: 1.3rem;
}

.status-stage.active .status-icon {
    animation: spin 2s linear infinite;
}

.status-stage.completed .status-icon::before {
    content: "✅";
}

.status-text {
    font-weight: 500;
    color: #333;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.run-id-display {
    margin-top: 20px;
    padding: 12px;
    background: white;
    border-radius: 8px;
}

.run-id-display code {
    background: #f1f3f5;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: "Courier New", monospace;
    color: #667eea;
}

/* ダウンロードオプション */
.download-options {
    margin-bottom: 30px;
}

.download-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* 分析内容 */
.analysis-content {
    margin-top: 30px;
}

.content-box {
    background: #f8f9fa;
    background-color: #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    max-height: 600px;
    overflow-y: auto;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.6;
}

.content-box h1, .report-content h1,
.content-box h2, .report-content h2,
.content-box h3, .report-content h3 {
    margin-top: 8px;
    margin-bottom: 2px;
    color: #333;
}

.content-box h1, .report-content h1 {
    font-size: 1.8rem;
}

.content-box h2, .report-content h2 {
    font-size: 1.5rem;
}

.content-box h3, .report-content h3 {
    font-size: 1.3rem;
}

.content-box p, .report-content p {
    text-indent: 1em;
    margin-top: 0;
    margin-bottom: 1em;
}

.content-box ul, .report-content ul,
.content-box ol, .report-content ol {
    margin-top: 0;
    margin-left: 2em;
    margin-bottom: 1em;
}

.content-box li, .report-content li {
    margin-bottom: 0.5em;
}

.content-box code, .report-content code {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: "Courier New", monospace;
}

.content-box pre, .report-content pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 8px;
}

.content-box pre code, .report-content pre code {
    background: transparent;
    color: inherit;
}

.content-box table, .report-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1em;
}

.content-box th, .report-content th,
.content-box td, .report-content td {
    border: 1px solid #000;
    padding: 8px;
    text-align: left;
}

.content-box th, .report-content th {
    background-color: #e2e8f0;
    font-weight: bold;
}

/* フッター */
footer {
    text-align: center;
    color: white;
    margin-top: 30px;
    opacity: 0.8;
}

/* 拡張スタイル: マルチフォーマット入力 */

.input-type-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.radio-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px 10px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    font-size: 0.9rem;
    background: #fcfcfc;
}

.radio-option:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.radio-option input[type="radio"] {
    margin-bottom: 10px;
}

.radio-option:has(input[type="radio"]:checked) {
    border-color: #667eea;
    background: #f0f4ff;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

/* File Upload Widget */
.file-upload-widget {
    margin-top: 5px;
}

.drop-zone {
    border: 3px dashed #cbd5e1;
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    background: #f8fafc;
    transition: all 0.3s ease;
    cursor: pointer;
}

.drop-zone:hover, .drop-zone.drag-over {
    border-color: #667eea;
    background: #f0f4ff;
}

.drop-zone p {
    color: #64748b;
    margin-bottom: 15px;
    font-weight: 500;
}

#file-info {
    margin-top: 15px;
    padding: 12px 18px;
    background: #e6fffa;
    border: 1px solid #38b2ac;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-name {
    font-weight: bold;
    color: #234e52;
}

.file-size {
    color: #2c7a7b;
    font-size: 0.85rem;
    margin-left: 10px;
}

.remove-file {
    background: none;
    border: none;
    color: #e53e3e;
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
}

.remove-file:hover {
    color: #c53030;
}

.encoding-selector select {
    padding: 8px 12px;
    border-radius: 6px;
    border: 2px solid #e2e8f0;
    margin-left: 10px;
    background: white;
}

/* Info Boxes */
.info-box {
    margin-top: 15px;
    padding: 15px;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.info-box.warning {
    background: #fffaf0;
    border-left: 4px solid #ed8936;
    color: #7b341e;
}

.info-box ul {
    margin-top: 8px;
    margin-left: 20px;
}

/* Data Preview */
#data-preview-container {
    background: #f7fafc;
    border: 2px solid #edf2f7;
}

#data-preview {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    background: #1a202c;
    color: #f7fafc;
    padding: 15px;
    border-radius: 8px;
    margin-top: 10px;
}

@media (max-width: 768px) {
    .input-type-selector {
        grid-template-columns: 1fr 1fr;
    }
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    .card {
        padding: 20px;
    }

    .download-buttons {
        flex-direction: column;
    }

    .btn-secondary {
        width: 100%;
        margin: 5px 0;
    }
}

/* === CopilotKit 要件定義AIモーダル === */

/* モーダルオーバーレイ */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* モーダルコンテンツ */
.modal-content {
    background-color: white;
    border-radius: 16px;
    width: 90%;
    max-width: 650px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* モーダルヘッダー */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 16px 16px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
}

.close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* モーダルボディ */
.modal-body {
    padding: 20px 25px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 1;
    overflow-y: auto; /* コンテンツが溢れた場合はスクロールさせる */
    min-height: 0; /* Flexboxの縮小を有効にするため */
}

/* チャット履歴エリア */
.chat-history {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 15px;
    background-color: #f7fafc;
    min-height: 150px; /* 入力欄が大きいので最小高さを抑制 */
}

.chat-history::-webkit-scrollbar {
    width: 8px;
}

.chat-history::-webkit-scrollbar-track {
    background: #edf2f7;
    border-radius: 10px;
}

.chat-history::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 10px;
}

.chat-history::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* チャットメッセージ */
.chat-message {
    margin-bottom: 14px;
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 85%;
    word-wrap: break-word;
    white-space: pre-wrap; /* 改行を保持 */
    animation: messageSlide 0.2s ease-out;
    line-height: 1.5;
    font-size: 0.7rem; /* 文字サイズを少し小さく */
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.user {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-left: auto;
    text-align: right;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant {
    background-color: #edf2f7;
    color: #2d3748;
    margin-right: auto;
    border-bottom-left-radius: 4px;
    border: 1px solid #e2e8f0;
}

.chat-message.system {
    background-color: #fef5e7;
    color: #975a16;
    margin: 0 auto;
    text-align: center;
    font-size: 0.9rem;
    border: 1px solid #f9e79f;
}

.chat-history .placeholder {
    text-align: center;
    color: #a0aec0;
    font-style: italic;
    padding: 80px 20px;
    font-size: 1.05rem;
}

/* 入力エリア */
.chat-input-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 5px;
}

.chat-input-area textarea {
    resize: none;
    padding: 12px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

.chat-input-area textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.input-actions {
    display: flex;
    gap: 10px;
    width: 100%;
}

.action-btn {
    padding: 10px 16px;
    font-size: 0.95rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    justify-content: center;
    align-items: center;
    display: flex;
}

#send-message-btn {
    flex: 4;
}

#start-analysis-chat-btn {
    flex: 4;
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
}

#reset-requirements-btn {
    flex: 1;
    background: #e53e3e;
    min-width: 50px;
}

.chat-input-area button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 成功バナー */
.success-banner {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    padding: 14px 20px;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    margin-top: 10px;
    animation: slideIn 0.3s ease-out;
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.3);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* クリアボタン */
.clear-history-btn {
    background-color: #f56565;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.clear-history-btn:hover {
    background-color: #e53e3e;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .modal-header {
        padding: 15px 20px;
    }
    
    .modal-header h3 {
        font-size: 1.1rem;
    }
    
    .modal-body {
        padding: 15px 20px;
    }
    
    .chat-history {
        min-height: 250px;
        max-height: 350px;
    }
    
    .chat-message {
        max-width: 90%;
        font-size: 0.95rem;
    }
}

/* �v����`�t�H�[�� */
.requirements-form-container {
    margin-top: 15px;
    background: #fff;
    padding: 0;
    border-radius: 8px;
    border: 1px solid #ccc;
    overflow: visible;
}

.requirements-table {
    width: 100%;
    border-collapse: collapse;
}

.requirements-table th, .requirements-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.requirements-table th {
    background-color: #fff;
    font-weight: normal;
    font-size: 0.9rem;
    color: #333;
    text-align: center;
    width: 30%;
    border-right: 1px solid #ddd;
}

.requirements-table td {
    padding: 0;
}

.requirements-table td input {
    width: 100%;
    padding: 10px;
    border: none;
    font-size: 0.95rem;
    outline: none;
}

.requirements-table tr:last-child th,
.requirements-table tr:last-child td {
    border-bottom: none;
}

