/**
 * LINE風チャットモーダル - 共通CSS (form.css完全独立版)
 * 
 * @file CONFIG/css_v2/line_chat.css
 * @description 全ページで使用可能なLINE風チャットモーダルのスタイル
 * @version 1.2.0
 * @created 2025-11-09
 * @updated 2025-11-09 - 右スライドインサイドバー追加
 */

/* ========================================
   LINE Chat Sidebar (Slide-in from Right)
   ======================================== */
.line-chat-sidebar {
    position: fixed;
    top: 0;
    right: -500px;
    width: 480px;
    max-width: 100vw;
    height: 100vh;
    background: white;
    box-shadow: -2px 0 15px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    transition: right 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.line-chat-sidebar.open {
    right: 0;
}

.line-chat-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.line-chat-sidebar-overlay.show {
    display: block;
    opacity: 1;
}

.line-chat-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #06C755 0%, #00B900 100%);
    color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.line-chat-sidebar-header h2 {
    margin: 0;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.line-chat-sidebar-close {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.line-chat-sidebar-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.line-chat-sidebar-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* サイドバー内の line-chat-page スタイル調整 */
.line-chat-sidebar-content .line-chat-page {
    width: 100%;
    max-width: none;
    height: 100%;
    border-radius: 0;
    box-shadow: none;
}

/* サイドバー内の入力欄を左寄せ */
.line-chat-sidebar-content .line-chat-input-container {
    position: relative;
    left: 0;
    transform: none;
    width: 100%;
    max-width: none;
}

/* サイドバー内のメッセージエリア */
.line-chat-sidebar-content .line-chat-messages {
    width: 100%;
    max-width: none;
}

/* サイドバー内のヘッダー（重複するので非表示） */
.line-chat-sidebar-content .line-chat-header {
    display: none;
}

@media (max-width: 768px) {
    /* モバイルではサイドバーを使用しない（別ページ遷移） */
    .line-chat-sidebar,
    .line-chat-sidebar-overlay {
        display: none !important;
    }
}

/* ========================================
   スコープ化リセット（form.cssの影響を完全排除）
   ======================================== */
#line-chat-modal *,
#line-chat-modal *::before,
#line-chat-modal *::after {
    box-sizing: border-box;
}

/* form.cssのデフォルトmargin/paddingを上書き */
#line-chat-modal div,
#line-chat-modal button,
#line-chat-modal textarea {
    margin: 0;
    padding: 0;
}

/* フォント設定 */
#line-chat-modal,
#line-chat-modal * {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
}

/* ========================================
   モーダル全体
   ======================================== */
#line-chat-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 99999;
    align-items: center;
}

#line-chat-modal .line-chat-container {
    width: 100%;
    max-width: 430px;
    height: 100vh;
    height: 100dvh; /* Dynamic Viewport Height（新しいブラウザ対応） */
    background: #f7f7f7;
    display: flex;
    flex-direction: column;
    position: relative;
    border-radius: 0;
    overflow: hidden;
    box-sizing: border-box;
    margin: 0;
}

/* ========================================
   ヘッダー
   ======================================== */
#line-chat-modal .line-chat-header {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    color: white;
    padding: 12px 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    min-height: 60px;
}

#line-chat-modal .line-chat-back-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 20px;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    transition: background 0.2s;
}

#line-chat-modal .line-chat-back-btn:hover {
    background: rgba(255,255,255,0.15);
}

#line-chat-modal .line-chat-avatar {
    width: 42px;
    height: 42px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #06b6d4;
    flex-shrink: 0;
}

#line-chat-modal .line-chat-header-info {
    flex: 1;
    min-width: 0;
}

#line-chat-modal .line-chat-header-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    color: white;
}

#line-chat-modal .line-chat-header-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 5px;
    color: white;
}

#line-chat-modal .line-chat-header-status i.fa-circle {
    color: #10b981;
    font-size: 8px;
}

#line-chat-modal .line-chat-menu-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 18px;
    padding: 8px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

#line-chat-modal .line-chat-menu-btn:hover {
    background: rgba(255,255,255,0.15);
}

/* ========================================
   メッセージエリア
   ======================================== */
#line-chat-modal .line-chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 15px;
    padding-bottom: 120px; /* 入力エリア（60px）＋余裕（60px） */
    background: #e5ddd5;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* 日付区切り */
#line-chat-modal .line-date-divider {
    text-align: center;
    margin: 20px 0;
}

#line-chat-modal .line-date-divider-text {
    display: inline-block;
    background: rgba(0,0,0,0.08);
    color: #666;
    padding: 6px 16px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

/* メッセージグループ */
#line-chat-modal .line-message-group {
    margin-bottom: 12px;
    display: flex;
    gap: 8px;
    animation: fadeInUp 0.3s ease-out;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    align-items: flex-end;
}

#line-chat-modal .line-message-group > div {
    max-width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* メッセージアバター */
#line-chat-modal .line-message-avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #06b6d4;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

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

#line-chat-modal .line-message-group.received {
    justify-content: flex-start;
}

#line-chat-modal .line-message-group.received > div {
    max-width: calc(85% - 48px); /* 85% - (アバター40px + gap8px) */
    align-items: flex-start;
    overflow: hidden;
}

#line-chat-modal .line-message-group.sent {
    justify-content: flex-end;
}

#line-chat-modal .line-message-group.sent > div {
    max-width: 85%;
    align-items: flex-end;
    overflow: hidden;
}

/* 送信者名 */
#line-chat-modal .line-message-sender {
    font-size: 11px;
    color: #666;
    margin-bottom: 4px;
    font-weight: 600;
    padding-left: 2px;
}

/* メッセージ吹き出し */
#line-chat-modal .line-message-bubble {
    max-width: 100%;
    width: 100%;
    padding: 11px 15px;
    border-radius: 18px;
    word-wrap: break-word;
    word-break: break-all;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    font-size: 15px;
    line-height: 1.5;
    position: relative;
    display: block;
    box-sizing: border-box;
    overflow: hidden;
}

#line-chat-modal .line-message-group.received .line-message-bubble {
    background: white;
    color: #1a1a1a;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

#line-chat-modal .line-message-group.sent .line-message-bubble {
    background: #dcf8c6;
    color: #1a1a1a;
    border-bottom-right-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

/* 時刻表示 */
#line-chat-modal .line-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

#line-chat-modal .line-message-group.received .line-message-time {
    justify-content: flex-start;
}

#line-chat-modal .line-message-group.sent .line-message-time {
    justify-content: flex-end;
}

/* ========================================
   入力エリア
   ======================================== */
#line-chat-modal .line-chat-input-container {
    background: #f7f7f7;
    padding: 12px 15px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    align-items: flex-end;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 430px;
    margin: 0 auto;
    z-index: 101;
    box-sizing: border-box;
    min-height: 60px;
}

#line-chat-modal .line-chat-attach-btn {
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    color: #666;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
    transition: background 0.2s;
}

#line-chat-modal .line-chat-attach-btn:hover {
    background: rgba(0,0,0,0.05);
}

#line-chat-modal .line-chat-input {
    flex: 1;
    min-height: 36px;
    max-height: 100px;
    padding: 8px 16px;
    border: 1px solid #d0d0d0;
    border-radius: 18px;
    font-size: 15px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    resize: none;
    outline: none;
    background: white;
    transition: border-color 0.2s;
}

#line-chat-modal .line-chat-input:focus {
    border-color: #06b6d4;
}

#line-chat-modal .line-chat-send-btn {
    width: 36px;
    height: 36px;
    background: #06b6d4;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    transition: all 0.2s;
}

#line-chat-modal .line-chat-send-btn:hover:not(:disabled) {
    background: #0891b2;
    transform: scale(1.05);
}

#line-chat-modal .line-chat-send-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

/* ========================================
   ローディング
   ======================================== */
#line-chat-modal .line-loading-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   スクロールバー
   ======================================== */
#line-chat-modal .line-chat-messages::-webkit-scrollbar {
    width: 8px;
}

#line-chat-modal .line-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#line-chat-modal .line-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.2);
    border-radius: 4px;
}

#line-chat-modal .line-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.3);
}

/* ========================================
   LINE Chat 専用ページ（line_chat.php）
   ======================================== */

/* ページ全体の背景 */
body.line-chat-body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
    background: #1a1a1a;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

/* チャットページコンテナ */
.line-chat-page {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    max-width: 430px;
    margin: 0 auto;
    background: #f0f0f0;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

/* ヘッダー（ページ版） */
.line-chat-page .line-chat-header {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    color: white;
    padding: 12px 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    min-height: 60px;
}

.line-chat-page .line-chat-back-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 20px;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    transition: background 0.2s;
    text-decoration: none;
}

.line-chat-page .line-chat-back-btn:hover {
    background: rgba(255,255,255,0.15);
}

.line-chat-page .line-chat-avatar {
    width: 42px;
    height: 42px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #06b6d4;
    flex-shrink: 0;
}

.line-chat-page .line-chat-header-info {
    flex: 1;
    min-width: 0;
}

.line-chat-page .line-chat-header-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: white;
}

.line-chat-page .line-chat-header-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 5px;
    color: white;
}

.line-chat-page .line-chat-header-status i.fa-circle {
    color: #10b981;
    font-size: 8px;
}

/* メッセージエリア（ページ版） */
.line-chat-page .line-chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 15px;
    padding-bottom: 120px;
    background: #e5ddd5;
    -webkit-overflow-scrolling: touch;
}

/* 入力エリア（ページ版） */
.line-chat-page .line-chat-input-container {
    background: white;
    padding: 12px 15px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    border-top: 1px solid #d0d0d0;
    display: flex;
    gap: 10px;
    align-items: flex-end;
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 430px;
    z-index: 100;
    box-sizing: border-box;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
}

.line-chat-page .line-chat-attach-btn {
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    color: #666;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.line-chat-page .line-chat-attach-btn:hover {
    background: rgba(0,0,0,0.05);
}

.line-chat-page .line-chat-input {
    flex: 1;
    min-height: 36px;
    max-height: 100px;
    padding: 8px 16px;
    border: 1px solid #d0d0d0;
    border-radius: 18px;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    outline: none;
    background: white;
    transition: border-color 0.2s;
}

.line-chat-page .line-chat-input:focus {
    border-color: #06b6d4;
}

.line-chat-page .line-chat-send-btn {
    width: 36px;
    height: 36px;
    background: #06b6d4;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
}

.line-chat-page .line-chat-send-btn:hover:not(:disabled) {
    background: #0891b2;
    transform: scale(1.05);
}

.line-chat-page .line-chat-send-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

.line-chat-page .line-loading-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

/* メッセージ要素（ページ版でCSSクラスを使用） */
.line-chat-page .line-date-divider {
    text-align: center;
    margin: 20px 0;
}

.line-chat-page .line-date-divider-text {
    display: inline-block;
    background: rgba(0,0,0,0.08);
    color: #666;
    padding: 6px 16px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.line-chat-page .line-message-group {
    margin-bottom: 12px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.line-chat-page .line-message-group.received {
    justify-content: flex-start;
}

.line-chat-page .line-message-group.sent {
    justify-content: flex-end;
}

.line-chat-page .line-message-avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #06b6d4;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.line-chat-page .line-message-content {
    max-width: 100%;
    display: flex;
    flex-direction: column;
}

.line-chat-page .line-message-group.received .line-message-content {
    max-width: calc(85% - 48px);
}

.line-chat-page .line-message-group.sent .line-message-content {
    max-width: 85%;
}

.line-chat-page .line-message-sender {
    font-size: 11px;
    color: #666;
    margin-bottom: 4px;
    font-weight: 600;
}

.line-chat-page .line-message-bubble {
    padding: 11px 15px;
    border-radius: 18px;
    word-break: break-all;
    white-space: pre-wrap;
    font-size: 15px;
    line-height: 1.5;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.line-chat-page .line-message-group.received .line-message-bubble {
    background: white;
    color: #1a1a1a;
    border-bottom-left-radius: 4px;
}

.line-chat-page .line-message-group.sent .line-message-bubble {
    background: #dcf8c6;
    color: #1a1a1a;
    border-bottom-right-radius: 4px;
}

.line-chat-page .line-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    display: flex;
    gap: 4px;
}

.line-chat-page .line-message-group.received .line-message-time {
    justify-content: flex-start;
}

.line-chat-page .line-message-group.sent .line-message-time {
    justify-content: flex-end;
}

