/* ローディング画面 */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    transition: opacity 0.5s ease-out;
}

#loading-screen.fade-out {
    opacity: 0;
}

#loading-screen.hidden {
    display: none;
}

.loading-container {
    text-align: center;
    color: white;
    max-width: 400px;
    padding: 40px;
}

.loading-logo h1 {
    font-size: 3rem;
    margin: 0;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    letter-spacing: 3px;
}

.loading-logo p {
    font-size: 1rem;
    margin: 10px 0 30px 0;
    opacity: 0.8;
    letter-spacing: 1px;
}

.loading-spinner {
    margin: 30px 0;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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

.loading-text {
    margin: 20px 0;
}

#loading-message {
    font-size: 1.2rem;
    margin-bottom: 10px;
    font-weight: 500;
}

#loading-progress {
    font-size: 1rem;
    opacity: 0.8;
}

.loading-details {
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#loading-detail-message {
    font-size: 0.9rem;
    opacity: 0.9;
    line-height: 1.4;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #101018;
    color: #fff;
    overflow: hidden;
    font-size: 13px;
}

#canvas-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#control-panel, #info-panel, #log-panel {
    position: absolute;
    background: rgba(0, 0, 0, 0.7);
    padding: 15px;
    border-radius: 8px;
    box-shadow: none;
    cursor: move;
    user-select: none;
    transition: all 0.3s ease;
    border: 1px solid #fff;
}

#control-panel {
    top: 10px;
    right: 10px;
    max-width: 300px;
    min-width: 280px;
}

/* APIアクセス回数表示 */
.api-call-counter {
    background: rgba(76, 175, 80, 0.2);
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 10px;
    text-align: center;
    font-weight: bold;
    border: 1px solid #4CAF50;
}

/* タブナビゲーション */
.tab-navigation {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    margin-bottom: 10px;
}

.tab-button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 6px 10px;
    font-size: 11px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    flex: 1;
    min-width: 0;
}

.tab-button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.tab-button.active {
    background: rgba(76, 175, 80, 0.3);
    border-color: #4CAF50;
    color: #4CAF50;
}

/* タブコンテンツ */
.tab-content {
    position: relative;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* タブ内のセクション */
.api-key-section,
.simulation-controls,
.agent-creation,
.agent-storage-controls,
.camera-controls,
.road-visualization,
.other-controls {
    margin-bottom: 15px;
}

.api-key-section input,
.api-key-section textarea {
    margin-bottom: 8px;
}

.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
}

.input-group label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
}

#info-panel {
    top: 10px;
    left: 10px;
    max-width: 280px;
    max-height: 70vh;
    overflow-y: auto;
}

#log-panel {
    bottom: 10px;
    right: 10px;
    max-width: 350px;
    max-height: 200px;
    overflow-y: auto;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    cursor: move;
}

.panel-title {
    font-size: 13px;
    font-weight: bold;
    color: #fff;
    text-shadow: none;
    margin: 0;
}

.panel-controls {
    display: flex;
    gap: 8px;
}

.panel-button {
    background: none;
    border: none;
    color: #4CAF50;
    cursor: pointer;
    padding: 2px 6px;
    font-size: 12px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.panel-button:hover {
    background: rgba(76, 175, 80, 0.2);
}

.panel-content {
    transition: all 0.3s ease;
}

.panel-minimized .panel-content {
    display: none;
}

.panel-minimized {
    padding: 8px;
}

input[type="text"], input[type="password"] {
    width: 100%;
    padding: 4px 8px;
    background: rgba(0,0,0,0.5);
    border: 1px solid #fff;
    border-radius: 4px;
    color: #fff;
    font-size: 12px;
    text-shadow: none;
}

.prompt-section {
    margin: 10px 0;
}

.prompt-section label {
    display: block;
    margin-bottom: 5px;
    font-size: 12px;
    color: #fff;
}

.prompt-section textarea {
    width: 100%;
    padding: 6px 8px;
    background: rgba(0,0,0,0.5);
    border: 1px solid #fff;
    border-radius: 4px;
    color: #fff;
    font-size: 11px;
    text-shadow: none;
    resize: vertical;
    min-height: 60px;
    font-family: inherit;
}

.prompt-section textarea:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 5px rgba(76, 175, 80, 0.3);
}

button {
    background: rgba(0,0,0,0.7);
    color: #fff;
    border: 1px solid #fff;
    box-shadow: none;
    text-shadow: none;
    font-size: 12px;
    padding: 4px 10px;
}

button:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

button:disabled {
    background: #222;
    color: #888;
    border: 1px solid #444;
}

.agent-card {
    margin: 10px 0;
    padding: 10px;
    background: rgba(0,0,0,0.5);
    border: 1px solid #fff;
    border-radius: 6px;
    transition: all 0.3s ease;
    box-shadow: none;
    font-size: 12px;
}

.agent-card:hover {
    background: rgba(255,255,255,0.05);
    border-color: #fff;
}

.agent-name {
    font-weight: bold;
    font-size: 12px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #fff;
    text-shadow: none;
}

.agent-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    background: #fff;
    box-shadow: none;
}

.status-active {
    background: #4CAF50;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.agent-info-row {
    margin: 3px 0;
    font-size: 12px;
    color: #b0b0b0;
}

.agent-thought {
    font-style: italic;
    color: #fff;
    margin-top: 6px;
    padding: 6px;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
    border-left: 2px solid #fff;
    font-size: 11px;
    text-shadow: none;
}

.agent-memory {
    margin-top: 6px;
    font-size: 11px;
}

.memory-item {
    padding: 3px 6px;
    margin: 2px 0;
    background: rgba(255,255,255,0.03);
    border-radius: 3px;
    color: #fff;
    font-size: 11px;
}

.relationship-info {
    margin-top: 6px;
    font-size: 11px;
}

.relationship-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 4px 0;
}

.relationship-bar {
    width: 100px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.relationship-fill {
    height: 100%;
    background: linear-gradient(to right, #ff6b6b, #ffd93d, #6bcf7f);
    transition: width 0.3s ease;
}

.log-entry {
    margin: 6px 0;
    padding: 6px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
    font-size: 11px;
    border-left: 3px solid transparent;
    transition: all 0.3s ease;
}

.log-entry:hover {
    background: rgba(255, 255, 255, 0.05);
}

.log-thought {
    border-left-color: #80cbc4;
    color: #80cbc4;
}

.log-interaction {
    border-left-color: #FFC107;
    color: #FFC107;
}

.log-movement {
    border-left-color: #2196F3;
    color: #2196F3;
}

.time-display {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.7);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    color: #fff;
    font-weight: bold;
    box-shadow: none;
    display: flex;
    align-items: center;
    gap: 15px;
}

/* 天候表示のスタイル */
.weather-display {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: bold;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
}

.weather-icon {
    font-size: 14px;
}

.weather-text {
    font-size: 11px;
}

.temperature {
    font-size: 11px;
    font-weight: bold;
}

.warning {
    color: #fff;
    font-size: 11px;
    margin-top: 8px;
    padding: 4px 8px;
    background: rgba(0,0,0,0.5);
    border-radius: 4px;
    border: 1px solid #fff;
}

/* ローディングインジケーター */
.thinking-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4CAF50;
    animation: pulse 1.5s infinite;
    margin-left: 8px;
}

@keyframes pulse {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
    100% { opacity: 1; transform: scale(1); }
}

.log-entry {
    margin: 8px 0;
    padding: 8px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    font-size: 13px;
    border-left: 3px solid transparent;
    transition: all 0.3s ease;
}

.log-entry:hover {
    background: rgba(255, 255, 255, 0.05);
}

.log-thought {
    border-left-color: #80cbc4;
    color: #80cbc4;
}

.log-interaction {
    border-left-color: #FFC107;
    color: #FFC107;
}

.log-movement {
    border-left-color: #2196F3;
    color: #2196F3;
}

.log-relationship {
    border-left-color: #E91E63;
    color: #E91E63;
}

.log-details-toggle {
    margin-top: 5px;
    cursor: pointer;
    color: #888;
    font-size: 12px;
}

.log-details-toggle:hover {
    color: #fff;
}

.log-details {
    margin-top: 6px;
    padding: 6px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 3px;
    font-size: 11px;
}

.log-detail-section {
    margin-bottom: 6px;
}

.log-detail-section h4 {
    margin: 0 0 4px 0;
    color: #4CAF50;
    font-size: 11px;
}

.agent-name {
    font-weight: bold;
    color: #4CAF50;
}

.relationship-change {
    color: #E91E63;
}

.camera-controls button, #resetCamera {
    background: rgba(0,0,0,0.7);
    color: #fff;
    border: 1px solid #fff;
    box-shadow: none;
    font-size: 12px;
}

.camera-status {
    margin-bottom: 10px;
    padding: 4px 8px;
    background: rgba(0,0,0,0.5);
    border: 1px solid #fff;
    border-radius: 4px;
    text-align: center;
}

.camera-status span {
    font-size: 11px;
    font-weight: bold;
    color: #fff;
}

.road-visualization {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255,255,255,0.2);
}

.road-visualization h3 {
    margin: 0 0 10px 0;
    font-size: 12px;
    color: #fff;
}

.road-visualization button {
    margin: 2px;
    padding: 4px 8px;
    font-size: 11px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    border: 1px solid #fff;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    margin-bottom: 5px;
}

.road-visualization button:hover {
    background: rgba(255,255,255,0.1);
}

.camera-target-display {
    position: absolute;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    color: #fff;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.2);
    z-index: 1000;
}

.camera-target-display span {
    font-size: 12px;
    color: #fff;
    text-shadow: none;
}

/* コミュニケーション機能のスタイル */
.communication-controls {
    margin: 10px 0;
    padding: 10px 0;
    border-top: 1px solid #333;
    border-bottom: 1px solid #333;
}

.communication-controls button {
    width: 100%;
    margin: 5px 0;
    padding: 8px;
    font-size: 12px;
}

/* モーダルスタイル */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
}

.modal-content {
    background-color: #1a1a1a;
    margin: 5% auto;
    padding: 0;
    border: 1px solid #fff;
    border-radius: 8px;
    width: 80%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background-color: #2a2a2a;
    border-bottom: 1px solid #333;
}

.modal-header h3 {
    margin: 0;
    color: #fff;
    font-size: 16px;
}

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: #fff;
}

.modal-body {
    padding: 15px;
    max-height: 60vh;
    overflow-y: auto;
}

.message-history {
    margin-bottom: 15px;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 10px;
    background-color: #0a0a0a;
}

.message-item {
    margin: 8px 0;
    padding: 8px;
    border-radius: 4px;
    font-size: 12px;
}

.message-user {
    background-color: #4CAF50;
    color: white;
    margin-left: 20px;
    text-align: right;
}

.message-agent {
    background-color: #2196F3;
    color: white;
    margin-right: 20px;
}

.message-input-area {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.message-input-area textarea {
    flex: 1;
    padding: 8px;
    background: rgba(0,0,0,0.5);
    border: 1px solid #fff;
    border-radius: 4px;
    color: #fff;
    font-size: 12px;
    resize: vertical;
    min-height: 60px;
    font-family: inherit;
}

.message-input-area button {
    padding: 8px 16px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.message-input-area button:hover {
    background: #45a049;
}

.message-input-area button:disabled {
    background: #666;
    cursor: not-allowed;
}

.message-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.message-buttons button {
    flex: 1;
    padding: 6px 12px;
    font-size: 11px;
}

.message-content {
    margin-bottom: 4px;
}

.message-time {
    font-size: 10px;
    color: #888;
    text-align: right;
}

.agent-storage-controls {
    margin-top: 10px;
    padding: 10px 0;
    border-top: 1px solid #333;
}

.agent-storage-controls button {
    width: 100%;
    margin: 5px 0;
    padding: 8px;
    font-size: 11px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    border: 1px solid #fff;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.agent-storage-controls button:hover {
    background: rgba(255,255,255,0.1);
}

.agent-storage-controls button:first-child {
    background: rgba(76, 175, 80, 0.3);
    border-color: #4CAF50;
}

.agent-storage-controls button:last-child {
    background: rgba(244, 67, 54, 0.3);
    border-color: #f44336;
}

/* エージェント詳細モーダル */
.agent-detail-modal {
    width: 90%;
    max-width: 1000px;
    max-height: 90vh;
    overflow-y: auto;
}

.agent-detail-tabs {
    display: flex;
    border-bottom: 1px solid #fff;
    margin-bottom: 15px;
}

.tab-button {
    background: rgba(0,0,0,0.5);
    border: 1px solid #fff;
    border-bottom: none;
    color: #fff;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 12px;
    border-radius: 4px 4px 0 0;
    margin-right: 2px;
}

.tab-button.active {
    background: rgba(76, 175, 80, 0.3);
    border-color: #4CAF50;
}

.tab-button:hover {
    background: rgba(255,255,255,0.1);
}

.tab-content {
    min-height: 400px;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.agent-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.agent-basic-info, .agent-stats, .agent-relationships {
    background: rgba(0,0,0,0.3);
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #fff;
}

.agent-basic-info h4, .agent-stats h4, .agent-relationships h4 {
    margin: 0 0 10px 0;
    color: #4CAF50;
    font-size: 14px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 12px;
}

.info-label {
    font-weight: bold;
    color: #ccc;
}

.info-value {
    color: #fff;
}

.movement-history, .action-history, .thought-history {
    background: rgba(0,0,0,0.3);
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #fff;
    max-height: 400px;
    overflow-y: auto;
}

.history-item {
    background: rgba(255,255,255,0.05);
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 4px;
    border-left: 3px solid #4CAF50;
    font-size: 12px;
}

.history-time {
    color: #888;
    font-size: 11px;
    margin-bottom: 4px;
}

.history-content {
    color: #fff;
}

.charts-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.chart-section {
    background: rgba(0,0,0,0.3);
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #fff;
}

.chart-section h4 {
    margin: 0 0 10px 0;
    color: #4CAF50;
    font-size: 14px;
}

.chart-section canvas {
    width: 100%;
    height: auto;
    background: rgba(0,0,0,0.2);
    border-radius: 4px;
}

/* 詳細ボタン */
.agent-detail-btn {
    background: rgba(76, 175, 80, 0.3);
    border: 1px solid #4CAF50;
    color: #fff;
    padding: 2px 6px;
    font-size: 10px;
    border-radius: 3px;
    cursor: pointer;
    margin-left: 8px;
}

.agent-detail-btn:hover {
    background: rgba(76, 175, 80, 0.5);
}

/* フィールド色選択ボタン */
.field-color-section {
    margin-bottom: 15px;
}

.field-color-section h4 {
    margin-bottom: 10px;
    color: #4CAF50;
}

.color-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.color-btn {
    padding: 8px 12px;
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    transition: all 0.2s ease;
    text-align: center;
}

.color-btn:hover {
    transform: scale(1.05);
    border-color: #fff;
}

.color-btn.selected {
    border-color: #4CAF50;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.5);
    transform: scale(1.05);
}
