/* manual_app/static/css/style.css */

/* ===============================================
   ベーススタイル
   =============================================== */
:root {
    --primary-color: #4a6fdc;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --border-color: #dee2e6;
    --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f7fa;
    margin: 0;
    padding: 0;
}

p {
    margin: 0;
    line-height: 1.4;
    word-break: break-word;
}

/* ===============================================
   ヘッダースタイル
   =============================================== */
.header {
    background-color: #4a6fdc;
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.header-container {
    max-width: 1200px;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    margin: 0 auto;
    box-sizing: border-box;
}

.brand {
    font-size: 1.5rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logout-btn {
    color: white;
    text-decoration: none;
    background-color: rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.logout-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* ===============================================
   メインコンテナスタイル
   =============================================== */
.container {
    max-width: 1200px;
    margin: 90px auto 20px;
    padding: 20px;
    background-color: #fff;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
}

.main-container {
    max-width: 1200px;
    margin: 90px auto 20px;
    padding: 0 20px;
}

/* ===============================================
   カードスタイル
   =============================================== */
.card {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    overflow: hidden;
}

.card-header {
    background-color: #f8f9fa;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #dee2e6;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body {
    padding: 1.5rem;
}

/* ===============================================
   フォームスタイル
   =============================================== */
.form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

.form-group select,
.form-group input[type="text"],
.form-group input[type="password"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s, box-shadow 0.3s;
    box-sizing: border-box;
}

.form-group select:focus,
.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus {
    outline: none;
    border-color: #4a6fdc;
    box-shadow: 0 0 0 3px rgba(74, 111, 220, 0.2);
}

/* ===============================================
   ファイルアップロードスタイル
   =============================================== */
.file-upload {
    margin-bottom: 1rem;
}

.file-input-wrapper {
    position: relative;
    margin-top: 0.5rem;
    border: 2px dashed #dee2e6;
    border-radius: 4px;
    padding: 1.5rem;
    text-align: center;
    transition: border-color 0.3s;
}

.file-input-wrapper:hover {
    border-color: #4a6fdc;
}

.file-input-wrapper input[type="file"] {
    display: block;
    width: 100%;
    margin-bottom: 0.5rem;
}

.file-name {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #6c757d;
}

/* ===============================================
   ボタンスタイル
   =============================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background-color: #4a6fdc;
    color: white;
}

.btn-primary:hover {
    background-color: #3a5fc8;
}

.btn-warning {
    background-color: #ffc107;
    color: #212529;
}

.btn-warning:hover {
    background-color: #e0a800;
}

.btn-info {
    background-color: #17a2b8;
    color: white;
}

.btn-info:hover {
    background-color: #138496;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
}

/* ===============================================
   テーブルスタイル
   =============================================== */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.table th,
.table td {
    padding: 0.75rem;
    border: 1px solid #dee2e6;
}

.table th {
    background-color: #f8f9fa;
    text-align: left;
}

.table tr:nth-child(even) {
    background-color: #f8f9fa;
}

.table tr:hover {
    background-color: #e9ecef;
}

.form-control {
    display: block;
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    transition: border-color 0.3s;
    box-sizing: border-box;
}

.form-control:focus {
    border-color: #4a6fdc;
    outline: none;
}

/* ===============================================
   フラッシュメッセージ
   =============================================== */
.flash-messages {
    margin-bottom: 1.5rem;
}

.flash-message {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.flash-message.success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.flash-message.error, .flash-message.danger {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.flash-message.info {
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

.flash-message.warning {
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
}

.flashes {
    list-style: none;
    padding: 0;
    margin: 20px 0;
}

.flashes li {
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 5px;
    color: white;
}

.flashes li.success {
    background-color: #28a745;
}

.flashes li.danger {
    background-color: #dc3545;
}

/* ===============================================
   タイトルスタイル
   =============================================== */
.page-title {
    margin-bottom: 1.5rem;
    color: #343a40;
    font-weight: 300;
    font-size: 2rem;
    text-align: center;
}

/* ===============================================
   フッタースタイル
   =============================================== */
.footer {
    background-color: #343a40;
    color: white;
    padding: 1.5rem 0;
    margin-top: 3rem;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    text-align: center;
}

/* ===============================================
   チャットスタイル
   =============================================== */
.chat-wrapper {
    max-width: 800px;
    margin: 70px auto 0;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 70px);
    overflow: hidden;
}

.chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid #dee2e6;
    background-color: #f8f9fa;
}

.chat-header h2 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 500;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background-color: #f5f7fa;
}

.chat-box {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    display: flex;
    margin-bottom: 2px;
}

.message-content {
    padding: 10px 14px;
    border-radius: 10px;
    max-width: 80%;
    word-wrap: break-word;
}

.user-message {
    justify-content: flex-end;
}

.user-message .message-content {
    background-color: #a2e87a;
    border-radius: 15px 15px 0 15px;
}

.ai-message {
    justify-content: flex-start;
}

.ai-message .message-content {
    background-color: #ffffff;
    border-radius: 15px 15px 15px 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.chat-input-form {
    display: flex;
    padding: 12px;
    background-color: #fff;
    border-top: 1px solid #dee2e6;
    align-items: center;
    gap: 8px;
}

#user-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
}

#user-input:focus {
    border-color: #4a6fdc;
    box-shadow: 0 0 0 3px rgba(74, 111, 220, 0.2);
}

.chat-input-form button {
    background-color: #4a6fdc;
    color: white;
    border: none;
    border-radius: 20px;
    padding: 10px 20px;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.3s, transform 0.1s;
}

.chat-input-form button:hover {
    background-color: #3a5fc8;
    transform: translateY(-1px);
}

.chat-input-form button:active {
    transform: translateY(1px);
}

/* ローディングアニメーション */
.loading-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    padding: 5px;
}

.loading-dots span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #aaa;
    border-radius: 50%;
    animation: loading 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes loading {
    0%, 80%, 100% { 
        transform: scale(0);
    } 
    40% { 
        transform: scale(1.0);
    }
}

/* ===============================================
   ログインページスタイル
   =============================================== */
.login-page {
    background-color: #f5f7fa;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 450px;
    text-align: center;
}

.login-header {
    margin-bottom: 2rem;
}

.logo-icon {
    font-size: 3rem;
    color: #4a6fdc;
    margin-bottom: 1rem;
}

.login-header h1 {
    color: #333;
    font-size: 1.8rem;
    font-weight: 600;
    margin: 0;
}

.login-card {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.login-card-header {
    background-color: #f8f9fa;
    padding: 1.5rem;
    border-bottom: 1px solid #dee2e6;
}

.login-card-header h2 {
    margin: 0;
    color: #333;
    font-size: 1.5rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.login-card-body {
    padding: 2rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    font-size: 0.95rem;
}

.alert-danger {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.password-input-wrapper {
    position: relative;
}

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    font-size: 1rem;
}

.toggle-password:hover {
    color: #4a6fdc;
}

.toggle-password:focus {
    outline: none;
}

.btn-login {
    background-color: #4a6fdc;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 12px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-login:hover {
    background-color: #3a5fc8;
    transform: translateY(-1px);
}

.btn-login:active {
    transform: translateY(1px);
}

.login-footer {
    color: #6c757d;
    font-size: 0.9rem;
}

/* ===============================================
   レスポンシブデザイン
   =============================================== */
@media (max-width: 768px) {
    /* ヘッダー */
    .header-container {
        flex-direction: row;
        padding: 0.5rem 1rem;
    }
    
    .brand {
        font-size: 1.2rem;
    }
    
    /* メインコンテナ */
    .container,
    .main-container {
        margin-top: 70px;
        padding: 15px;
    }
    
    /* カード */
    .card-body {
        padding: 1rem;
    }
    
    /* テーブル */
    .table th,
    .table td {
        padding: 0.5rem;
    }
    
    /* ボタン */
    .btn {
        padding: 0.6rem 1.2rem;
    }
    
    /* チャット */
    .chat-wrapper {
        margin: 60px 0 0;
        height: calc(100vh - 60px);
        border-radius: 0;
    }
    
    .chat-header {
        padding: 8px 12px;
    }
    
    .chat-header h2 {
        font-size: 1.1rem;
    }
    
    .message-content {
        padding: 8px 12px;
        max-width: 85%;
    }
    
    .chat-container {
        padding: 12px;
    }
    
    .chat-input-form {
        padding: 8px;
    }
    
    #user-input {
        padding: 8px 12px;
    }
    
    .chat-input-form button {
        padding: 8px 15px;
    }
    
    /* ログイン */
    .login-card-body {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    /* ヘッダー小さい画面用 */
    .brand-suffix {
        display: none;
    }
    
    .btn-text {
        display: none;
    }
    
    .user-info {
        gap: 0.5rem;
    }
    
    .logout-btn {
        padding: 0.4rem;
    }
    
    /* チャット */
    .message-content {
        padding: 6px 10px;
        max-width: 90%;
        font-size: 0.95rem;
    }
    
    .user-message .message-content {
        border-radius: 12px 12px 0 12px;
    }
    
    .ai-message .message-content {
        border-radius: 12px 12px 12px 0;
    }
    
    .chat-input-form button {
        padding: 8px;
    }
    
    /* ログイン */
    .login-header h1 {
        font-size: 1.5rem;
    }
    
    .login-card-header h2 {
        font-size: 1.3rem;
    }
}

@media (max-width: 360px) {
    /* 非常に小さい画面向けの調整 */
    .header-container {
        padding: 0.5rem;
    }
    
    .brand {
        font-size: 1rem;
    }
    
    .message-content {
        padding: 5px 8px;
        font-size: 0.9rem;
    }
    
    #user-input {
        padding: 6px 10px;
        font-size: 0.9rem;
    }
    
    .chat-input-form button {
        padding: 6px;
        font-size: 0.85rem;
    }
}


/* ===============================================
   チャットの箇条書き修正
   =============================================== */
.message-content {
    /* 箇条書きの余白を確保 */
    padding: 10px 14px 10px 20px; /* 左側の余白を増やす */
}

.message-content ul,
.message-content ol {
    margin: 0.5em 0 0.5em 1em; /* 左マージンを調整 */
    padding-left: 1em; /* 左パディングを調整 */
}

.message-content li {
    margin-bottom: 0.3em; /* リスト項目間のマージン */
    position: relative; /* 相対位置指定 */
}

/* 番号付きリストの番号がはみ出さないよう調整 */
.ai-message .message-content ol {
    counter-reset: item;
    list-style-type: none;
    padding-left: 0.5em;
}

.ai-message .message-content ol > li {
    counter-increment: item;
    padding-left: 1.5em; /* 数字用のスペース */
    position: relative;
    margin-bottom: 0.5em;
}

.ai-message .message-content ol > li::before {
    content: counter(item) ".";
    position: absolute;
    left: 0;
    width: 1.5em; /* 数字とピリオドのための幅 */
    text-align: left;
    color: inherit;
}

/* 通常の箇条書きも同様に調整 */
.ai-message .message-content ul {
    list-style-type: none;
    padding-left: 0.5em;
}

.ai-message .message-content ul > li {
    padding-left: 1.2em; /* ・用のスペース */
    position: relative;
}

.ai-message .message-content ul > li::before {
    content: "•";
    position: absolute;
    left: 0;
    width: 1.2em;
    text-align: left;
}

/* リスト内の入れ子リストの調整 */
.ai-message .message-content ul ul,
.ai-message .message-content ol ol,
.ai-message .message-content ul ol,
.ai-message .message-content ol ul {
    margin-top: 0.3em;
    margin-bottom: 0;
}

/* リスト内のコード、太字などの表示を調整 */
.ai-message .message-content li code,
.ai-message .message-content li strong,
.ai-message .message-content li em {
    display: inline;
}

/* スマホ表示での調整 */
@media (max-width: 480px) {
    .message-content {
        padding: 8px 10px 8px 16px; /* 左側余白を確保しつつ全体を小さく */
    }
    
    .ai-message .message-content ol > li {
        padding-left: 1.3em; /* 数字用のスペースを少し縮小 */
    }
    
    .ai-message .message-content ul > li {
        padding-left: 1em; /* ・用のスペースを少し縮小 */
    }
}


/* スクロールボタン用スタイル */
.scroll-to-bottom-btn {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #4a6fdc;
    color: white;
    border: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    opacity: 0.8;
    transition: opacity 0.3s;
}

.scroll-to-bottom-btn:hover {
    opacity: 1;
}