/* Claude Code Web UI — Custom styles */

/* ── Base ─────────────────────────────────────────── */

* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ── Typing indicator ─────────────────────────────── */

.typing-indicator { display: flex; gap: 3px; align-items: center; }
.typing-indicator span {
    width: 4px; height: 4px; border-radius: 50%;
    background: #d97706; animation: typing 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* ── Prose overrides for markdown ─────────────────── */

.prose {
    --tw-prose-body: #d1d5db;
    --tw-prose-headings: #f3f4f6;
    --tw-prose-links: #d97706;
    --tw-prose-bold: #f3f4f6;
    --tw-prose-code: #e5e7eb;
    --tw-prose-pre-bg: #0f0f23;
    --tw-prose-pre-code: #d1d5db;
}

.prose pre {
    background: #0d1117 !important;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    padding-top: 2rem;
    overflow-x: auto;
    font-size: 0.75rem;
    line-height: 1.5;
    position: relative;
}

.prose code {
    font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
    font-size: 0.8em;
}

.prose :not(pre) > code {
    background: rgba(255,255,255,0.06);
    padding: 0.15em 0.35em;
    border-radius: 0.25rem;
    font-weight: normal;
}

.prose p { margin-top: 0.5em; margin-bottom: 0.5em; }
.prose h1, .prose h2, .prose h3 { margin-top: 1em; margin-bottom: 0.5em; }
.prose ul, .prose ol { margin-top: 0.5em; margin-bottom: 0.5em; padding-left: 1.5em; }
.prose li { margin-top: 0.15em; margin-bottom: 0.15em; }
.prose a { text-decoration: underline; text-underline-offset: 2px; }
.prose table { font-size: 0.8rem; width: 100%; }
.prose th, .prose td { padding: 0.35rem 0.5rem; border-bottom: 1px solid rgba(255,255,255,0.06); }
.prose blockquote { border-left: 3px solid #d97706; padding-left: 1em; color: #9ca3af; font-style: italic; }

/* ── Copy code button ────────────────────────────── */

.copy-code-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    color: #9ca3af;
    font-size: 0;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
    z-index: 2;
}

pre:hover .copy-code-btn { opacity: 1; }
.copy-code-btn:hover { background: rgba(255,255,255,0.12); color: #e5e7eb; }

.copy-code-lang {
    font-size: 10px;
    font-family: 'JetBrains Mono', monospace;
    text-transform: uppercase;
    opacity: 0.6;
}

/* ── Message action buttons ──────────────────────── */

.msg-action-btn {
    padding: 4px;
    border-radius: 6px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s;
    background: transparent;
    border: none;
}

.msg-action-btn:hover {
    background: rgba(255,255,255,0.08);
    color: #d1d5db;
}

/* Touch devices: always show actions */
@media (hover: none) {
    .msg-actions { opacity: 1 !important; }
    .copy-code-btn { opacity: 1 !important; }
    .session-delete-btn { opacity: 1 !important; }
}

/* ── Tool cards ───────────────────────────────────── */

.tool-card { animation: slideIn 0.2s ease-out; }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-8px); }
    to { opacity: 1; transform: none; }
}

/* ── Input ────────────────────────────────────────── */

#prompt-input {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    line-height: 1.4;
}

#prompt-input:focus {
    box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.15);
}

/* ── Messages fade-in ─────────────────────────────── */

.assistant-msg,
.flex.justify-end {
    animation: msgFadeIn 0.2s ease-out;
}

@keyframes msgFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

/* ── File viewer ──────────────────────────────────── */

#file-viewer pre { margin: 0; background: transparent !important; border: none !important; padding: 0 !important; }
#file-viewer code { font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace; font-size: 0.75rem; line-height: 1.6; }

/* ── Drop zone ────────────────────────────────────── */

.drop-zone-active {
    outline: 2px dashed #d97706;
    outline-offset: -4px;
    background: rgba(217, 119, 6, 0.05) !important;
}

/* ── Toast notifications ──────────────────────────── */

.toast-msg { animation: toastIn 0.2s ease-out; }
.toast-fade-out { opacity: 0; transform: translateY(8px); transition: all 0.3s ease; }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

/* ── Session list ─────────────────────────────────── */

.session-item { transition: background-color 0.15s; }

/* ── Mobile optimizations ─────────────────────────── */

@media (max-width: 1023px) {
    #sidebar.fixed {
        width: 280px;
        background: #0f0f23;
        box-shadow: 4px 0 24px rgba(0,0,0,0.5);
    }
    #file-viewer { display: none !important; }
}

/* ── Safe area for notched phones ─────────────────── */

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    body { padding-bottom: env(safe-area-inset-bottom); }
}

/* ── Modal animation ─────────────────────────────── */

.modal-animate { animation: modalIn 0.2s ease-out; }

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(8px); }
    to { opacity: 1; transform: none; }
}

#approval-modal,
#settings-panel {
    backdrop-filter: blur(4px);
}

/* ── Command Palette ──────────────────────────────── */

#command-palette { backdrop-filter: blur(4px); }

.cmd-item { border-left: 2px solid transparent; }
.cmd-item.bg-amber-600\/15,
.cmd-item:hover { border-left-color: #d97706; }

#cmd-results::-webkit-scrollbar { width: 4px; }

/* ── Quick action buttons ────────────────────────── */

.quick-action-btn:active {
    transform: scale(0.97);
}

/* ── Scroll toggle pulse ─────────────────────────── */

#scroll-toggle {
    animation: scrollPulse 2s ease-in-out infinite;
}

@keyframes scrollPulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* ── Diff viewer ─────────────────────────────────── */

.diff-block { font-size: 0.72rem !important; }
.diff-add { color: #4ade80; background: rgba(74,222,128,0.08); display: inline-block; width: 100%; }
.diff-del { color: #f87171; background: rgba(248,113,113,0.08); display: inline-block; width: 100%; }
.diff-hunk { color: #60a5fa; font-weight: 600; }
.diff-meta { color: #94a3b8; font-style: italic; }

/* ── Cost dashboard ──────────────────────────────── */

.cost-bar { transition: height 0.3s ease; }
.cost-bar:hover { opacity: 0.8; }

/* ── File editor ─────────────────────────────────── */

#file-editor-textarea {
    font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
    font-size: 0.75rem;
    line-height: 1.6;
    tab-size: 4;
    resize: none;
}

/* ── Session tags ────────────────────────────────── */

.session-tag {
    display: inline-flex;
    align-items: center;
    padding: 0 5px;
    height: 14px;
    border-radius: 7px;
    font-size: 9px;
    font-weight: 600;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    flex-shrink: 0;
}

.tag-bug { background: rgba(248,113,113,0.15); color: #f87171; }
.tag-feature { background: rgba(74,222,128,0.15); color: #4ade80; }
.tag-refactor { background: rgba(96,165,250,0.15); color: #60a5fa; }
.tag-docs { background: rgba(192,132,252,0.15); color: #c084fc; }
.tag-test { background: rgba(250,204,21,0.15); color: #facc15; }
.tag-wip { background: rgba(251,146,60,0.15); color: #fb923c; }

.tag-picker {
    position: fixed;
    z-index: 60;
    min-width: 140px;
    padding: 4px;
    background: #1a1a2e;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
    animation: modalIn 0.12s ease-out;
}

.tag-picker-item {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 6px 10px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #d1d5db;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.1s;
    text-align: left;
}

.tag-picker-item:hover { background: rgba(255,255,255,0.06); }
.tag-picker-item .tag-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ── Theme toggle ────────────────────────────────── */

.theme-toggle-btn {
    position: relative;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.theme-toggle-btn:hover { background: rgba(255,255,255,0.06); color: #e5e7eb; }

/* ── Light theme ─────────────────────────────────── */

html.light body {
    background: #f5f5f7;
    color: #1a1a2e;
}

html.light header {
    background: #ffffff;
    border-color: #e5e7eb;
}

html.light #sidebar {
    background: #ffffff;
    border-color: #e5e7eb;
}

html.light .session-item.hover\:bg-gray-800:hover,
html.light .session-item [class*="hover:bg-gray-800"]:hover {
    background: rgba(0,0,0,0.04) !important;
}

html.light #messages {
    background: #f5f5f7;
}

html.light .bg-surface-900,
html.light .bg-surface-950 {
    background: #ffffff !important;
}

html.light .border-gray-800 {
    border-color: #e5e7eb !important;
}

html.light .bg-gray-800 {
    background: #f3f4f6 !important;
}

html.light .bg-gray-800\/50 {
    background: rgba(243,244,246,0.7) !important;
}

html.light .text-gray-100 {
    color: #1f2937 !important;
}

html.light .text-gray-200 {
    color: #374151 !important;
}

html.light .text-gray-300 {
    color: #4b5563 !important;
}

html.light .text-gray-400 {
    color: #6b7280 !important;
}

html.light .text-gray-500 {
    color: #9ca3af !important;
}

html.light .text-gray-600 {
    color: #9ca3af !important;
}

html.light .text-white {
    color: #1a1a2e !important;
}

html.light .hover\:bg-gray-800:hover {
    background: rgba(0,0,0,0.05) !important;
}

html.light #prompt-input {
    background: #ffffff !important;
    border-color: #d1d5db !important;
    color: #1f2937 !important;
}

html.light #prompt-input::placeholder {
    color: #9ca3af;
}

html.light .prose pre {
    background: #f8f9fa !important;
    border-color: #e5e7eb !important;
}

html.light .prose code {
    color: #1f2937;
}

html.light .prose :not(pre) > code {
    background: rgba(0,0,0,0.06);
}

html.light .prose {
    --tw-prose-body: #374151;
    --tw-prose-headings: #1f2937;
    --tw-prose-code: #1f2937;
    --tw-prose-pre-code: #374151;
}

html.light .assistant-msg {
    background: #ffffff;
    border-color: #e5e7eb;
}

html.light .copy-code-btn {
    background: rgba(0,0,0,0.05);
    border-color: rgba(0,0,0,0.1);
    color: #6b7280;
}

html.light .copy-code-btn:hover {
    background: rgba(0,0,0,0.1);
    color: #374151;
}

html.light .msg-action-btn { color: #9ca3af; }
html.light .msg-action-btn:hover { background: rgba(0,0,0,0.06); color: #4b5563; }

html.light .tag-picker {
    background: #ffffff;
    border-color: #e5e7eb;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

html.light .tag-picker-item:hover { background: rgba(0,0,0,0.04); }

html.light .theme-toggle-btn { color: #6b7280; }
html.light .theme-toggle-btn:hover { background: rgba(0,0,0,0.06); color: #374151; }

html.light .quick-action-btn {
    background: #ffffff !important;
    border-color: #e5e7eb !important;
}

html.light .quick-action-btn:hover {
    background: #f9fafb !important;
}

html.light .cmd-item:hover,
html.light .cmd-item.bg-amber-600\/15 {
    background: rgba(217,119,6,0.06) !important;
}

html.light #scroll-toggle {
    background: rgba(255,255,255,0.9) !important;
    border-color: #e5e7eb !important;
    color: #6b7280;
}

html.light select {
    background: #f3f4f6 !important;
    border-color: #d1d5db !important;
    color: #374151 !important;
}

html.light .tool-card {
    border-color: #e5e7eb !important;
}

html.light *::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); }
html.light * { scrollbar-color: rgba(0,0,0,0.15) transparent; }

@media (max-width: 1023px) {
    html.light #sidebar.fixed {
        background: #ffffff;
        box-shadow: 4px 0 24px rgba(0,0,0,0.1);
    }
}

/* ── Voice recording ─────────────────────────────── */

.mic-recording {
    animation: micPulse 1s ease-in-out infinite;
}

@keyframes micPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* ── Slash Command Autocomplete ──────────────────── */

#slash-autocomplete {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    margin-bottom: 4px;
    background: #1a1a2e;
    border: 1px solid #374151;
    border-radius: 12px;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.4);
    max-height: 320px;
    overflow-y: auto;
    z-index: 30;
    scrollbar-width: thin;
}

html.light #slash-autocomplete {
    background: #ffffff;
    border-color: #e5e7eb;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.1);
}

.slash-ac-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    padding: 8px 14px;
    font-size: 13px;
    color: #9ca3af;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
}

.slash-ac-item:first-child { border-radius: 12px 12px 0 0; }
.slash-ac-item:last-child { border-radius: 0 0 12px 12px; }
.slash-ac-item:only-child { border-radius: 12px; }

.slash-ac-item:hover,
.slash-ac-item.slash-ac-active {
    background: rgba(217, 119, 6, 0.12);
    color: #f59e0b;
}

html.light .slash-ac-item { color: #6b7280; }
html.light .slash-ac-item:hover,
html.light .slash-ac-item.slash-ac-active {
    background: rgba(217, 119, 6, 0.08);
    color: #b45309;
}

.slash-ac-icon {
    font-size: 14px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.slash-ac-name {
    font-weight: 600;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: #d1d5db;
    flex-shrink: 0;
}

html.light .slash-ac-name { color: #1f2937; }

.slash-ac-active .slash-ac-name { color: #fbbf24; }
html.light .slash-ac-active .slash-ac-name { color: #92400e; }

.slash-ac-args {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    color: #6b7280;
    flex-shrink: 0;
}

.slash-ac-desc {
    font-size: 11px;
    color: #6b7280;
    margin-left: auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── System message (command output) ────────────── */

.system-msg {
    font-size: 13px;
    line-height: 1.6;
}

.system-msg p { margin: 0.25em 0; }
.system-msg strong { color: #d1d5db; }
html.light .system-msg strong { color: #1f2937; }

.system-msg code {
    background: rgba(0,0,0,0.25);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12px;
    color: #fbbf24;
}

html.light .system-msg code {
    background: rgba(0,0,0,0.06);
    color: #92400e;
}

.system-msg pre {
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    padding: 10px 14px;
    overflow-x: auto;
    margin: 8px 0;
}

html.light .system-msg pre {
    background: rgba(0,0,0,0.04);
}

.system-msg pre code {
    background: transparent;
    padding: 0;
    color: #d1d5db;
    font-size: 12px;
}

html.light .system-msg pre code { color: #374151; }

/* ── Multi-panel Tab bar ─────────────────────────── */

#tab-bar {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#tab-list {
    scrollbar-width: none;
}
#tab-list::-webkit-scrollbar { display: none; }

.tab-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px 6px;
    font-size: 12px;
    color: #9ca3af;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
    flex-shrink: 0;
}

.tab-item:hover {
    color: #d1d5db;
    background: rgba(255,255,255,0.03);
}

.tab-item.tab-active {
    color: #d97706;
    border-bottom-color: #d97706;
    background: rgba(217,119,6,0.06);
}

.tab-icon { font-size: 11px; line-height: 1; }

.tab-title {
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tab-close {
    display: none;
    font-size: 15px;
    width: 16px;
    height: 16px;
    line-height: 15px;
    text-align: center;
    border-radius: 4px;
    color: #6b7280;
    cursor: pointer;
    flex-shrink: 0;
}

.tab-item:hover .tab-close,
.tab-item.tab-active .tab-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tab-close:hover {
    background: rgba(239,68,68,0.15);
    color: #ef4444;
}

/* Ensure tab panel visibility override */
.tab-panel.hidden { display: none !important; }

/* Tab file viewer/editor */
.tab-file-viewer pre { margin: 0; background: transparent !important; border: none !important; padding: 0 !important; }
.tab-file-viewer code { font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace; font-size: 0.75rem; line-height: 1.6; }

.tab-file-editor {
    font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
    font-size: 0.75rem;
    line-height: 1.6;
    tab-size: 4;
    resize: none;
}

/* Light theme tab overrides */
html.light .tab-item { color: #6b7280; }
html.light .tab-item:hover { color: #374151; background: rgba(0,0,0,0.03); }
html.light .tab-item.tab-active { color: #b45309; border-bottom-color: #b45309; background: rgba(217,119,6,0.06); }
html.light .tab-close:hover { background: rgba(239,68,68,0.08); }

/* Touch devices: always show tab close */
@media (hover: none) {
    .tab-close { display: inline-flex !important; align-items: center; justify-content: center; }
}

/* Mobile: compact tabs */
@media (max-width: 640px) {
    .tab-item { padding: 5px 10px 4px; font-size: 11px; gap: 4px; }
    .tab-title { max-width: 80px; }
}

/* ── Highlight.js tweaks ──────────────────────────── */

.hljs { background: transparent !important; padding: 0 !important; }

/* Light mode highlight.js override */
html.light .hljs { color: #24292e; }
html.light .hljs-keyword { color: #d73a49; }
html.light .hljs-string { color: #032f62; }
html.light .hljs-comment { color: #6a737d; }
html.light .hljs-number { color: #005cc5; }
html.light .hljs-function .hljs-title { color: #6f42c1; }
html.light .hljs-built_in { color: #e36209; }
