/* 全局样式 */
* { box-sizing: border-box; }
html, body { min-height: 100%; height: auto; overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: auto; -webkit-overflow-scrolling: touch; }
body { -webkit-text-size-adjust: 100%; position: relative; touch-action: pan-y; }
#app { min-height: 100vh; min-height: 100dvh; overflow: visible; }
html.sidebar-open, body.sidebar-open { overflow: hidden !important; }
.mobile-bottom-nav { display: none; }
.mobile-language-select { position: fixed; right: 12px; z-index: 1180; }

.nav-link.active { background-color: #374151; color: #10b981 !important; }

/* Asset-center visual system: used by the refreshed wallet page and safe to
   coexist with legacy pages that still rely on the original Tailwind classes. */

/* 上传区域 */
.upload-area { transition: all 0.2s; cursor: pointer; }
.upload-area.drag-over { border-color: #10b981 !important; background-color: rgba(16, 185, 129, 0.1); }
.upload-area:hover { border-color: #10b981; background-color: rgba(16, 185, 129, 0.05); }

/* 语言切换 */
.language-switch { transition: all 0.2s; cursor: pointer; }
.language-switch:hover { background-color: #374151; color: #10b981 !important; }

/* 自定义提示框 */
.toast-notification {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    min-width: 280px;
    max-width: 420px;
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    animation: slideInRight 0.3s ease-out;
    backdrop-filter: blur(10px);
}
.toast-notification.success { background: rgba(34, 197, 94, 0.95); border-left: 4px solid #22c55e; color: white; }
.toast-notification.error { background: rgba(239, 68, 68, 0.95); border-left: 4px solid #ef4444; color: white; }
.toast-notification.warning { background: rgba(245, 158, 11, 0.95); border-left: 4px solid #f59e0b; color: white; }
.toast-notification.info { background: rgba(59, 130, 246, 0.95); border-left: 4px solid #3b82f6; color: white; }
.toast-notification.important-alert {
    display: flex;
    align-items: center;
    gap: 15px;
    width: min(520px, calc(100vw - 40px));
    max-width: 520px;
    min-height: 86px;
    padding: 17px 20px;
    border: 2px solid rgba(255, 255, 255, 0.36);
    border-left-width: 2px;
    border-radius: 18px;
    font-size: 16px;
    font-weight: 750;
    line-height: 1.5;
    letter-spacing: 0.01em;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.48), 0 0 0 4px rgba(255, 255, 255, 0.08);
    animation: importantToastIn 0.38s cubic-bezier(.2, .9, .25, 1), importantToastPulse 1.2s ease-in-out 0.45s 2;
}
.toast-notification.important-alert.withdrawal-alert {
    border-color: rgba(254, 202, 202, 0.7);
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.99), rgba(234, 88, 12, 0.99));
}
.toast-notification.important-alert.kyc-alert {
    border-color: rgba(254, 240, 138, 0.72);
    background: linear-gradient(135deg, rgba(217, 119, 6, 0.99), rgba(245, 158, 11, 0.99));
}
.important-alert-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    border-radius: 15px;
    background: rgba(17, 24, 39, 0.25);
    font-size: 23px;
    color: #fff;
}
.important-alert-message { flex: 1; min-width: 0; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.24); }

@keyframes importantToastIn {
    from { transform: translateY(-18px) scale(0.96); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes importantToastPulse {
    0%, 100% { box-shadow: 0 18px 48px rgba(0, 0, 0, 0.48), 0 0 0 4px rgba(255, 255, 255, 0.08); }
    50% { box-shadow: 0 20px 54px rgba(0, 0, 0, 0.55), 0 0 0 8px rgba(255, 255, 255, 0.12); }
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
.fade-out { animation: fadeOut 0.5s ease-out forwards; }
.toast-notification.important-alert.fade-out { animation: fadeOut 0.5s ease-out forwards; }
@keyframes fadeOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100%); }
}

/* 模态框 */
.custom-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}
.custom-modal-content {
    background: #1f2937;
    border-radius: 16px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    border: 1px solid #374151;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}
.custom-modal-content h3 {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 12px;
    color: white;
}
.custom-modal-content p {
    color: #9ca3af;
    margin-bottom: 20px;
    line-height: 1.5;
}
.custom-modal-content button {
    padding: 8px 24px;
    background: #10b981;
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}
.custom-modal-content button:hover { background: #059669; }

/* 表格样式 */
.data-table { width: 100%; }
.data-table th { text-align: left; padding: 12px 8px; color: #9ca3af; border-bottom: 1px solid #374151; }
.data-table td { padding: 12px 8px; border-bottom: 1px solid #374151; }

#withdrawAmount::-webkit-outer-spin-button,
#withdrawAmount::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
#withdrawAmount {
    -moz-appearance: textfield;
}

/* KYC图片上传与预览 */
.kyc-upload-box,
.payment-upload-box {
    position: relative;
    min-height: 150px;
    overflow: hidden;
}
.kyc-upload-box.has-image,
.payment-upload-box.has-image { padding: 0 !important; border-style: solid !important; border-color: #22c55e !important; }
.kyc-upload-box .kyc-preview-img,
.payment-upload-box .payment-preview-img { width: 100%; height: 100%; min-height: 150px; object-fit: contain; background: #111827; }
.kyc-upload-change,
.payment-upload-change {
    position: absolute;
    inset: auto 0 0;
    padding: 9px 12px;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.68);
    backdrop-filter: blur(4px);
}
.kyc-upload-box.is-preparing,
.payment-upload-box.is-preparing { pointer-events: none; opacity: .7; }
.exchange-panel { min-height: 100%; }
.support-empty-state {
    border: 1px dashed #4b5563;
    border-radius: 14px;
    background: rgba(17, 24, 39, 0.65);
}

/* Tawk.to 客服頁面 */
.support-content { min-width: 0; }
.support-page-title {
    width: min(100%, 1120px);
    margin: 0 auto 16px;
}
.support-chat-shell {
    width: min(100%, 1120px);
    margin: 0 auto;
    overflow: hidden;
    border: 1px solid rgba(75, 85, 99, 0.9);
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}
.support-chat-frame {
    display: block;
    width: 100%;
    height: calc(100vh - 132px);
    height: calc(100dvh - 132px);
    min-height: 640px;
    border: 0;
    background: #fff;
}

/* 状态标签 */
.status-badge { padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.status-pending { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.status-completed { background: rgba(34, 197, 94, 0.2); color: #22c55e; }
.status-cancelled { background: rgba(239, 68, 68, 0.2); color: #ef4444; }
.status-processing { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }

/* ==================== 移动端适配样式 ==================== */
@media (max-width: 768px) {
    /* Keep the document as the scroll container. The !important also clears
       stale inline overflow left behind by older versions of the menu code. */
    html, body { height: auto; min-height: 100%; overflow-x: hidden !important; overflow-y: auto !important; }
    body { background: #111827; overscroll-behavior-y: auto; touch-action: pan-y; }
    html.sidebar-open, body.sidebar-open { overflow: hidden !important; }

    #app { display: block; min-height: 100dvh; overflow: visible; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }

    .mobile-language-select {
        position: fixed;
        right: 12px;
        z-index: 1180;
    }

    .mobile-language-select select {
        min-height: 34px;
        max-width: 132px;
    }

    /* 侧边栏 - 默认隐藏，通过按钮控制 */
    .sidebar-mobile {
        position: fixed;
        left: 0;
        top: 0;
        width: min(86vw, 320px);
        height: 100%;
        z-index: 1300;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        background-color: #1f2937;
        overflow-y: auto;
        box-shadow: 20px 0 60px rgba(0, 0, 0, 0.45);
    }
    .sidebar-mobile.open {
        transform: translateX(0);
    }
    .sidebar-mobile > .fixed {
        position: relative !important;
        inset: auto !important;
        width: 100% !important;
        height: 100% !important;
        border-right: 0 !important;
        z-index: auto !important;
    }
    .sidebar-mobile .sidebar-nav {
        flex: 0 0 auto !important;
    }
    .sidebar-mobile .sidebar-language-panel {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        align-items: center;
        gap: 10px;
        margin: 0 16px 16px;
        padding: 12px;
        border: 1px solid #374151;
        border-top: 1px solid #374151;
        border-radius: 12px;
        background: #1f2937;
    }
    .sidebar-mobile .sidebar-language-panel label {
        display: flex;
        align-items: center;
        gap: 7px;
        color: #94a3b8;
        font-size: 12px;
        white-space: nowrap;
    }
    .sidebar-mobile .sidebar-language-panel select {
        width: 100%;
        min-width: 0;
        min-height: 40px;
        padding: 7px 30px 7px 10px;
        border: 1px solid #475569;
        border-radius: 10px;
        outline: none;
        background: #374151;
        color: #f1f5f9;
        font-size: 13px !important;
    }
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1290;
        display: none;
    }
    .sidebar-overlay.open {
        display: block;
    }
    .main-content {
        margin-left: 0 !important;
        padding: 72px 12px calc(96px + env(safe-area-inset-bottom)) 12px !important;
        width: 100% !important;
        max-width: 100vw !important;
        min-width: 0 !important;
        overflow-x: hidden;
        overflow-y: visible;
        min-height: calc(100dvh - 56px);
        overscroll-behavior-y: auto;
        touch-action: pan-y;
        -webkit-overflow-scrolling: touch;
    }
    .support-content {
        padding: 68px 12px calc(72px + env(safe-area-inset-bottom)) !important;
        min-height: 100dvh;
        overflow: hidden;
    }
    .support-page-title {
        margin-bottom: 12px;
    }
    .support-chat-shell {
        border-radius: 13px;
        box-shadow: 0 14px 36px rgba(0, 0, 0, 0.3);
    }
    .support-chat-frame {
        height: calc(100vh - 180px - env(safe-area-inset-bottom));
        height: calc(100dvh - 180px - env(safe-area-inset-bottom));
        min-height: 0;
    }
    .mobile-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 56px;
        padding-top: env(safe-area-inset-top);
        background-color: rgba(31, 41, 55, 0.96);
        backdrop-filter: blur(12px);
        border-bottom: 1px solid #374151;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding-left: 14px;
        padding-right: 14px;
        z-index: 1200;
    }
    .menu-btn {
        background: none;
        border: none;
        color: white;
        font-size: 22px;
        width: 44px;
        height: 44px;
        cursor: pointer;
    }

    .mobile-bottom-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1180;
        display: flex;
        justify-content: space-around;
        gap: 4px;
        padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
        background: rgba(17, 24, 39, 0.97);
        border-top: 1px solid #374151;
        backdrop-filter: blur(14px);
    }

    .mobile-bottom-nav.hidden { display: none !important; }

    .mobile-bottom-link {
        flex: 1;
        min-width: 0;
        min-height: 50px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        border-radius: 10px;
        color: #9ca3af;
        text-decoration: none;
        font-size: 11px;
        line-height: 1;
    }

    .mobile-bottom-link i { font-size: 17px; }
    .mobile-bottom-link span { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .mobile-bottom-link.active { color: #34d399; background: rgba(16, 185, 129, 0.12); }
    .mobile-bottom-link:active { transform: scale(0.98); }

    .main-content .grid,
    .main-content [class*="grid-cols"] {
        min-width: 0;
    }

    .main-content [class*="grid-cols"] > * {
        min-width: 0;
    }

    .main-content .rounded-xl,
    .main-content .rounded-lg,
    .main-content table,
    .main-content .overflow-x-auto {
        max-width: 100%;
    }
    
    /* 网格布局调整 */
    .grid-cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    .lg\:grid-cols-2 {
        grid-template-columns: 1fr;
    }
    .lg\:col-span-2 {
        grid-column: span 1;
    }
    
    /* 字体调整 */
    .text-2xl {
        font-size: 1.25rem;
    }
    .text-xl {
        font-size: 1.125rem;
    }
    .p-6 {
        padding: 1rem;
    }
    
    /* 语言切换栏移动端适配 */
    .language-switch {
        font-size: 11px;
        padding: 4px 6px;
    }
    
    /* 提示框移动端适配 */
    .toast-notification {
        top: 60px;
        right: 10px;
        left: 10px;
        max-width: none;
        font-size: 12px;
    }
    .toast-notification.important-alert {
        top: calc(68px + env(safe-area-inset-top));
        right: 14px;
        left: 14px;
        width: auto;
        max-width: none;
        min-width: 0;
        min-height: 92px;
        padding: 18px;
        border-radius: 18px;
        font-size: 16px;
        line-height: 1.55;
    }
    .toast-notification.important-alert .important-alert-icon {
        flex-basis: 50px;
        width: 50px;
        height: 50px;
        font-size: 24px;
    }
    
    /* 模态框移动端适配 */
    .custom-modal-content {
        width: 95%;
        margin: 10px;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    /* 表格移动端适配 */
    table {
        font-size: 12px;
    }
    th, td {
        padding: 8px 4px;
    }
    
    /* 表单元素移动端适配 */
    input:not([type="checkbox"]):not([type="radio"]), select, textarea {
        font-size: 16px !important; /* 防止iOS缩放 */
        min-height: 44px;
    }
    
    /* 按钮移动端适配 */
    button, .btn {
        font-size: 14px;
        min-height: 44px;
        touch-action: manipulation;
    }
    
    /* 加密货币选项移动端适配 */
    .crypto-option, .sell-crypto-option {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    /* 余额卡片移动端适配 */
    .wallet-card {
        padding: 12px;
    }

    .exchange-panel {
        min-height: auto;
    }

    .kyc-form-mobile {
        max-width: 100%;
    }

    .kyc-upload-box {
        min-height: 132px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    .kyc-upload-box .kyc-preview-img,
    .payment-upload-box .payment-preview-img { min-height: 180px; max-height: 260px; }
    
    /* 间距调整 */
    .gap-2 {
        gap: 6px;
    }
    .gap-4 {
        gap: 8px;
    }
    .gap-6 {
        gap: 12px;
    }
    .mb-4 {
        margin-bottom: 12px;
    }
    .mb-6 {
        margin-bottom: 16px;
    }
    .mb-8 {
        margin-bottom: 20px;
    }
}

@media (max-width: 640px) {
    .record-table {
        min-width: 0;
        border-collapse: separate;
        border-spacing: 0;
    }
    .record-table thead { display: none; }
    .record-table,
    .record-table tbody,
    .record-table tr,
    .record-table td {
        display: block;
        width: 100%;
    }
    .record-table tr {
        margin: 0 0 10px;
        padding: 10px 12px;
        background: rgba(17, 24, 39, 0.72);
        border: 1px solid #374151;
        border-radius: 12px;
    }
    .record-table td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 7px 0;
        border-bottom: 1px solid rgba(55, 65, 81, 0.65);
        color: #e5e7eb;
        text-align: right;
        word-break: break-word;
    }
    .record-table td:last-child { border-bottom: 0; }
    .record-table td::before {
        content: attr(data-label);
        flex: 0 0 86px;
        color: #9ca3af;
        font-size: 11px;
        text-align: left;
    }
    .record-table td[colspan] {
        display: block;
        text-align: center;
    }
    .record-table td[colspan]::before { content: none; }
}

/* 平板端适配 */
@media (min-width: 769px) and (max-width: 1024px) {
    .main-content {
        padding: 20px !important;
    }
    .grid-cols-3 {
        grid-template-columns: repeat(3, 1fr);
    }
    .fixed.top-4.right-4 {
        top: 12px;
        right: 12px;
    }
}

/* 桌面端样式 */
@media (min-width: 769px) {
    .mobile-header {
        display: none;
    }
    .sidebar-mobile {
        display: none;
    }
    .sidebar-overlay {
        display: none !important;
    }
    .main-content {
        margin-left: 256px !important;
        padding: 24px !important;
    }
    .main-content.support-content {
        width: calc(100% - 256px) !important;
        max-width: none !important;
    }

    .exchange-panel {
        min-height: 520px;
    }
}

/* 小手机适配 */
@media (max-width: 480px) {
    .grid-cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    .text-3xl {
        font-size: 1.5rem;
    }
    .language-switch {
        font-size: 10px;
        padding: 3px 5px;
    }
}

/* 交易记录表格 */
.record-table { border-collapse: collapse; }
.record-table thead { background: rgba(16, 185, 129, 0.1); }
.record-table th { color: #6ee7b7; font-weight: 600; padding: 10px 8px; text-align: left; border-bottom: 1px solid #374151; white-space: nowrap; }
.record-table td { padding: 10px 8px; border-bottom: 1px solid #1f2937; color: #e5e7eb; }
.record-table tbody tr:hover { background: rgba(55, 65, 81, 0.4); }
.record-table .record-time { color: #9ca3af; font-size: 0.75rem; }

@media (max-width: 640px) {
    .record-table { min-width: 0; border-collapse: separate; border-spacing: 0; }
    .record-table thead { display: none; }
    .record-table,
    .record-table tbody,
    .record-table tr,
    .record-table td { display: block; width: 100%; }
    .record-table tr {
        margin: 0 0 10px;
        padding: 10px 12px;
        background: rgba(17, 24, 39, 0.72);
        border: 1px solid #374151;
        border-radius: 12px;
    }
    .record-table td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 7px 0;
        border-bottom: 1px solid rgba(55, 65, 81, 0.65);
        text-align: right;
        word-break: break-word;
    }
    .record-table td:last-child { border-bottom: 0; }
    .record-table td::before {
        content: attr(data-label);
        flex: 0 0 86px;
        color: #9ca3af;
        font-size: 11px;
        text-align: left;
    }
    .record-table td[colspan] { display: block; text-align: center; }
    .record-table td[colspan]::before { content: none; }
}

/* 在线客服 */
.online-chat-widget { position: fixed; bottom: 20px; right: 20px; z-index: 9998; }
.online-chat-btn {
    width: 56px; height: 56px; border-radius: 50%;
    background: linear-gradient(135deg, #10b981, #059669);
    border: none; color: white; font-size: 22px; cursor: pointer;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
    transition: transform 0.2s;
}
.online-chat-btn:hover { transform: scale(1.05); }
.online-chat-panel {
    position: absolute; bottom: 70px; right: 0;
    width: 320px; max-width: calc(100vw - 40px);
    background: #1f2937; border: 1px solid #374151; border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5); overflow: hidden;
}
.online-chat-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px; background: #111827; color: #10b981; font-weight: 600;
}
.online-chat-header button { background: none; border: none; color: #9ca3af; cursor: pointer; }
.online-chat-body { padding: 16px; max-height: 200px; overflow-y: auto; }
.online-chat-footer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid #374151; }
.online-chat-input {
    flex: 1; padding: 8px 12px; background: #374151; border: 1px solid #4b5563;
    border-radius: 8px; color: white; font-size: 14px;
}
.online-chat-send {
    padding: 8px 14px; background: #10b981; border: none; border-radius: 8px;
    color: white; cursor: pointer;
}
@media (max-width: 768px) {
    .online-chat-widget { bottom: calc(84px + env(safe-area-inset-bottom)); right: 16px; }
    .online-chat-panel { width: calc(100vw - 32px); right: 0; bottom: 66px; }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: #374151;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb {
    background: #6b7280;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* 加载动画 */
.spinner {
    border: 3px solid #374151;
    border-top: 3px solid #10b981;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
