/* SAKE LOGs Chat - Main Styles */

html, body {
    height: 100%;
    overflow: hidden;
    color-scheme: only light;
}
* {
    forced-color-adjust: none;
}

/* ================================================
   ブランドカラー強制適用 (モバイル互換)
   Tailwindのカスタムカラーが解釈されない場合のフォールバック
   すべての色指定を !important で明示的に上書き
   ================================================ */
:root {
    --color-base: #e9dfe5;   /* 桜鼠色 */
    --color-main: #19448e;   /* 瑠璃紺 */
    --color-accent: #38b48b; /* 翡翠色 */
}

/* body */
body {
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    margin: 0;
    background-color: #e9dfe5 !important; /* bg-base */
    color: #19448e !important;            /* text-main */
}

/* ---- ヘッダー ---- */
#main-header {
    background-color: #19448e !important; /* bg-main */
    color: #ffffff !important;
}

/* ---- チャットコンテナ・メッセージエリア ---- */
#chat-container {
    background-color: #e9dfe5 !important; /* bg-base */
}
#chat-messages {
    background-color: #e9dfe5 !important; /* bg-base */
}
#input-area {
    background-color: #e9dfe5 !important; /* bg-base */
    border-top: 1px solid rgba(25, 68, 142, 0.1) !important;
}

/* ---- 一つ前に戻るボタン ---- */
/* #chat-messages の外・#input-area の直前に配置し、height:0 で高さ0のオーバーレイとして扱う */
#back-btn-row {
    position: relative;
    height: 0;
    overflow: visible;
    pointer-events: none;
    z-index: 5;
}
#back-btn-row.hidden { display: none !important; }
#back-step-btn, #reload-recording-btn {
    position: absolute;
    bottom: 8px;
    pointer-events: auto;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(25, 68, 142, 0.18);
    border: none;
    padding: 0;
    line-height: 1;
    font-size: 1.2rem;
    color: #19448e;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
#back-step-btn { right: 56px; padding-top: 2px; }
#reload-recording-btn { right: 12px; font-size: 1.5rem; padding-bottom: 2px; }

/* ---- 送信ボタン ---- */
#send-button {
    background-color: #19448e !important; /* bg-main */
    color: #e9dfe5 !important;            /* text-base */
    border: 2px solid #19448e !important;
}
#send-button:hover, #send-button:focus {
    background-color: #38b48b !important;
    color: #19448e !important;
    border-color: #38b48b !important;
}

/* ---- メッセージ入力欄 ---- */
#message-input {
    background-color: #ffffff !important;
    color: #19448e !important;
    border: 1px solid rgba(25, 68, 142, 0.2) !important;
}
#message-input::placeholder {
    color: rgba(25, 68, 142, 0.5) !important;
}

/* ---- 選択ボタン (JSで動的生成されるものも含む) ---- */
#button-input button {
    background-color: #19448e !important; /* bg-main */
    color: #e9dfe5 !important;            /* text-base */
    border: 2px solid #19448e !important;
}
#button-input button:hover,
#button-input button:active,
#button-input button:focus {
    background-color: #38b48b !important;
    color: #19448e !important;
    border-color: #38b48b !important;
}

/* ---- HOMEオーバーレイ ---- */
#home-overlay {
    background-color: #e9dfe5 !important; /* bg-base */
}
#home-title {
    color: #19448e !important;
}
.home-stats-container {
    background-color: #ffffff !important;
}
.home-stat-value {
    color: #38b48b !important; /* accent */
}

/* ---- ゲストモードヘッダー ---- */
#guest-mode-header {
    background-color: rgba(233, 223, 229, 0.7) !important;
    border-bottom-color: rgba(25, 68, 142, 0.15) !important;
    color: #19448e !important;
}

/* ---- 認証オーバーレイ背景 ---- */
#auth-overlay {
    background-color: rgba(25, 68, 142, 0.7) !important;
}

/* 認証オーバーレイ表示中はボトムナビを非表示 */
body:has(#auth-overlay:not(.hidden)) #bottom-nav {
    display: none !important;
}


#chat-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 672px; /* sm breakpoint in tailwind */
    height: 100%;
    margin: 0 auto;
    box-sizing: border-box;
    background-color: #e9dfe5; /* bg-base */
}
#chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1.5rem 1rem;
    scrollbar-width: thin;
    scrollbar-color: transparent #1F2937;
    transition: scrollbar-color 0.3s ease;
}

#chat-messages::-webkit-scrollbar {
    width: 8px;
}
#chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
#chat-messages::-webkit-scrollbar-thumb {
    background: #e5e7eb;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.3s ease, background 0.2s ease;
}
#chat-messages.scrolling::-webkit-scrollbar-thumb {
    opacity: 1;
}
#chat-messages.scrolling::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}
#chat-messages.scrolling {
    scrollbar-color: #4b5563 #1F2937;
}

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

.message {
    max-width: 85%;
    margin-bottom: 1rem;
    padding: 0.875rem 1.25rem;
    border-radius: 1.25rem;
    line-height: 1.6;
    width: fit-content;
    animation: fadeIn 0.2s ease-out forwards;
}
.bot-message {
    background-color: #f3f4f6 !important; /* light gray */
    color: #19448e !important; /* main */
    align-self: flex-start;
    border-bottom-left-radius: 0.5rem;
    white-space: pre-wrap;
}
.user-message {
    background-color: #38b48b !important; /* accent */
    color: #ffffff !important;
    align-self: flex-end;
    border-bottom-right-radius: 0.5rem;
}

.record-wrapper {
    background-color: #e8ecef !important; /* 白花色 */
    border: 1px solid rgba(25, 68, 142, 0.2) !important;
    color: #19448e !important; /* 瑠璃紺 */
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    animation: fadeIn 0.2s ease-out forwards;
}
.record-image {
    width: 100%;
    height: auto;
    max-height: 250px;
    object-fit: cover;
    border-radius: 0.5rem;
    margin-bottom: 0.75rem;
    background-color: #f3f4f6;
}

#button-input.horizontal { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; }
#button-input.vertical {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
}
#button-input button {
    line-height: 1.5rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    height: 2.5rem;
    transition: background-color 0.15s, transform 0.08s, color 0.15s, border-color 0.15s;
    background-color: #19448e; /* main: 瑠璃紺 */
    color: #e9dfe5; /* base: 桜鼠色 */
    border: 2px solid #19448e;
    border-radius: 0.5rem;
    font-weight: 600;
}
#button-input button:hover, #button-input button:focus {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    background-color: #38b48b; /* accent: 翡翠色 */
    color: #19448e; /* main */
    border-color: #38b48b;
}
#button-input button:active {
    transform: translateY(0);
}

.rating-stars { display: flex; gap: 0.25rem; cursor: pointer; }
.rating-stars svg { width: 2rem; height: 2rem; color: #6b7280; transition: color 0.15s; }
.rating-stars svg.selected, .rating-stars svg:hover { color: #f59e0b; }
.rating-stars:hover svg { color: #f59e0b; }
.rating-stars svg:hover ~ svg { color: #6b7280; }

#image-selection-container {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    animation: fadeIn 0.2s ease-out forwards;
}
#image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
    width: 100%;
}
.suggestion-image {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 0.5rem;
    cursor: pointer;
    border: 3px solid transparent;
    transition: border-color 0.15s, transform 0.15s;
    background-color: #f3f4f6;
}
.suggestion-image:hover {
    transform: scale(1.05);
}
.suggestion-image.selected {
    border-color: #19448e;
    box-shadow: 0 0 15px rgba(25, 68, 142, 0.4);
}

.auth-button {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: background-color 0.15s;
}
.login-button {
    background-color: #2563eb;
    color: white;
}
.logout-button {
    background-color: #dc2626;
    color: white;
}

.auth-input {
    background-color: #ffffff;
    border: 1px solid #d1d5db;
    color: #19448e; /* main */
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    width: 100%;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-input:focus {
    outline: none;
    border-color: #38b48b; /* accent */
    box-shadow: 0 0 0 2px rgba(56, 180, 139, 0.2);
}
.auth-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #19448e; /* main */
}

.loading-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    z-index: 10;
}
.spinner {
    border: 4px solid #4b5563;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.loading-text {
    margin-top: 1rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: #19448e;
}

.tab-button {
    transition: color 0.3s ease;
    position: relative;
    z-index: 1;
}

.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
    opacity: 0;
}
.collapsible-content.open {
    max-height: 1200px;
    opacity: 1;
    overflow-y: auto;
}
.chevron-icon {
    transition: transform 0.3s ease-out;
}

/* Bottom Navigation */
#bottom-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background-color: #ffffff !important;
    border-top: 1px solid rgba(25, 68, 142, 0.1) !important;
    padding: 0.5rem 0;
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    height: 4.5rem;
    width: 100%;
    max-width: 672px;
    box-sizing: border-box;
}
/* ボトムナビが .hidden クラスを持つ場合は強制非表示（IDセレクタ詳細度対策）*/
#bottom-nav.hidden {
    display: none !important;
}
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #9ca3af !important; /* inactive gray */
    font-size: 0.75rem;
    cursor: pointer;
    transition: color 0.2s;
    flex: 1;
}
.nav-item:hover, .nav-item.active {
    color: #38b48b !important; /* accent */
}
.nav-icon {
    width: 1.5rem;
    height: 1.5rem;
    margin-bottom: 0.25rem;
}

/* =====================================================
   キーボード展開時のレイアウト調整
   body.keyboard-open は物理キーボード開放時のみ JS が付加する
   ===================================================== */
body.keyboard-open {
    overflow: hidden !important;
}
body.keyboard-open #chat-container {
    padding-bottom: 0 !important;
}
body.keyboard-open:has(#chat-messages:not(.hidden)) #bottom-nav {
    display: none !important;
}

/* Home Overlay */
#home-overlay {
    position: fixed;
    inset: 0;
    left: 50%;
    transform: translateX(-50%);
    bottom: 4.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #e9dfe5; /* base */
    z-index: 40;
    padding: 2rem;
    text-align: center;
    width: 100%;
    max-width: 672px;
    box-sizing: border-box;
}
#home-overlay.hidden {
    display: none !important;
}

/* Settings Overlay (Fullscreen like Home) */
#settings-overlay {
    position: fixed !important;
    inset: 0 !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    bottom: 4.5rem !important; /* ボトムナビの高さ分 */
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    background-color: #e9dfe5 !important; /* bg-base */
    z-index: 40 !important;
    width: 100% !important;
    max-width: 672px !important;
    box-sizing: border-box !important;
    padding: 0 !important;
}
#settings-overlay.hidden {
    display: none !important;
}
#settings-overlay > div {
    width: 100% !important;
    max-width: 672px !important;
    height: 100% !important;
    background-color: #e9dfe5 !important;
    padding: 1.5rem !important;
    overflow-y: auto !important;
    box-shadow: none !important;
}
#home-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: #19448e; /* main */
    margin-bottom: 2rem;
    letter-spacing: -0.025em;
}
.home-stats-container {
    background-color: #ffffff;
    border: 1px solid rgba(25, 68, 142, 0.2);
    border-radius: 1rem;
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}
.home-stats-title {
    font-size: 0.875rem;
    color: #19448e;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.home-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}
.home-stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.home-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #38b48b !important; /* accent */
}
.home-stat-label {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

/* Home Stats - Drilldown Subcategories */
.home-stat-clickable {
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}
.home-stat-clickable:hover {
    background-color: rgba(56, 180, 139, 0.1);
    border-radius: 0.5rem;
}
.home-stat-clickable:active {
    transform: scale(0.97);
}
.home-sub-stats {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
    width: 100%;
    margin-top: 0;
}
.home-sub-stats.open {
    max-height: 300px;
    opacity: 1;
    margin-top: 0.5rem;
}
.home-sub-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    color: #4b5563;
    border-top: 1px solid rgba(25, 68, 142, 0.1);
}
.home-sub-stat:first-child {
    border-top: none;
}
.home-sub-stat-label {
    color: #4b5563;
}
.home-sub-stat-value {
    color: #38b48b !important;
    font-weight: 600;
}

/* ---- 審査中画面 (仮登録完了) のテキスト配色 ---- */
#register-review-view h3 {
    color: #19448e !important;
}
#register-review-view p {
    color: rgba(25, 68, 142, 0.8) !important;
}
#register-review-view span:not(.text-amber-600):not(.animate-ping) {
    color: rgba(25, 68, 142, 0.8) !important;
}
#register-review-view #review-user-email {
    color: #19448e !important;
}
#register-review-view .bg-gray-50 {
    background-color: #f8fafc !important; /* よりクリーンな明るい背景 */
}
#register-review-view .border-gray-200 {
    border-color: rgba(25, 68, 142, 0.15) !important;
}

