/* style.css (v1.0 Final) */

/* ============================================= */
/* 全体・共通スタイル */
/* ============================================= */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f7f6;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

main {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 90%;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* ============================================= */
/* タブナビゲーション (モダンなトグル風) */
/* ============================================= */
#app-tabs {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #e0e0e0;
    padding: 6px;
    border-radius: 30px;
    margin: 10px auto;
    width: fit-content;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 10;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 10px 24px;
    font-size: 1rem;
    font-weight: bold;
    color: #666;
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
}

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

.tab-btn.active {
    background-color: #00796b;
    color: white;
    box-shadow: 0 4px 8px rgba(0, 121, 107, 0.3);
}

/* ============================================= */
/* ログイン画面のスタイル */
/* ============================================= */
#login-container .login-box {
    max-width: 350px;
    margin: auto;
    padding: 40px;
    text-align: center;
}

.login-box h1 {
    margin-bottom: 25px;
    color: #004d40;
}

.login-box input {
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-sizing: border-box;
}

.login-box button {
    width: 100%;
    padding: 12px 15px;
    border: none;
    border-radius: 6px;
    background-color: #004d40;
    color: white;
    font-size: 1.1em;
    cursor: pointer;
    transition: background-color 0.3s;
}

.login-box button:hover {
    background-color: #00382e;
}

.error-message {
    color: #d32f2f;
    margin-top: 15px;
    font-size: 0.9em;
    min-height: 1.2em;
}


/* ============================================= */
/* チャット画面のスタイル */
/* ============================================= */
#chat-container {
    max-width: 700px;
    /* 古いブラウザ用（dvhを知らないブラウザはここを読む） */
    height: calc(100vh - 90px);
    /* 新しいブラウザ用（dvhを知っているブラウザはこっちで上書きする） */
    height: calc(100dvh - 90px);
    display: flex;
    flex-direction: column;
}

/* --- header (AI補助教師の部分) --- */
header {
    background-color: #004d40;
    color: white;
    padding: 10px 20px;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    /* 両端に寄せる */
    align-items: center;
}

header h1 {
    margin: 0;
    font-size: 1.4em;
    /* 少し小さく */
}

#member-info {
    font-size: 0.8em;
    margin: 0;
    color: #e0f2f1;
}

#topic-selector {
    margin-top: 8px;
}

.topic-options {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 15px;
    /* 縦と横の間隔 */
}

.topic-options label {
    font-size: 0.8em;
    cursor: pointer;
}

#chat-window {
    flex-grow: 1;
    /* 利用可能な高さをすべて使う */
    padding: 20px;
    overflow-y: auto;
    border-bottom: 1px solid #ddd;
    /* ▼▼▼ 追加 ▼▼▼ */
    overflow-x: hidden;
    /* 横スクロールを禁止 */
}

.message {
    margin-bottom: 15px;
    padding: 10px 15px;
    border-radius: 18px;
    max-width: 80%;
    line-height: 1.5;
    /* ▼▼▼ 追加 ▼▼▼ */
    overflow-wrap: break-word;
    /* 長い単語を折り返す */
    word-break: break-word;
    /* これも念のため入れておくと安心 */
}

.message p {
    margin: 0;
}

.message.user {
    background-color: #b3e5fc;
    margin-left: auto;
}

.message.model,
.message.system {
    background-color: #e0f2f1;
    margin-right: auto;
}

.message pre.code {
    background-color: #000000;
    color: #f1f1f1;
    padding: 10px;
    border-radius: 6px;
    overflow-x: auto;
    margin-top: 10px;
    font-size: 0.9em;
}

.message.model h3 {
    color: #004d40;
    border-bottom: 2px solid #e0f2f1;
    padding-bottom: 5px;
    margin-top: 25px;
    font-size: 1.2em;
}

#input-area {
    display: flex;
    padding: 15px 20px;
    background-color: #f9f9f9;
    border-top: 1px solid #eee;
}

#question-input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    margin-right: 10px;
    resize: none;
}

#send-button {
    background-color: #004d40;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s;
}

#send-button:hover:not(:disabled) {
    background-color: #00382e;
}

#send-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

#status-message {
    padding: 10px 20px;
    text-align: center;
    font-size: 0.9em;
    display: none;
}

.error {
    color: #d32f2f;
    background-color: #ffcdd2;
}

.info {
    color: #004d40;
    background-color: #e0f2f1;
}

/* style.css の末尾に追記 */

#disclaimer {
    padding: 8px 20px;
    background-color: #fffbe6;
    /* 薄い黄色 */
    border-top: 1px solid #eee;
}

#disclaimer p {
    margin: 0;
    font-size: 0.7em;
    /* 0.75em から 0.7em に変更 */
    color: #5d4037;
    /* 茶色系の文字 */
    text-align: center;
    line-height: 1.5;
}

/* ============================================= */
/* ログイン画面のお知らせ欄 (追記) */
/* ============================================= */
#notification-area {
    /* ログインボックス(350px + 左右padding 40px*2 = 430px)に合わせる */
    max-width: 430px;
    margin: 20px auto 30px auto;
    padding: 0 40px;
    /* ログインボックスのpaddingと合わせる */
    box-sizing: border-box;
}

#notification-area h2 {
    font-size: 1.2em;
    color: #004d40;
    border-bottom: 2px solid #e0f2f1;
    padding-bottom: 5px;
    margin-bottom: 15px;
}

#notification-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 200px;
    /* お知らせが多くなったらスクロール */
    overflow-y: auto;
    font-size: 0.9em;
    border: 1px solid #eee;
    border-radius: 6px;
}

#notification-list li {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
}

#notification-list li:last-child {
    border-bottom: none;
}

/* 読み込み中・お知らせなし の表示 */
#notification-list #notification-loading,
#notification-list li:only-child {
    color: #888;
    border-bottom: none;
}

.notification-date {
    display: block;
    font-size: 0.8em;
    color: #777;
    margin-bottom: 4px;
}

.notification-title {
    font-weight: bold;
    color: #333;
    display: block;
}

.notification-content {
    margin: 5px 0 0 0;
    color: #555;
    line-height: 1.5;
    font-size: 0.9em;
    /* 長い内容の場合に備えて改行を許可 */
    white-space: pre-wrap;
    word-break: break-word;
}

/* ============================================= */
/* iPhoneなどスマホでの入力時ズーム防止 */
/* ============================================= */
@media screen and (max-width: 768px) {

    /* スマホサイズの時だけ適用 */
    input,
    textarea,
    select {
        font-size: 16px !important;
        /* 16px以上ならズームされない */
    }
}

/* まちゼミ専用トピックの強調 */
.special-topic {
    background-color: #fff3e0;
    /* 薄いオレンジ背景 */
    padding: 5px 10px;
    border-radius: 15px;
    border: 1px solid #ffb74d;
    font-weight: bold;
    color: #e65100;
    display: flex;
    align-items: center;
    font-size: 0.8em;
    background-color: #00897b;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.task-board {
    display: flex;
    gap: 15px;
    flex-grow: 1;
    overflow-x: auto;
    min-height: 0;
}

.task-column {
    flex: 1;
    background: #e0e0e0;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    min-width: 200px;
    min-height: 0;
}

.task-column h3 {
    margin: 0 0 10px 0;
    font-size: 1em;
    text-align: center;
    color: #333;
}

.task-list {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.task-card {
    background: white;
    padding: 10px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    font-size: 0.9em;
    cursor: grab;
    position: relative;
}

.task-card:active {
    cursor: grabbing;
}

.task-card select {
    display: block;
    margin-top: 8px;
    width: 100%;
    padding: 4px;
    font-size: 0.85em;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* モーダル */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    background: white;
    padding: 25px;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content input,
.modal-content textarea {
    width: 100%;
    padding: 10px;
    margin: 10px 0 20px 0;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-family: inherit;
    resize: vertical;
}

.modal-content label {
    font-size: 0.9em;
    font-weight: bold;
    color: #444;
}

.modal-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

.modal-actions .right-actions {
    display: flex;
    gap: 10px;
}

.modal-actions button {
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background: #004d40;
    color: white;
}

.modal-actions button.cancel-btn {
    background: #ccc;
    color: #333;
}

.modal-actions button.danger-btn {
    background: #d32f2f;
    color: white;
}

/* ============================================= */
/* チームルーム */
/* ============================================= */

#team-container {
    height: calc(100vh - 90px);
    height: calc(100dvh - 90px);
    display: flex;
    flex-direction: column;
}

.team-layout {
    display: flex;
    flex-direction: row;
    gap: 20px;
    flex-grow: 1;
    padding: 10px;
    box-sizing: border-box;
    overflow: hidden;
    min-height: 0;
}

@media screen and (max-width: 768px) {
    .team-layout {
        display: block;
        overflow-y: auto;
    }

    .team-chat-area {
        flex: none;
        height: 50vh;
        min-height: 350px;
        max-height: none;
        margin-bottom: 20px;
    }

    .team-task-area {
        flex: none;
        height: 70vh;
        min-height: 500px;
    }
}

.team-chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fdfdfd;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    min-width: 300px;
    min-height: 0;
}

#group-chat-window {
    flex-grow: 1;
    overflow-y: auto;
    padding: 15px;
    background: #ffffff;
}

#group-input-area {
    display: flex;
    padding: 10px;
    background-color: transparent;
    border-top: 1px solid #eee;
    align-items: center;
}

#group-question-input {
    flex-grow: 1;
    padding: 10px;
    font-size: 1em;
    border: 1px solid #ccc;
    border-radius: 20px;
    resize: none;
    font-family: inherit;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
    height: auto;
}

#group-send-button {
    background-color: #00897b;
    color: white;
    border: none;
    border-radius: 20px;
    padding: 10px 20px;
    font-size: 1em;
    margin-left: 10px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.team-task-area {
    flex: 2;
    display: flex;
    flex-direction: column;
    background: #fdfdfd;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    padding: 15px;
    overflow: hidden;
    min-height: 0;
}

.team-task-area h2 {
    margin: 0 0 15px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.2em;
}