/* ========================================
   移动端聊天界面样式
   ======================================== */

   * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary-color: #1AAD19;
    --primary-light: #E8F5E9;
    --user-bubble: #95EC69;
    --system-bubble: #FFFFFF;
    --success-color: #1AAD19;
    --error-color: #FA5151;
    --bg-color: #EDEDED;
    --text-primary: #000000;
    --text-secondary: #999999;
    --border-color: #E5E5E5;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-color);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   移动端容器布局
   ======================================== */

.mobile-chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* 动态视口高度 */
    width: 100vw;
    background: var(--bg-color);
}

/* ========================================
   顶部导航栏
   ======================================== */

.mobile-header {
    background: #FFFFFF;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    /* iOS安全区域适配 */
    padding-top: env(safe-area-inset-top);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 12px;
}

.back-btn,
.more-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.2s;
}

.back-btn:active,
.more-btn:active {
    background: rgba(0, 0, 0, 0.05);
}

.header-info {
    flex: 1;
    text-align: center;
    padding: 0 12px;
}

.header-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.header-status {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.2;
    margin-top: 2px;
}

/* ========================================
   聊天消息区域
   ======================================== */

.mobile-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}

/* 消息组 */
.message-group {
    display: flex;
    margin-bottom: 16px;
    animation: slideIn 0.3s ease-out;
}

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

.message-group.left {
    justify-content: flex-start;
}

.message-group.right {
    justify-content: flex-end;
}

/* 头像 */
.message-avatar {
    margin-right: 8px;
    flex-shrink: 0;
}

.message-group.right .message-avatar {
    margin-right: 0;
    margin-left: 8px;
    order: 2;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

/* 消息列表 */
.message-list {
    max-width: 70%;
    display: flex;
    flex-direction: column;
}

.message-group.right .message-list {
    align-items: flex-end;
}

/* 消息气泡 */
.message-bubble {
    padding: 10px 14px;
    border-radius: 8px;
    word-wrap: break-word;
    word-break: break-word;
    position: relative;
    box-shadow: var(--shadow);
}

.message-bubble.system {
    background: var(--system-bubble);
    border-top-left-radius: 2px;
}

.message-bubble.user {
    background: var(--user-bubble);
    border-top-right-radius: 2px;
}

.bubble-content p {
    margin: 0;
    line-height: 1.5;
}

.bubble-content p + p {
    margin-top: 8px;
}

.hint {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 6px !important;
}

/* 消息时间 */
.message-time {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
    padding: 0 4px;
}

/* ========================================
   快捷回复按钮
   ======================================== */

.quick-replies {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.quick-reply-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.quick-reply-btn:active {
    background: #F5F5F5;
    transform: scale(0.98);
}

.quick-reply-btn .icon {
    font-size: 18px;
}

.quick-reply-btn .text {
    flex: 1;
    text-align: left;
}

/* ========================================
   成功/失败卡片
   ======================================== */

.success-card {
    background: #FFFFFF;
    border: 1px solid var(--success-color);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(26, 173, 25, 0.15);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.card-icon {
    font-size: 20px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--success-color);
}

.card-body {
    text-align: center;
    padding: 16px 0;
}

.amount-display {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 4px;
}

.amount-value {
    font-size: 48px;
    font-weight: 700;
    color: var(--success-color);
    line-height: 1;
}

.amount-unit {
    font-size: 16px;
    color: var(--text-secondary);
}

.card-message {
    margin-top: 12px;
    font-size: 15px;
    color: var(--text-primary);
}

.card-footer {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    font-size: 14px;
    color: var(--text-secondary);
}

.footer-icon {
    font-size: 16px;
}

/* ========================================
   打字中动画
   ======================================== */

.message-bubble.typing {
    background: var(--system-bubble);
    padding: 12px 16px;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* ========================================
   底部输入框
   ======================================== */

.mobile-input {
    background: #F7F7F7;
    border-top: 1px solid var(--border-color);
    /* iOS安全区域适配 */
    padding-bottom: env(safe-area-inset-bottom);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    padding: 8px;
    gap: 8px;
}

.input-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.2s;
    flex-shrink: 0;
}

.input-btn:active {
    background: rgba(0, 0, 0, 0.05);
}

.message-input {
    flex: 1;
    min-height: 36px;
    max-height: 100px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #FFFFFF;
    font-size: 16px;
    line-height: 1.5;
    resize: none;
    outline: none;
    font-family: inherit;
}

.message-input:focus {
    border-color: var(--primary-color);
}

.send-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--primary-color);
    color: #FFFFFF;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.send-btn:disabled {
    background: #CCCCCC;
    cursor: not-allowed;
}

.send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.input-footer {
    padding: 4px 12px 8px;
    text-align: right;
}

.char-count {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ========================================
   滚动条样式
   ======================================== */

.mobile-messages::-webkit-scrollbar {
    width: 4px;
}

.mobile-messages::-webkit-scrollbar-track {
    background: transparent;
}

.mobile-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

/* ========================================
   响应式适配
   ======================================== */

@media (max-width: 375px) {
    .message-list {
        max-width: 75%;
    }

    .amount-value {
        font-size: 40px;
    }
}

/* ========================================
   暗黑模式（可选）
   ======================================== */

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #1C1C1E;
        --system-bubble: #2C2C2E;
        --text-primary: #FFFFFF;
        --text-secondary: #8E8E93;
        --border-color: #38383A;
    }

    .mobile-header {
        background: #1C1C1E;
    }

    .message-input {
        background: #2C2C2E;
        color: #FFFFFF;
    }

    .mobile-input {
        background: #1C1C1E;
    }

    .quick-reply-btn {
        background: #2C2C2E;
        border-color: #38383A;
        color: #FFFFFF;
    }

    .success-card {
        background: #2C2C2E;
    }
}

/* ========================================
   下拉菜单样式（微信风格）
   ======================================== */

.dropdown-menu {
    position: fixed;
    top: 55px;
    right: 10px;
    background: #4C4C4C;
    border-radius: 6px;
    min-width: 140px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    animation: menuFadeIn 0.15s ease-out;
}

.dropdown-menu::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 16px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid #4C4C4C;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    color: #FFFFFF;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.15s;
}

.menu-item:first-child {
    border-radius: 6px 6px 0 0;
}

.menu-item:last-child {
    border-radius: 0 0 6px 6px;
}

.menu-item:hover,
.menu-item:active {
    background: rgba(255, 255, 255, 0.1);
}

.menu-item svg {
    flex-shrink: 0;
    opacity: 0.9;
}

.menu-item + .menu-item {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

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

/* ========================================
   欢迎界面样式
   ======================================== */

.welcome-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.welcome-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
    color: white;
}

.welcome-intro {
    font-size: 14px;
    margin-bottom: 12px;
    opacity: 0.95;
}

.feature-list {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 12px;
    margin: 12px 0;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    font-size: 14px;
}

.feature-item:not(:last-child) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.feature-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.welcome-footer {
    font-size: 13px;
    margin-top: 12px;
    opacity: 0.9;
}

/* 快捷按钮增强 */
.quick-replies {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 12px;
}

.quick-reply-btn {
    background: white;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.quick-reply-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    grid-column: 1 / -1;
    font-weight: 600;
}

.quick-reply-btn:active {
    transform: scale(0.98);
}

.quick-reply-btn .icon {
    font-size: 18px;
}

.quick-reply-btn .text {
    flex: 1;
    text-align: left;
}