/* src/web/css/style.css */

/* ===============================================================================
   Global & Layout
   =============================================================================== */
* {
    box-sizing: border-box;
}

body {
    height: 100dvh;
    margin: 0;
    text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
}

/* ===============================================================================
   容器宽度控制：电脑端更宽（80vw），手机端全宽
   =============================================================================== */
.container-max-width {
    width: 100%;
    max-width: min(80vw, 1280px);
    margin-left: auto;
    margin-right: auto;
}

@media (max-width: 639px) {
    .container-max-width {
        max-width: 100% !important;
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    footer .container-max-width {
        max-width: 100% !important;
        width: 100% !important;
    }
}

/* ===============================================================================
   Scrollbars
   =============================================================================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-thumb {
    background: #4b5563;
    border-radius: 3px;
}

textarea {
    min-height: 44px;
    max-height: 200px;
    overflow-y: auto;
    -webkit-appearance: none;
    appearance: none;
    resize: none;
    outline: none;
    scrollbar-width: thin;
    transition: box-shadow 0.2s ease;
}
textarea:focus {
    box-shadow: inset 0 0 0 2px rgba(59, 130, 246, 0.4);
}
textarea::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}
textarea::-webkit-scrollbar-thumb {
    background: #6b7280;
    border-radius: 4px;
}
textarea::-webkit-scrollbar-track {
    background: #374151;
    border-radius: 4px;
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* ===============================================================================
   Animations
   =============================================================================== */
.spin-anim {
    animation: spin 1s linear infinite;
}
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.typing-dot {
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background-color: #9ca3af;
    margin-right: 3px;
    animation: typing 1.4s infinite ease-in-out both;
}
@keyframes typing {
    0%,
    80%,
    100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* ★ 停止按钮脉冲动画 */
@keyframes pulse-red {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}
.btn-stop-active {
    animation: pulse-red 1.5s infinite;
}

/* ===============================================================================
   UI Components
   =============================================================================== */

/* 思考过程面板 */
.thought-process {
    background-color: rgba(31, 41, 55, 0.6);
    border-left: 3px solid #4b5563;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.5rem 0.75rem;
    font-style: italic;
    color: #9ca3af;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    width: 100%;
    overflow-wrap: break-word;
    word-break: break-word;
}
.thought-process[open] {
    background-color: rgba(31, 41, 55, 0.8);
}
.thought-process summary {
    cursor: pointer;
    font-weight: 600;
    color: #6b7280;
    outline: none;
    user-select: none;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
}
.thought-process summary::before {
    content: "🧠";
    font-size: 0.9rem;
}
.thought-process summary::after {
    content: "▼";
    font-size: 0.7rem;
    margin-left: auto;
    transition: transform 0.2s;
}
.thought-process[open] summary::after {
    transform: rotate(180deg);
}
.thought-process summary:hover {
    color: #d1d5db;
}
.think-hint {
    font-size: 0.7rem;
    font-weight: normal;
    color: #6b7280;
    margin-left: 0.25rem;
}

/* Toast 通知 */
#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.toast {
    padding: 0.75rem 1.25rem;
    border-radius: 0.5rem;
    color: white;
    font-size: 0.875rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease-out forwards;
    min-width: 200px;
    max-width: 350px;
}
.toast-success {
    background-color: #10b981;
}
.toast-error {
    background-color: #ef4444;
}
.toast-warn {
    background-color: #f59e0b;
}
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* 附件芯片 */
.attachment-chip {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #374151;
    border: 1px solid #4b5563;
    padding: 0.5rem 0.75rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    color: #d1d5db;
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ★ 欢迎界面样式 */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #6b7280;
    padding: 2rem;
    gap: 1.5rem;
}
.suggestion-chip {
    background: #1f2937;
    border: 1px solid #374151;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
}
.suggestion-chip:hover {
    background: #374151;
    border-color: #4b5563;
    color: white;
}

/* ===============================================================================
   Search — 搜索高亮与导航
   =============================================================================== */

/* 搜索关键词高亮（黄色背景，用于所有匹配项） */
.search-highlight {
    background-color: #f59e0b;
    color: #000;
    padding: 0 2px;
    border-radius: 2px;
}

/* 当前跳转定位的高亮（橙色背景 + 边框，用于 TreeWalker DOM 层定位） */
.search-highlight-current {
    background-color: #fb923c;
    color: #000;
    padding: 0 2px;
    border-radius: 2px;
    outline: 2px solid #f97316;
    outline-offset: 1px;
}

/* 跳转时消息气泡的蓝色闪光动画 */
.search-match-jump {
    animation: search-jump-flash 1.5s ease-out;
}
@keyframes search-jump-flash {
    0% {
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.6);
    }
    100% {
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0);
    }
}

/* 搜索匹配计数文字（可点击跳转下一条） */
.search-match-count {
    font-size: 0.7rem;
    color: #9ca3af;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}
.search-match-count:hover {
    color: #d1d5db;
}

/* 搜索上下导航按钮（上一条/下一条） */
.search-nav-btn {
    cursor: pointer;
    opacity: 0.4;
    transition:
        opacity 0.2s,
        background 0.15s;
    padding: 2px 4px;
    border-radius: 4px;
    color: #9ca3af;
}
.search-nav-btn:hover {
    opacity: 1;
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

/* ===============================================================================
   Code Blocks & Markdown
   =============================================================================== */
select option {
    background-color: #374151;
    color: white;
}
.code-block-wrapper {
    margin: 0.75rem 0;
    border-radius: 0.5rem;
    overflow: hidden;
    border: 1px solid #374151;
    background-color: #111827;
}
.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #1f2937;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    color: #9ca3af;
    border-bottom: 1px solid #374151;
    user-select: none;
}
.prose pre {
    background-color: #111827 !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 0 0.5rem 0.5rem;
}
.hljs {
    background: transparent !important;
    padding: 1rem !important;
    font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
    font-size: 0.875rem;
    line-height: 1.5;
}
.prose {
    max-width: none !important;
}
.user-msg-long {
    max-height: 5.5rem;
    overflow: hidden;
    position: relative;
}
.user-msg-long::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2rem;
    background: linear-gradient(transparent, rgba(30, 58, 138, 0.8));
}
.copy-btn {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
}
.copy-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}
.prose table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.875rem;
    border: 1px solid #374151;
    border-radius: 0.5rem;
    overflow: hidden;
}
.prose thead {
    background-color: #1f2937;
}
.prose th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: #e5e7eb;
    border-bottom: 2px solid #4b5563;
    white-space: nowrap;
}
.prose td {
    padding: 0.625rem 1rem;
    color: #d1d5db;
    border-bottom: 1px solid #374151;
}
.prose tbody tr {
    background-color: #111827;
    transition: background-color 0.15s ease;
}
.prose tbody tr:nth-child(even) {
    background-color: #1a202c;
}
.prose tbody tr:hover {
    background-color: #1f2937;
}
.prose tbody tr:last-child td {
    border-bottom: none;
}

.prose ul.contains-task-list {
    list-style: none;
    padding-left: 0;
    margin: 0.75rem 0;
}
.prose li.task-list-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin: 0.375rem 0;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    transition: background-color 0.15s ease;
}
.prose li.task-list-item:hover {
    background-color: rgba(55, 65, 81, 0.5);
}
.prose input[type="checkbox"].task-list-item-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 1.125rem;
    height: 1.125rem;
    min-width: 1.125rem;
    border: 2px solid #4b5563;
    border-radius: 0.25rem;
    background-color: #1f2937;
    cursor: default;
    margin-top: 0.125rem;
    position: relative;
    transition: all 0.15s ease;
}
.prose input[type="checkbox"].task-list-item-checkbox:checked {
    background-color: #2563eb;
    border-color: #2563eb;
}
.prose input[type="checkbox"].task-list-item-checkbox:checked::after {
    content: "";
    position: absolute;
    left: 0.3125rem;
    top: 0.0625rem;
    width: 0.375rem;
    height: 0.625rem;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.prose li.task-list-item.checked > label,
.prose li.task-list-item.checked > span {
    text-decoration: line-through;
    color: #6b7280;
}

.prose blockquote {
    border-left: 4px solid #3b82f6;
    padding-left: 1rem;
    margin: 1rem 0;
    color: #9ca3af;
    font-style: italic;
}
.prose hr {
    border: none;
    border-top: 1px solid #374151;
    margin: 1.5rem 0;
}
.prose del {
    color: #6b7280;
    text-decoration: line-through;
}
.prose ins {
    color: #4ade80;
    text-decoration: underline;
    text-decoration-color: #4ade80;
}

/* 响应式 */
@media (max-width: 640px) {
    #provider-select {
        max-width: 75px !important;
    }
    #model-select {
        max-width: 85px !important;
    }
    .prose table {
        font-size: 0.75rem;
    }
    .prose th,
    .prose td {
        padding: 0.5rem;
    }
    .flex.justify-start,
    .flex.justify-end {
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }
}

.prose pre,
.prose table {
    max-width: 100%;
    overflow-x: auto;
}
.prose img {
    max-width: 100%;
    height: auto;
}
