/* 基本リセットと共通設定 */
:root {
    --bg-dark: #070b16;
    --card-bg: rgba(18, 26, 47, 0.4);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glowing: rgba(59, 130, 246, 0.4);
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --accent-blue: #3b82f6;
    --accent-pink: #ec4899;
    --accent-violet: #8b5cf6;
    --accent-green: #10b981;
    --accent-cyan: #06b6d4;
    --accent-orange: #f59e0b;
    --accent-red: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Inter', 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    overflow-x: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 粒子バックグラウンド */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(236, 72, 153, 0.08) 0%, transparent 40%);
    z-index: -1;
    pointer-events: none;
}

/* Glassmorphism パネル */
.glass {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.hidden {
    display: none !important;
}

/* 共通UI部品 */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-violet) 100%);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(59, 130, 246, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-xs {
    padding: 4px 8px;
    font-size: 11px;
}

/* ログインコンテナ */
#login-container {
    width: 100%;
    max-width: 440px;
    padding: 40px;
    animation: fadeIn 0.6s ease-out;
}

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

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #fff 30%, var(--accent-blue) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.domain-tag {
    font-size: 13px;
    color: var(--accent-cyan);
    font-weight: 600;
    margin-top: 4px;
    letter-spacing: 1px;
}

.subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: white;
    outline: none;
    transition: all 0.3s;
}

.form-group input:focus {
    border-color: var(--accent-blue);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.error-msg {
    color: var(--accent-red);
    font-size: 13px;
    margin-bottom: 15px;
    background: rgba(239, 68, 68, 0.1);
    padding: 10px;
    border-radius: 6px;
    border-left: 3px solid var(--accent-red);
}

/* メインアプリケーションコンテナ */
#app-container {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 16px;
}

/* ヘッダー */
.main-header {
    height: 70px;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, #fff 50%, var(--accent-blue) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.badge {
    background: rgba(255, 255, 255, 0.08);
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    color: var(--accent-blue);
}

.url-badge {
    color: var(--accent-cyan);
    font-weight: 600;
    font-size: 12px;
}

.mode-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mode-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.select-wrapper select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 16px;
    color: var(--text-primary);
    outline: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s;
}

.select-wrapper select:hover {
    background: rgba(255, 255, 255, 0.08);
}

.select-wrapper select option {
    background-color: #0c1120;
    color: var(--text-primary);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 15px;
}

#user-email-display {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* メインレイアウト */
.main-layout {
    flex: 1;
    display: flex;
    gap: 16px;
    overflow: hidden;
}

/* 左サイドバー */
.sidebar-left {
    width: 260px;
    min-width: 260px;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.sidebar-section {
    margin-bottom: 24px;
}

.sidebar-section h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-weight: 700;
}

.history-section {
    flex: 1;
    overflow-y: auto;
}

.history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.history-item.active {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.2);
    color: white;
    font-weight: 500;
}

/* ワークスペース */
.main-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow: hidden;
}

/* 仮想クラウドステータス */
.cloud-status-panel {
    padding: 18px 24px;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.section-title h2 {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.live-indicator {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-green);
    border: 1px solid rgba(16, 185, 129, 0.2);
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    animation: pulse 1.8s infinite;
}

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

.cloud-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
}

.cloud-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.cloud-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--accent-blue);
}

.cloud-card.node-phi-4::before { background: var(--accent-blue); }
.cloud-card.node-gemma-4::before { background: var(--accent-pink); }
.cloud-card.node-llama-4::before { background: var(--accent-orange); }
.cloud-card.node-yi-1.5::before { background: var(--accent-green); }
.cloud-card.node-granite::before { background: var(--accent-violet); }
.cloud-card.node-simplesd::before { background: var(--accent-cyan); }
.cloud-card.node-rlt-32b::before { background: var(--accent-red); }

.cloud-card h4 {
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.node-role {
    font-size: 10px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.node-metrics {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
    text-align: left;
    background: rgba(0, 0, 0, 0.15);
    padding: 6px 8px;
    border-radius: 6px;
}

.metric-row {
    display: flex;
    justify-content: space-between;
}

.metric-val {
    font-weight: 600;
    color: var(--text-primary);
}

.node-adapter {
    font-size: 9px;
    font-weight: 700;
    color: var(--accent-cyan);
    margin-top: 6px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* チャットパネル */
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 20px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding-right: 10px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

/* スクロールバー装飾 */
.chat-messages::-webkit-scrollbar,
.history-section::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track,
.history-section::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb,
.history-section::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
}

.welcome-message {
    text-align: center;
    margin: auto;
    max-width: 460px;
    color: var(--text-secondary);
}

.welcome-message h3 {
    font-family: 'Outfit', sans-serif;
    color: white;
    font-size: 20px;
    margin-bottom: 10px;
}

/* メッセージバブル */
.message-bubble {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 12px;
    line-height: 1.6;
    font-size: 14px;
    animation: fadeInBubble 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.message-bubble.user {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2) 0%, rgba(139, 92, 246, 0.2) 100%);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: white;
    border-bottom-right-radius: 2px;
}

.message-bubble.ai {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 2px;
}

.message-header {
    font-weight: 700;
    font-size: 11px;
    margin-bottom: 6px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.message-bubble.user .message-header {
    color: var(--accent-cyan);
    text-align: right;
}

.message-bubble.ai .message-header {
    color: var(--accent-orange);
}

/* 円卓会議の発言者毎の展開 */
.roundtable-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
}

.speaker-bubble {
    display: flex;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    border-left: 4px solid var(--accent-blue);
    animation: fadeInBubble 0.4s ease-out;
}

.speaker-icon {
    font-size: 20px;
    min-width: 30px;
    height: 30px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.speaker-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.speaker-meta {
    font-size: 11px;
    font-weight: 700;
}

.speaker-role {
    color: var(--text-secondary);
    font-weight: 500;
    margin-left: 6px;
}

.speaker-text {
    font-size: 13.5px;
    color: var(--text-primary);
    white-space: pre-wrap;
}

/* チャット入力エリア */
.chat-input-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.input-options {
    display: flex;
    gap: 12px;
}

.input-row {
    display: flex;
    gap: 12px;
}

.input-row textarea {
    flex: 1;
    height: 60px;
    resize: none;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    color: white;
    outline: none;
    font-size: 14px;
    transition: all 0.3s;
}

.input-row textarea:focus {
    border-color: var(--accent-blue);
    background: rgba(255, 255, 255, 0.06);
}

.btn-send {
    background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-violet) 100%);
    color: white;
    width: 100px;
}

/* 右サイドバー: 管理者設定 */
.sidebar-right {
    width: 280px;
    min-width: 280px;
    display: flex;
    flex-direction: column;
    padding: 20px;
    border-left: 1px solid var(--border-color);
}

.section-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.form-group-sm {
    margin-bottom: 12px;
}

.form-group-sm label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.form-group-sm input {
    width: 100%;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: white;
    font-size: 12px;
    outline: none;
}

.form-group-sm input:focus {
    border-color: var(--accent-blue);
}

.user-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 250px;
    overflow-y: auto;
}

.user-item {
    background: rgba(255, 255, 255, 0.02);
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--border-color);
}

.user-item-info {
    display: flex;
    flex-direction: column;
    max-width: 65%;
}

.user-item-email {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-status-suspended {
    color: var(--accent-red);
    font-weight: 700;
    font-size: 10px;
}

.user-status-active {
    color: var(--accent-green);
    font-weight: 700;
    font-size: 10px;
}

/* モーダル */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-content {
    width: 100%;
    max-width: 400px;
    padding: 30px;
    border-radius: 16px;
}

.modal-content h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 20px;
    margin-bottom: 20px;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.status-msg {
    font-size: 12px;
    padding: 6px;
    border-radius: 4px;
    margin-top: 10px;
    text-align: center;
}

.status-msg.success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
}

.status-msg.error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
}
