/* Reset default styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 限制页面被放大 */
html {
    touch-action: manipulation; /* 防止双击放大 */
    -webkit-text-size-adjust: 100%; /* 防止iOS缩放 */
    -ms-text-size-adjust: 100%;
    user-select: none; /* 防止文本选择 */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* 限制输入框缩放 */
input, textarea {
    font-size: 16px; /* 防止iOS缩放 */
    touch-action: manipulation;
    user-select: text; /* 允许输入框文本选择 */
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

/* 限制弹窗缩放 */
.modal {
    touch-action: none; /* 防止弹窗内的缩放操作 */
}

body {
    font-family: Arial, sans-serif;
    overflow: hidden;
    position: fixed; /* 防止页面滚动 */
    width: 100%;
    height: 100%;
}

/* External page iframe */
.external-page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    z-index: 1;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

/* Main toggle button */
.main-toggle-button {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 101;
    position: relative;
    margin-top: 200px;
}

.main-toggle-button:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.main-toggle-button.active {
    background: rgba(255, 255, 255, 0.35);
}

/* Buttons container */
.buttons-container {
    position: absolute;
    top: -200px;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s ease;
    z-index: 99;
    max-height: 400px; /* 限制最大高度 */
    overflow-y: auto; /* 允许垂直滚动 */
    padding: 10px 0; /* 添加内边距 */
    scrollbar-width: thin; /* 针对Firefox */
}

/* 滚动条样式 */
.buttons-container::-webkit-scrollbar {
    width: 4px; /* 滚动条宽度 */
}

.buttons-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1); /* 滚动条轨道背景 */
    border-radius: 2px;
}

.buttons-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3); /* 滚动条滑块背景 */
    border-radius: 2px;
}

.buttons-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5); /* 滚动条滑块悬停背景 */
}

.buttons-container.expanded {
    opacity: 1;
    visibility: visible;
}

/* Sidebar buttons */
.sidebar-button {
    display: block;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    text-align: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    min-width: 90px;
    white-space: nowrap;
    transform: translateX(100px);
    opacity: 0;
    position: relative;
}

/* 整齐排列效果 - 靠右屏显示 */
.buttons-container.expanded .sidebar-button {
    transform: translateX(0);
    opacity: 1;
}

.buttons-container.expanded .sidebar-button:nth-child(1) {
    transition-delay: 0.1s;
}

.buttons-container.expanded .sidebar-button:nth-child(2) {
    transition-delay: 0.15s;
}

.buttons-container.expanded .sidebar-button:nth-child(3) {
    transition-delay: 0.2s;
}

.buttons-container.expanded .sidebar-button:nth-child(4) {
    transition-delay: 0.25s;
}

.buttons-container.expanded .sidebar-button:nth-child(5) {
    transition-delay: 0.3s;
}

.buttons-container.expanded .sidebar-button:nth-child(6) {
    transition-delay: 0.35s;
}

.buttons-container.expanded .sidebar-button:nth-child(7) {
    transition-delay: 0.4s;
}

.buttons-container.expanded .sidebar-button:nth-child(8) {
    transition-delay: 0.45s;
}

.buttons-container.expanded .sidebar-button:nth-child(9) {
    transition-delay: 0.5s;
}

.buttons-container.expanded .sidebar-button:nth-child(10) {
    transition-delay: 0.55s;
}

.sidebar-button:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: translateX(-15px) !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    touch-action: none; /* 防止背景滚动 */
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #f5f0e6; /* 米色背景 */
    border-radius: 4px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    padding: 20px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    position: relative;
    width: 400px; /* 固定宽度 */
    height: 600px; /* 固定高度 */
}

/* Modal content for image items */
.modal-item-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.modal-item-image {
    width: 100%;
    max-height: 200px !important;
    height: auto;
    object-fit: contain;
    background-color: #f0f0f0;
    margin-bottom: 15px;
}

.modal-item-info {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 5px;
}

.modal-item-title {
    font-size: 18px !important;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
    text-align: center;
}

.modal-item-description {
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    text-align: left;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: scroll;
    padding: 10px 15px;
    background-color: #f9f9f9;
    border-radius: 4px;
    border: 1px solid #eee;
    margin-bottom: 10px;
}

.modal-url-content {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
}

.modal-iframe {
    width: 100%;
    height: 100%;
    border: none;
    object-fit: contain; /* 等比例缩放内容 */
}

/* 滚动条样式 */
.modal-item-info::-webkit-scrollbar {
    width: 6px;
}

.modal-item-info::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.modal-item-info::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.modal-item-info::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.close-button {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    z-index: 1001;
    color: #666;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-button:hover {
    color: #333;
}

/* Source lookup styles */
.modal-source-lookup {
    margin: 15px 0;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 4px;
    border: 1px solid #eee;
}

.source-label {
    font-weight: bold;
    margin-right: 10px;
}

.source-query-container {
    display: flex;
    align-items: center;
    flex: 1;
}

.source-phone-input {
    flex: 1;
    padding: 5px;
    margin-right: 5px;
    border: 1px solid #ddd;
    border-radius: 3px;
}

.source-query-button {
    padding: 5px 10px;
    background-color: #007cba;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.source-query-button:hover {
    background-color: #005a87;
}

.source-query-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.source-result {
    display: none;
    margin-top: 10px;
    padding: 5px;
    background-color: #e8f5e9;
    border-radius: 3px;
    font-size: 14px;
}

/* 默认来源显示 */
.source-default {
    color: #007cba;
    font-weight: bold;
    display: none;
}

/* 修改来源部分颜色与标题一致 */
.modal-source-lookup .source-label {
    color: #333;
    font-weight: bold;
}

.modal-source-lookup .source-name {
    color: #333;
    font-weight: bold;
}

.modal-source-lookup .source-default {
    color: #333;
    font-weight: bold;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .sidebar {
        right: 10px;
    }
    
    .main-toggle-button {
        width: 45px;
        height: 45px;
        font-size: 14px;
    }
    
    .sidebar-button {
        min-width: 80px;
        font-size: 13px;
        padding: 8px 12px;
    }
    
    .buttons-container {
        max-height: 300px; /* 移动端减小最大高度 */
    }
    
    .modal-content {
        width: 90vw;
        height: 80vh;
        padding: 15px;
    }
}