/* 基本的なスタイル設定 */
body {
    display: flex;
    height: 100vh;
    font-size: 15pt;
    font-family: 'Open sans', sans-serif;
    background-color: #F3F4F6;
    flex-direction: column; 
    margin: 0;
}
header {
    background-color: #0a8ee1;
    color: white;
}
h1 {
    font-size: 1.25rem;
    font-weight: 600;
}
button:disabled {
  filter: brightness(0.7);
  opacity: 0.7;
  cursor: not-allowed !important;
}
/* フォームのラベル */
.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.25rem;
}
/* フォームのテキストエリアや入力エリア */
.form-textarea, .form-input {
    display: block;
    width: 100%;
    border-radius: 0.375rem;
    border: 1px solid #D1D5DB;
    box-shadow: 0 1px 2px 0 rgba(0,0,0,0.05);
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    box-sizing: border-box;
    resize: none;
}
.no-wrap-textarea {
    white-space: pre;
    overflow-x: auto;
    line-height: 1.3;
}
.form-textarea:focus, .form-input:focus {
    border-color: #A5B4FC;
    box-shadow: 0 0 0 3px rgba(199, 210, 254, 0.5);
    outline: none;
}
/* ボタンデフォルト */
.defult-btn {
    width: fit-content;
    background-color: #0a8ee1;
    color: white;
    font-size: 0.8rem;;
    font-weight: 600;
    padding: 0.5rem 0.5rem;
    border-radius: 0.25rem;
    /* margin-bottom: 1rem; */
    transition: background-color 0.15s ease-in-out;
    border: none;
    cursor: pointer;
    text-align: center;
}
.defult-btn:hover {
    background-color: #007ecc;
}
/* ドロップダウンメニュー（共通） */
.dropdown-menu {
    position: absolute;
    font-size: 0.8rem;
    background-color: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 50;
    min-width: 120px;
}
/* ドロップダウンメニューの各項目 */
.dropdown-item {
    padding: 8px 12px;
    cursor: pointer;
}
.dropdown-item:hover {
    background-color: #f3f4f6;
}
/* 要素を強制的に非表示にする */
.hidden {
    display: none !important;
}
/* ヘッダ */
.header-left-div {
    display: flex;
    align-items: center;
}
/* サイドバーの開閉ボタン */
#toggle-sidebar-btn {
    margin-right: 1rem;
    color: white;
    background: none;
    border: none;
    cursor: pointer;
}
#toggle-sidebar-btn:hover {
    color: #D1D5DB;
}
#toggle-sidebar-btn:focus {
    outline: none;
}
#toggle-sidebar-btn .fa-bars, #toggle-sidebar-btn .fa-angle-double-right {
    font-size: 1.25rem;
}
/* サイドバー */
.sidebar {
    width: 280px;
    min-width: 280px;
    /* 0.3秒かけて滑らかに開閉する */
    transition: width 0.3s ease-in-out, padding 0.3s ease-in-out, min-width 0.3s ease-in-out, border-width 0.3s ease-in-out;
    overflow-x: hidden;
    background-color: #E5E7EB;
    padding: 1rem 1rem 0 1rem;
    display: flex;
    flex-direction: column; 
    overflow-y: auto;
    border-right: 1px solid #D1D5DB;
}
.sidebar > *:not(:last-child) {
    margin-bottom: 1rem;
}
.sidebar.collapsed {
    width: 0px !important;
    min-width: 0px !important;
    padding-left: 0px !important;
    padding-right: 0px !important;
    border-right-width: 0px !important;
    overflow: hidden;
}
.sidebar.collapsed > * {
    display: none;
}
/* 新しい会話ボタン */
#add-new-thread-btn {
    width: 100%;
    background-color: #0077b5;
    color: white;
    font-weight: bold;
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    margin-bottom: 1rem;
    transition: background-color 0.15s ease-in-out;
    border: none;
    cursor: pointer;
    text-align: center;
}
#add-new-thread-btn:hover {
    background-color: #005b8c;
}
#add-new-thread-btn .fa-plus {
    margin-right: 0.5rem;
}
/* スレッド（会話履歴）のリスト */
#thread-list {
    flex-grow: 1;
    overflow-y: auto;
    max-height: calc(100vh - 325px);
    border: solid 1px #D1D5DB;
    border-radius: 6px 0 0 6px;
}
#thread-list > div
{
    margin-bottom: 0.25rem;
}
/* スレッド選択ボタン */
.thread-button {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 8px 12px;
    margin-bottom: 4px;
    border-radius: 0.375rem;
    text-align: left;
    transition: background-color 0.2s;
    border: none;
    background-color: transparent;
    cursor: pointer;
}
.thread-button:hover {
    background-color: #e5e7eb;
}
/* 現在選択中のスレッドボタン */
.thread-button.active {
    background-color: #d1d5db;
    font-weight: bold;
}
.thread-button span.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-grow: 1;
    margin-right: 0.5rem;
}
/* スレッドリストの横にある「...」メニューボタン */
.menu-button {
    padding: 4px;
    border-radius: 50%;
    color: #6B7280;
    padding: 0.25rem;
    border: none;
    background-color: transparent;
    cursor: pointer;
}
/* サイドバー下部のボタン（テストパネル、本番ウィンドウ）の共通スタイル */
.sidebar-bottom-buttons > button,
.sidebar-bottom-buttons .requires-auth > button {
    width: 100%;
    color: white;
    font-weight: bold;
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    transition: background-color 0.15s ease-in-out;
    border: none;
    cursor: pointer;
    margin-bottom: 0.5rem;
}
.sidebar-bottom-buttons > button:last-child,
.sidebar-bottom-buttons .requires-auth > button:last-child {
    margin-bottom: 0;
}
/* テストパネルボタン */
#test-panel-btn, #production-panel-btn {
    background-color: #0a8ee1;
}
#test-panel-btn:hover, #production-panel-btn:hover {
    background-color: #007ecc;
}
/* 本番パネルボタン */
#production-window-btn {
    background-color: #22C55E;
}
#production-window-btn:hover{
    background-color: #16A34A;
}
/* ユーザーメニューのコンテナ */
.user-menu-container {
    position: relative;
}
/* --- ユーザー情報ツールチップ --- */
/* ユーザーメニューボタン */
#user-menu-button {
    cursor: pointer;
    display: flex;
    align-items: center;
    color: #4B5563;
    width: fit-content;
    padding: 0.5rem;
    border-radius: 0.25rem;
    transition: background-color 0.15s ease-in-out, color 0.15s ease-in-out;
    border: none;
    background: none;
    text-align: left;
}
/* ユーザーアイコン */
#user-menu-button > i {
    font-size: 1.5rem;
    border: 2px solid #6B7280;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s ease-in-out;
}
#user-menu-button:hover {
    color: #1F2937;
    background-color: #D1D5DB;
}
#user-menu-button:hover > i {
    border-color: #1F2937;
}

/* ユーザーコンテキストメニューの配置 */
#user-context-menu {
    position: absolute;
    bottom: 0px;
    left: 60px;
    margin-bottom: 10px;
    min-width: 150px;
    z-index: 60;
    background-color: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* メニュー内のアイコン調整 */
#logout-btn i {
    margin-right: 0.5rem;
}
/* ユーザー情報ツールチップのスタイル */
.user-menu-container {
    position: relative;
}
.user-tooltip {
    position: absolute;
    left: -20px;
    bottom: 60px;
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 8px 12px;
    width: max-content;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
    z-index: 100;
    font-size: 0.85rem;
    color: #333;
    line-height: 1.4;
    text-align: left;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease-in-out, visibility 0.2s;
}
.user-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 20px;
    margin-top: 0;
    border-width: 6px;
    border-style: solid;
    border-color: transparent #ccc transparent transparent;
}
#user-menu-button:hover + .user-tooltip {
    visibility: visible;
    opacity: 1;
}
.tooltip-grid {
    display: grid;
    grid-template-columns: auto auto 1fr;
    gap: 4px 8px;
    align-items: baseline;
}
.tooltip-label {
    font-weight: bold;
    text-align: left;
    white-space: nowrap;
    color: #555;
}
.tooltip-sep {
    color: #555;
    font-weight: bold;
}
.tooltip-value {
    /* 値は左寄せ */
    text-align: left;
    color: #111;
    /* 必要ならフォント指定など */
}

/* メインコンテンツエリア */
.main-content {
    flex-grow: 1;
    transition: margin-left 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    width: calc(100vw - 345px);
    max-width: calc(100vw - 345px);
    padding: 1rem;
    background-color: #FFFFFF;
}
/* チャット表示エリア */
#chat-display {
    flex: 1 1 0%;
    overflow-y: auto;
    margin-bottom: 1rem;
    padding: 0.75rem;
    border: 1px solid #D1D5DB;
    border-radius: 0.5rem;
    background-color: #F9FAFB;
    display: flex;
    flex-direction: column;
}
#chat-display > div {
    margin-bottom: 0.5rem;
}
#chat-display > div:last-child {
    margin-bottom: 0;
}
/* チャットの吹き出し（共通） */
.chat-bubble {
    width: calc(100% - 25px);
    max-width: calc(100% - 25px);
    padding: 10px 15px;
    border-radius: 15px;
    margin-bottom: 10px;
    word-wrap: break-word;
    white-space: pre-wrap;
    margin-bottom: 0.5rem;
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
}
/* ユーザー、ボット */
.chat-message-wrapper {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
}
.sender-label {
    font-size: 0.75rem;
    color: #555;
    margin-bottom: 4px;
}
/* ユーザー側の吹き出し */
.user-bubble {
    background-color: #DCF8C6;
    border-bottom-right-radius: 0;
    align-self: flex-end;
}
/* ボット側の吹き出し */
.bot-bubble {
    background-color: #D1E7FD;
    border-bottom-left-radius: 0;
    align-self: flex-start;
}
/* チャット内のコードブロックのスタイル */
.chat-bubble pre {
    background-color: #1f2937;  
    color: #f9fafb;
    padding: 0.5rem;
    border-radius: 0.375rem;
    overflow-x: auto;
    font-size: 0.75rem;
    max-width: 100%;
    white-space: pre;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}
.chat-bubble code {
    font-family: monospace;
}
/* 入力エリア全体 */
.input-area {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 10px;
}
.input-area-controls { 
    display: flex;
    align-items: center;
    height: auto;
    width: fit-content;
}
/* ファイル添付ボタン（ラベル） */
#attach-label {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #0a8ee1;
    color: white;
    font-size: 0.875rem;
    font-weight: bold;
    text-align: center;
    padding: 0;
    border-radius: 0.5rem;
    cursor: pointer;
    margin-right: 0;
    transition: background-color 0.15s ease-in-out;
    width: 70px;
    height: auto;
    padding: 0.8rem 0.2rem;
}
#attach-label:hover {
    background-color: #007ecc;
}
#attach-label .fa-paperclip {
    margin-right: 0.25rem;
}
#attached-file-name {
    cursor: pointer;
}
/* 添付ファイル一覧 */
#file-list { 
    margin-bottom: 0.5rem;
    display: none;
}
.file-item {
    font-size: 0.875rem;
    color: #4B5563;
    background-color: #f3f4f6;
    border: solid 1px #E5E7EB;
    border-radius: 0.25rem;
    padding: 0.25rem 0.5rem;
    display: inline-flex;
    align-items: center;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}
.file-item span {
    cursor: pointer;
}
.file-item span:hover {
    text-decoration: underline;
}
/* ファイル削除ボタン */
.file-item button {
    color: #EF4444;
    background: none;
    border: none;
    cursor: pointer;
    margin-left: 0.5rem;
    font-size: 1rem;
    padding: 0 0.25rem;
}
.file-item button:hover {
    color: #DC2626;
}
/* プロンプトコンテナ */
.prompt-send-container {
    display: flex;
    width: 100%;
    flex-grow: 1;
    align-items: center;
    gap: 10px;
}
/* プロンプト入力エリア */
#prompt-input {
    flex-grow: 1;
    border: 1px solid #D1D5DB;
    border-radius: 0.5rem;
    padding: 0.9rem 0.5rem;
    resize: vertical;
    box-sizing: border-box;
    overflow: hidden;
}
#prompt-input:focus {
    outline: none;
    border-color: #0a8ee1;
    box-shadow: inset 0 0 0 2px rgba(59, 130, 246, 0.5);
}
/* 送信ボタン */
#send-btn {
    background-color: #0a8ee1; 
    color: white;
    font-weight: bold;
    padding: 0.8rem 0;
    border-radius: 0.5rem;
    transition: background-color 0.15s ease-in-out;
    border: none;
    cursor: pointer;
    width: 70px;
    height: auto;
}
#send-btn:hover {
    background-color: #007ecc;
}
/* モーダルウィンドウ（小さいポップアップウィンドウ）の基本スタイル */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
    justify-content: center;
    align-items: center;
}
/* モーダルウィンドウの内容部分 */
.modal-container {
    position: relative;
    background-color: #fefefe;
    padding: 0;
    border: 1px solid #888;
    width: 90%;
    max-width: 500px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.modal-header {
    display: flex;
    width: 100%;
    background-color: #0a8ee1;
    border-radius: 8px 8px 0 0;
    justify-content: space-between;
}
.modal-header h2 {
    display: flex !important;
    color: #fff !important;
    font-size: 1rem !important;
    align-content: center !important;
    padding: 0 20px !important;
}
.modal-content {
    background-color: #fefefe;
    margin: 0 auto;
    padding: 20px;
    border-radius: 8px;
}
/* モーダル内のボタンをまとめるコンテナ */
.modal-buttons-container {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.modal-buttons-container button {
    margin-left: 0.5rem;
}
.modal-buttons-container button:first-child {
    margin-left: 0;
}

/* タイトル編集モーダルのキャンセルボタン */
#edit-title-modal .modal-buttons-container button.cancel-button {
    background-color: #D1D5DB;
    color: #374151;
}
#edit-title-modal .modal-buttons-container button.cancel-button:hover {
    background-color: #9CA3AF;
}
/* モーダル内のボタンの共通スタイル */
/*
.modal-button { 
    font-weight: bold;
    padding: 0.5rem 1rem; 
    border-radius: 0.25rem; 
    font-size: 0.875rem; 
    transition: background-color 0.15s ease-in-out,border-color 0.15s ease-in-out, color 0.15s ease-in-out;
    border: 1px solid transparent;
    cursor: pointer;
}
*/
/* 閉じる「×」ボタン */
.close-button {
    display: flex;
    color: #fff;
    float: right;
    font-size: 2rem;
    font-weight: bold;
    margin: auto 20px;
}
.close-button:hover,
.close-button:focus {
    color: #aaa;
    text-decoration: none;
    cursor: pointer;
}
/* テストパネル */
#panel-modal {
    justify-content: flex-end;
    align-items: stretch;
}
#panel-modal .modal-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 550px;
    border-radius: 8px;
    border-right: none;
    border-top: none;
    border-bottom: none;
    box-sizing: border-box;
}
#panel-modal .modal-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    width: inherit;
}
.panel-program-area {
    flex-grow: 2;
    display: flex;
    flex-direction: column;
}
/* 実行ログの親div */
.panel-log-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    margin-top: 1rem;
}
#panel-modal #execution-log {
    height: 100%;
}
#panel-modal #program-code {
    height: 100%;
}
#panel-modal h2, #package-maint-modal h2, #pg-register-modal h2, #edit-title-modal h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
}
#panel-modal .text-sm {
    font-size: 0.875rem;
}
#panel-modal .text-gray-600 {
    color: #4B5563;
}
#panel-modal .mb-2 {
    margin-bottom: 0.5rem;
}
#panel-modal .mt-4 {
    margin-top: 1rem;
}
#panel-modal .mt-2 {
    margin-top: 0.5rem;
}
.file-item span:hover {
    text-decoration: none !important;
    cursor: none;
}

/* PG実行 */
/* 「処理中です...」アニメーションのキーフレーム */
@keyframes ellipsis {
    0%   { content: ""; }
    25%   { content: "."; }
    50%  { content: ".."; }
    75%  { content: "..."; }
}
/* 「処理中です...」を表示するためのスタイル */
.is-processing {
    color: #6B7280;
}
/* ドット(...)の部分を疑似要素として作成し、アニメーションを適用 */
.is-processing::after {
    display: inline-block;
    width: 1.5em;
    vertical-align: bottom;
    animation: ellipsis 1.5s infinite;
    content: "...";
}
/* Disable設定 */
.disabled-label {
    filter: brightness(0.7);
    opacity: 0.7;
    cursor: not-allowed !important;
    pointer-events: none;
}
.disabled-list {
    opacity: 0.7;
    pointer-events: none;
}

/* マルチユーザー対応 */
/* ログインダイアログ */
#login-modal .modal-container {
    max-width: 600px !important;
}
#login-modal .modal-container .modal-content .form-label {
    min-width: 120px !important;
    max-width: 120px !important;
}
#login-error-message {
    font-size: 0.875rem;
    display: block;
    color: red;
    margin-bottom: 1rem;
}
/* パスワード表示切り替えボタン */
.password-wrapper {
    position: relative;
    width: 100%;
}
.password-wrapper input {
    padding-right: 2.5rem;
}
.password-toggle-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #6B7280;
    font-size: 1rem;
    z-index: 10;
}
.password-toggle-icon:hover {
    color: #374151;
}
/* メイン画面 */
/* ログイン必須要素 (.requires-auth) を削除 */
body.not-logged-in .requires-auth {
    display: none !important;
}
/* ログインボタン (.login-required) を表示 */
body.not-logged-in .login-required {
    display: block !important;
}
/* ログイン状態に応じたUI切り替え */
.not-logged-in .requires-auth {
    display: none !important;
}
/* ログインボタンとウェルカムメッセージを表示 */
.login-required {
    display: none !important;
}
.not-logged-in .login-required {
    display: block;
}
/* ログインボタンとウェルカムメッセージを非表示 */
body:not(.not-logged-in) .login-required {
    display: none !important;
}
/* ウェルカムメッセージ */
#welcome-message {
    display: flex !important;
    text-align: center;
    align-items: center;
    color: #374151;
    height: 100%;
    margin: auto; 
    padding: 2rem;
}
#welcome-message h1 {
    font-size: 1.75rem;
    font-weight: 600;
    color: #0a8ee1;
}
#welcome-message p {
    font-size: 1rem;
    color: #4B5563;
    margin-top: 0.5rem;
}

/* サイドバー */
/* ログインボタン (サイドバー) */
#login-btn {
width: 100%;
    background-color: #22C55E;
    color: white;
    font-weight: bold;
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    margin-bottom: 1rem;
    border: none;
    cursor: pointer;
    text-align: center;
    font-size: 1rem;
}
#login-btn:hover {
    background-color: #16A34A;
}
#login-btn .fa-sign-in-alt {
    margin-right: 0.5rem;
}
