/* ===========================
   Language Switch Styles
   =========================== */
.language-switch {
    position: relative;
    margin-right: 20px;
    cursor: pointer;
    float: left;
    padding: 26px 0px;
    margin-left: 20px;
    font-size: 15px;
    font-weight: 600;
}

.language-switch .icon-wrapper {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #fff;
}
.language-switch .dropdown {
    position: absolute;
    right: -10px;
    top: 60px;
    background-color: #fff;
    border: 1px solid #eee;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    width: 150px;
    padding: 10px;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    overflow-y: auto;
}
.language-switch .dropdown.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}
.language-switch .dropdown::-webkit-scrollbar {
    width: 6px;
}
.language-switch .dropdown::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}
.language-switch .dropdown::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.language-switch .dropdown li {
    list-style: none;
}
.language-switch .dropdown .language-item {
    padding: 5px 10px;
    text-decoration: none;
    display: flex;
    align-items: center;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
}
.language-switch .dropdown .language-item:hover {
    background-color: #f0f0f0;
}

.language-switch .dropdown .language-item img {
    width: 20px;
    height: 20px;
    margin-right: 10px;
}

/* ===========================
   Global Message Base Styles
   =========================== */
.global-message {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #fff;
    width: 346px;
    min-height: 100px;
    padding: 30px;
    border-radius: 10px;
    font-size: 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

/* Icon Styles */
.global-message .icon {
    width: 100px;
    height: 100px;
    fill: currentColor;
    flex-shrink: 0;
    margin-bottom: 20px;
}

/* Spinner Styles */
.icon.spinner {
    width: 80px;
    height: 80px;
    animation: spin 1s linear infinite;
}

.icon.spinner .path {
    stroke: currentColor;
    stroke-linecap: round;
    stroke-dasharray: 90, 150;
    stroke-dashoffset: 0;
}

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

/* ===========================
   Color Variants
   =========================== */
.global-message.success { 
    color: #28a745; 
}
.global-message.error { 
    color: #dc3545; 
}

/* ===========================
   Show / Hide Animations
   =========================== */
.global-message.show.success {
    animation: slideDownFadeIn 0.4s ease forwards;
}

.global-message.show.error {
    animation: slideDownFadeIn 0.4s ease forwards, shake 0.4s ease;
}

.global-message.hide {
    animation: slideUpFadeOut 0.4s ease forwards;
}

/* ==============================
   Markdown Styles
   ============================== */
.chat-message {
  font-size: 15px;
}

.chat-message:last-child {
    margin-bottom: 0;
}

.chat-message h1,
.chat-message h2,
.chat-message h3 {
  font-weight: 600;
  margin: .5rem 0 .4rem;
}

.chat-message p {
  margin: .5rem 0;
  line-height: 1.75;
}

.chat-message ul,
.chat-message ol {
  padding-left: 1.25rem;
  margin: .5rem 0;
}

.chat-message li {
  list-style: disc;
}

.chat-message blockquote {
  border-left: 4px solid #999;
  padding: .5rem 1rem;
  color: #6b7280;
  margin: .5rem 0;
}

.chat-message pre {
  background: #f2f2f2;
  border-radius: .5rem;
  padding: .75rem;
  overflow: auto;
}

.chat-message code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: .875rem;
}

.chat-message hr {
  border: 0;
  border-top: 1px solid #e5e7eb;
  margin: .75rem 0;
}

.chat-message a {
  text-decoration: underline;
}

.chat-message table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: .95rem;
}

.chat-message th,
.chat-message td {
    border: 1px solid #e5e7eb;
    padding: .5rem .75rem;
    text-align: left;
}

.chat-message th {
    background-color: #f9fafb;
    font-weight: 600;
}

.chat-message tr:nth-child(even) {
    background-color: #fdfdfd;
}

.chat-message tr:hover {
    background-color: #f3f4f6;
}

/* ------------------- 聊天弹窗 ------------------- */
body.modal-open {
    overflow: hidden;
}

#chat-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#chat-modal.show {
    opacity: 1;
    pointer-events: auto;
}

#chat-box-container {
    background: #fff;
    width: 90%;
    max-width: 600px;
    max-height: calc(100vh - 120px);
    height: calc(100vh - 120px);
    margin: 60px auto;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}

#chat-modal.show #chat-box-container {
    transform: translateY(0);
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #fff;
    border-bottom: 1px solid #ddd;
}

.chat-header-text {
    font-size: 18px;
    font-weight: 500;
    color: #333;
}

#chat-close-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #333;
}

#chat-close-btn:hover {
    color: red;
}

#chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 20px 15px;
    background: #f5f5f5;
    display: flex;
    flex-direction: column;
}

#chat-input-area {
    display: flex;
    padding: 15px;
    padding-top: 0;
    background: #f5f5f5;
}

#chat-input-area input {
    flex: 1;
    padding: 6px 10px;
    border-radius: 5px;
    border: 1px solid #ccc;
    margin-right: 5px;
}

#chat-input-area button,
.form-group button {
    padding: 6px 15px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(90deg, #B8860B, #8B6508);
    box-shadow: 0 4px 12px rgba(184, 134, 11, 0.4);
    transition: all 0.3s ease;
}

#chat-input-area button:hover,
.form-group button:hover {
    background: linear-gradient(90deg, #8B6508, #B8860B);
    box-shadow: 0 6px 16px rgba(184, 134, 11, 0.5);
    transform: translateY(-2px);
}

.chat-message {
    margin-bottom: 15px;
    max-width: 90%;
    padding: 0 12px;
    border-radius: 8px;
    word-break: break-word;
}

.chat-message.user {
    background: #d0ebff;
    margin-left: auto;
}

.chat-message.assistant {
    background: #e4e4e4;
    margin-right: auto;
}

/* ------------------- 旋转加载动画 ------------------- */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top-color: #000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

.loading-text {
    display: inline-flex;
    padding: 5px 0;
    align-items: center;
    font-size: 16px;
    color: #333;
}

/* ------------------- 漂浮聊天按钮 ------------------- */
#chat-float-btn {
    position: fixed;
    width: 46px;
    text-align: center;
    padding: 20px 10px;
    bottom: 80px;
    right: 30px;
    line-height: 22px;
    border-radius: 30px;
    background: linear-gradient(90deg, #B8860B, #8B6508);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(184, 134, 11, 0.4);
    z-index: 999;
    transition: all 0.3s ease;
}

#chat-float-btn span {
    display: block;
    font-size: 20px;
}

#chat-float-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(184, 134, 11, 0.5);
}

/* ------------------- 响应式适配 ------------------- */
@media (max-width: 1024px) {
    #chat-float-btn {
        bottom: 20px;
        right: 20px;
    }
    #chat-float-btn span {
        font-size: 24px;
    }
}

@media (max-width: 768px) {
    #chat-box-container {
        width: 95%;
        max-height: calc(100vh - 80px);
        margin: 40px auto;
    }
    #chat-float-btn {
        bottom: 15px;
        right: 15px;
    }
    #chat-float-btn span {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    #chat-box-container {
        width: 100%;
        max-height: 100vh;
        height: 100%;
        margin: 0 auto;
        border-radius: 0;
    }
    #chat-input-area input {
        font-size: 18px;
    }
    #chat-input-area button {
        font-size: 16px;
        padding: 8px 20px;
    }
    #chat-float-btn {
        width: 40px;
        bottom: 10px;
        right: 10px;
    }
    #chat-float-btn span {
        font-size: 18px;
    }
}