/* 
 * Inbox - シンプルなNotionライクUI
 * 白ベース / スレート / 差し色シアン
 */

:root {
    --white: #ffffff;
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;
    --cyan-500: #06b6d4;
    --cyan-600: #0891b2;
    --cyan-100: #cffafe;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--slate-800);
    background: var(--white);
}

/* アプリ全体のレイアウト */
.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* サイドバー */
.sidebar {
    width: 240px;
    background: var(--slate-50);
    border-right: 1px solid var(--slate-200);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--slate-200);
}

.sidebar-header h1 {
    font-size: 16px;
    font-weight: 600;
    color: var(--slate-800);
}

.btn-new {
    padding: 6px 12px;
    font-size: 13px;
    background: var(--white);
    border: 1px solid var(--slate-200);
    border-radius: 4px;
    color: var(--slate-600);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.btn-new:hover {
    background: var(--slate-100);
    border-color: var(--slate-300);
}

/* フィルタータブ */
.filter-tabs {
    display: flex;
    padding: 8px;
    gap: 4px;
    border-bottom: 1px solid var(--slate-200);
}

.filter-tab {
    flex: 1;
    padding: 6px 8px;
    font-size: 11px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--slate-500);
    cursor: pointer;
    transition: all 0.15s;
}

.filter-tab:hover {
    background: var(--slate-100);
}

.filter-tab.active {
    background: var(--white);
    border-color: var(--slate-200);
    color: var(--slate-700);
    font-weight: 500;
}

.document-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.document-item {
    padding: 10px 12px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: background 0.15s;
    position: relative;
}

.document-item:hover {
    background: var(--slate-100);
}

.document-item.active {
    background: var(--cyan-100);
}

.document-item-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.document-badge {
    width: 18px;
    height: 18px;
    background: var(--cyan-500);
    color: var(--white);
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.document-item.is-completed .document-title {
    color: var(--slate-400);
}

/* フィルターで非表示 */
.document-item.filter-hidden {
    display: none;
}

.document-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--slate-700);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.document-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.document-id {
    font-size: 10px;
    color: var(--slate-400);
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    background: var(--slate-100);
    padding: 1px 4px;
    border-radius: 2px;
}

.document-date {
    font-size: 11px;
    color: var(--slate-400);
}

.document-delete-btn {
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: var(--slate-400);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.document-item:hover .document-delete-btn {
    opacity: 1;
}

.document-delete-btn:hover {
    background: var(--slate-200);
    color: var(--slate-600);
}

/* メインコンテンツ */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* パネル共通 */
.input-panel,
.result-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.input-panel {
    border-right: 1px solid var(--slate-200);
    overflow-y: auto;
}

.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--slate-200);
}

.panel-header h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--slate-700);
}

/* カメラセクション */
.camera-section {
    padding: 16px 20px;
    border-bottom: 1px solid var(--slate-200);
    flex-shrink: 0;
}

.camera-container {
    background: var(--slate-100);
    border-radius: 4px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    max-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.camera-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.camera-controls {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* ボタン */
.btn {
    padding: 8px 16px;
    font-size: 13px;
    background: var(--white);
    border: 1px solid var(--slate-200);
    border-radius: 4px;
    color: var(--slate-600);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.btn:hover:not(:disabled) {
    background: var(--slate-50);
    border-color: var(--slate-300);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--cyan-500);
    border-color: var(--cyan-500);
    color: var(--white);
}

.btn-primary:hover:not(:disabled) {
    background: var(--cyan-600);
    border-color: var(--cyan-600);
}

.btn-large {
    padding: 12px 24px;
    font-size: 14px;
    width: 100%;
}

/* 撮影した画像一覧 */
.captured-images {
    padding: 12px 20px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--slate-200);
    min-height: 50px;
    flex-shrink: 0;
}

.captured-image {
    position: relative;
    width: 80px;
    height: 60px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--slate-200);
}

.captured-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
}

.captured-image .remove-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background: var(--slate-700);
    color: var(--white);
    border: none;
    border-radius: 50%;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.captured-image .remove-btn:hover {
    background: var(--slate-900);
}

/* テキスト入力セクション */
.text-input-section {
    padding: 16px 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100px;
}

.text-input-section textarea {
    flex: 1;
    width: 100%;
    padding: 12px;
    border: 1px solid var(--slate-200);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    min-height: 80px;
}

.text-input-section textarea:focus {
    outline: none;
    border-color: var(--cyan-500);
}

/* 送信セクション */
.submit-section {
    padding: 16px 20px;
    border-top: 1px solid var(--slate-200);
    flex-shrink: 0;
}

/* 結果表示パネル */
.result-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--slate-400);
}

.message {
    margin-bottom: 16px;
    max-width: 90%;
}

.message.user {
    margin-left: auto;
}

.message.assistant {
    margin-right: auto;
}

.message-content {
    padding: 12px 16px;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.6;
}

.message.user .message-content {
    background: var(--cyan-100);
    color: var(--slate-800);
}

.message.assistant .message-content {
    background: var(--slate-100);
    color: var(--slate-800);
}

.message-images {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.message-images img {
    width: 100px;
    height: 75px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--slate-200);
}

.message-time {
    font-size: 11px;
    color: var(--slate-400);
    margin-top: 4px;
}

/* チャット入力エリア */
.chat-input-area {
    padding: 16px 20px;
    border-top: 1px solid var(--slate-200);
    display: flex;
    gap: 8px;
}

.chat-input-area textarea {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--slate-200);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    min-height: 40px;
    max-height: 120px;
}

.chat-input-area textarea:focus {
    outline: none;
    border-color: var(--cyan-500);
}

/* ローディング */
.loading {
    display: inline-flex;
    gap: 4px;
    padding: 12px 16px;
}

.loading span {
    width: 6px;
    height: 6px;
    background: var(--slate-400);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading span:nth-child(1) { animation-delay: -0.32s; }
.loading span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* 結果表示ヘッダー */
.result-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--slate-200);
}

.result-doc-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--slate-800);
    margin: 0 0 4px 0;
}

.result-header-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.result-doc-id {
    font-size: 11px;
    color: var(--cyan-600);
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    background: var(--cyan-100);
    padding: 2px 6px;
    border-radius: 3px;
    cursor: pointer;
    user-select: all;
}

.result-doc-id:hover {
    background: var(--cyan-500);
    color: var(--white);
}

.result-doc-type {
    font-size: 12px;
    color: var(--slate-500);
}

/* YAML表示 */
.yaml-summary {
    font-size: 14px;
    color: var(--slate-700);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--slate-200);
}

.yaml-response {
    font-size: 14px;
    color: var(--slate-700);
    margin-bottom: 12px;
}

.yaml-questions {
    margin-top: 12px;
    padding: 12px;
    background: var(--slate-50);
    border-radius: 4px;
}

.yaml-questions .questions-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--slate-600);
    margin-bottom: 8px;
}

.yaml-questions ul {
    margin: 0;
    padding-left: 20px;
}

.yaml-questions li {
    font-size: 13px;
    color: var(--slate-600);
    margin-bottom: 4px;
}

.yaml-details {
    margin-top: 12px;
}

.yaml-details summary {
    font-size: 12px;
    color: var(--slate-400);
    cursor: pointer;
    user-select: none;
}

.yaml-details summary:hover {
    color: var(--slate-600);
}

.yaml-block {
    background: var(--slate-50);
    border: 1px solid var(--slate-200);
    border-radius: 4px;
    padding: 12px;
    margin-top: 8px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    font-size: 12px;
    white-space: pre-wrap;
    overflow-x: auto;
}

/* タスク表示 */
.task-list {
    margin-top: 12px;
}

.task-item {
    padding: 10px 12px;
    border: 1px solid var(--slate-200);
    border-radius: 4px;
    margin-bottom: 6px;
    background: var(--white);
}

.task-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.task-id {
    font-size: 11px;
    color: var(--cyan-600);
    font-weight: 600;
    flex-shrink: 0;
}

.task-title {
    font-size: 13px;
    color: var(--slate-700);
}

.task-category {
    font-size: 11px;
    padding: 2px 8px;
    background: var(--slate-100);
    flex-shrink: 0;
}

.task-category {
    color: var(--slate-600);
    border-radius: 10px;
    margin-left: auto;
}

.task-notes {
    font-size: 12px;
    color: var(--slate-500);
    margin-top: 6px;
    padding-top: 6px;
    padding-left: 32px;
    border-top: 1px dashed var(--slate-200);
}

/* タスクチェックボックス */
.task-checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}

.task-checkbox {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.task-checkbox-custom {
    width: 18px;
    height: 18px;
    border: 2px solid var(--slate-300);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    background: var(--white);
}

.task-checkbox-custom::after {
    content: '';
    width: 10px;
    height: 6px;
    border-left: 2px solid var(--white);
    border-bottom: 2px solid var(--white);
    transform: rotate(-45deg) scale(0);
    transition: transform 0.15s ease;
    margin-top: -2px;
}

.task-checkbox:checked + .task-checkbox-custom {
    background: var(--cyan-500);
    border-color: var(--cyan-500);
}

.task-checkbox:checked + .task-checkbox-custom::after {
    transform: rotate(-45deg) scale(1);
}

.task-checkbox-label:hover .task-checkbox-custom {
    border-color: var(--cyan-500);
}

/* 完了タスクのスタイル */
.task-item.task-completed {
    background: var(--slate-50);
    opacity: 0.7;
}

.task-item.task-completed .task-title {
    text-decoration: line-through;
    color: var(--slate-400);
}

.task-item.task-completed .task-notes {
    text-decoration: line-through;
    color: var(--slate-400);
}

/* 入力テキストセクション */
.input-text-section {
    margin: 12px 0;
    padding: 12px;
    background: var(--slate-50);
    border-radius: 4px;
}

.section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--slate-500);
    margin-bottom: 8px;
}

.input-text {
    font-size: 13px;
    color: var(--slate-600);
    white-space: pre-wrap;
}

/* 画像サムネイル */
.images-section {
    margin: 12px 0;
}

.image-thumbnails {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.thumbnail {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--slate-200);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.thumbnail:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* スクロールバー */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--slate-300);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--slate-400);
}

/* 画像プレビューモーダル */
.image-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.image-preview-modal.active {
    display: flex;
}

.image-preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    cursor: pointer;
}

.image-preview-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    z-index: 1;
}

.image-preview-content img {
    max-width: 100%;
    max-height: 90vh;
    display: block;
    border-radius: 4px;
}

.image-preview-close {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 32px;
    height: 32px;
    background: var(--white);
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--slate-600);
    transition: background 0.15s, color 0.15s;
}

.image-preview-close:hover {
    background: var(--slate-100);
    color: var(--slate-800);
}
