/* リセット＆基本設定 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Yu Gothic', 'Meiryo', sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

/* ヘッダー */
.app-header {
    background: linear-gradient(135deg, #0f3460 0%, #16213e 100%);
    color: white;
    padding: 0.8rem 1.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.profile-icon {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, #e94560 0%, #d63447 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 3px 10px rgba(233, 69, 96, 0.4);
}

.profile-name {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.status-online {
    color: #27ae60;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
}

.status-online::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #27ae60;
    border-radius: 50%;
    display: inline-block;
    margin-right: 0.5rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.btn-admin {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.5rem 0.9rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.btn-admin:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

/* メインコンテンツ */
.main-content {
    max-width: 1200px;
    margin: 1.5rem auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* タブナビゲーション */
.tab-nav {
    display: flex;
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
}

.tab-btn {
    flex: 1;
    padding: 0.75rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: #6c757d;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.tab-btn:hover {
    background: rgba(233, 69, 96, 0.05);
}

.tab-btn.active {
    color: #e94560;
    background: white;
    border-bottom: 3px solid #e94560;
}

/* チャット画面 */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 800px;
}

.messages-area {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    background: linear-gradient(135deg, #e8f4f8 0%, #f0f8ff 100%);
}

.message-wrapper {
    margin-bottom: 1.2rem;
    animation: fadeIn 0.5s ease;
}

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

.message-received {
    display: flex;
    justify-content: flex-start;
}

.message-bubble {
    max-width: 70%;
    padding: 0.9rem 1.1rem;
    background: white;
    border-radius: 16px 16px 16px 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    font-size: 0.95rem;
    white-space: pre-line;
    line-height: 1.6;
    position: relative;
}

.message-bubble::before {
    content: '';
    position: absolute;
    left: -8px;
    bottom: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 15px 15px;
    border-color: transparent transparent white transparent;
}

/* タイプ確定表示 */
.type-result {
    text-align: center;
    padding: 1.5rem;
    animation: scaleIn 0.5s ease;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.type-badge {
    display: inline-block;
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    font-size: 1.3rem;
    font-weight: bold;
    color: white;
    margin-bottom: 0.8rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.type-A { background: linear-gradient(135deg, #e74c3c, #c0392b); }
.type-B { background: linear-gradient(135deg, #27ae60, #229954); }
.type-C { background: linear-gradient(135deg, #f39c12, #d68910); }
.type-D { background: linear-gradient(135deg, #95a5a6, #7f8c8d); }

.type-description {
    font-size: 0.9rem;
    color: #555;
    margin-top: 0.8rem;
}

/* 選択肢エリア */
.choices-area {
    padding: 0.5rem 0.8rem;
    background: white;
    border-top: 1px solid #e9ecef;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.choice-btn {
    width: calc(50% - 0.2rem);
    padding: 0.4rem 0.6rem;
    margin-bottom: 0;
    background: linear-gradient(135deg, #f0f8ff 0%, #e6f3ff 100%);
    border: 1px solid #b3d9ff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    text-align: left;
    transition: all 0.3s ease;
    color: #333;
    font-weight: 500;
    line-height: 1.3;
}

.choice-btn:hover {
    background: linear-gradient(135deg, #e94560 0%, #d63447 100%);
    border-color: #e94560;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(233, 69, 96, 0.3);
}

.choice-btn:last-child {
    margin-bottom: 0;
}

/* アクションボタン */
.action-buttons {
    display: flex;
    gap: 0.6rem;
    padding: 0.6rem 0.8rem;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.btn-primary, .btn-secondary {
    flex: 1;
    padding: 0.5rem 0.8rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.btn-primary {
    background: linear-gradient(135deg, #e94560 0%, #d63447 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(233, 69, 96, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(233, 69, 96, 0.4);
}

.btn-secondary {
    background: white;
    color: #333;
    border: 2px solid #dee2e6;
}

.btn-secondary:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
}

/* 統計画面 */
.stats-container {
    padding: 1.5rem;
    max-height: 800px;
    overflow-y: auto;
}

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

.stats-header h2 {
    font-size: 1.5rem;
    color: #333;
}

.btn-danger-small {
    padding: 0.45rem 0.9rem;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.btn-danger-small:hover {
    background: #c0392b;
    transform: translateY(-2px);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.2rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: white;
    padding: 1.2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.stat-card h3 {
    font-size: 1rem;
    color: #555;
    margin-bottom: 0.8rem;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: #e94560;
    text-align: center;
    padding: 0.8rem 0;
}

.chart-card canvas {
    max-height: 220px;
}

/* 履歴テーブル */
.history-section {
    margin-top: 1.5rem;
}

.history-section h3 {
    font-size: 1.1rem;
    color: #333;
    margin-bottom: 0.8rem;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    font-size: 0.9rem;
}

.history-table thead {
    background: linear-gradient(135deg, #0f3460 0%, #16213e 100%);
    color: white;
}

.history-table th {
    padding: 0.8rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
}

.history-table td {
    padding: 0.8rem;
    border-bottom: 1px solid #e9ecef;
}

.history-table tbody tr:hover {
    background: #f8f9fa;
}

.type-badge-small {
    display: inline-block;
    padding: 0.25rem 0.7rem;
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
}

.route-cell {
    font-size: 0.8rem;
    color: #666;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.route-numbers {
    font-weight: 600;
    color: #e94560;
    font-size: 0.9rem;
}

/* エクスポートセクション */
.export-section {
    margin-top: 1.5rem;
    text-align: center;
}

/* モーダル */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    animation: slideUp 0.3s ease;
}

.modal-large {
    max-width: 900px;
    max-height: 80vh;
    overflow-y: auto;
}

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

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

.modal-content h2 {
    font-size: 1.5rem;
    color: #333;
    margin-bottom: 1.5rem;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
    transition: color 0.3s ease;
}

.btn-close:hover {
    color: #333;
}

.input-field, .textarea-field {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    margin-bottom: 1rem;
    font-family: inherit;
}

.input-field:focus, .textarea-field:focus {
    outline: none;
    border-color: #e94560;
}

.textarea-field {
    resize: vertical;
    min-height: 100px;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* 管理者パネル */
.admin-content {
    margin: 1.5rem 0;
}

.admin-section h3 {
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 1rem;
}

.message-edit-card {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    border: 2px solid #e9ecef;
}

.message-edit-card h4 {
    font-size: 1rem;
    color: #e94560;
    margin-bottom: 1rem;
}

.message-edit-card h5 {
    font-size: 0.9rem;
    color: #666;
    margin: 1rem 0 0.5rem 0;
}

.choices-edit {
    margin-top: 1rem;
}

.choice-edit-item {
    margin-bottom: 0.8rem;
}

.btn-danger {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-danger:hover {
    background: #c0392b;
    transform: translateY(-2px);
}

/* レスポンシブ */
@media (max-width: 768px) {
    .main-content {
        margin: 1rem;
        border-radius: 16px;
    }

    .chat-container {
        height: 500px;
    }

    .messages-area {
        padding: 1rem;
    }

    .message-bubble {
        max-width: 90%;
    }

    .choices-area {
        flex-direction: column;
    }

    .choice-btn {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .history-table {
        font-size: 0.85rem;
    }

    .history-table th,
    .history-table td {
        padding: 0.6rem;
    }

    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }

    .profile-name {
        font-size: 1.2rem;
    }

    .stat-value {
        font-size: 2.5rem;
    }
}

/* スクロールバーのスタイル */
.messages-area::-webkit-scrollbar,
.stats-container::-webkit-scrollbar,
.modal-large::-webkit-scrollbar {
    width: 8px;
}

.messages-area::-webkit-scrollbar-track,
.stats-container::-webkit-scrollbar-track,
.modal-large::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.messages-area::-webkit-scrollbar-thumb,
.stats-container::-webkit-scrollbar-thumb,
.modal-large::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 10px;
}

.messages-area::-webkit-scrollbar-thumb:hover,
.stats-container::-webkit-scrollbar-thumb:hover,
.modal-large::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}
