html, body {
    overflow-x: hidden;
}

html {
    overflow-y: scroll;
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: white;
}

header {
    background-color: #C8B0D0;
    color: #4A2C40;
    padding: 20px;
    position: relative;
}

.top-header {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.logo {
    height: 50px;
    width: auto;
}

.main-nav {
    position: absolute;
    right: 20px;
    top: 20px;
    display: flex;
    gap: 10px;
    z-index: 100;
}

.nav-link {
    padding: 12px 20px;
    background-color: white;
    color: #D9C1D9;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    text-decoration: none;
    display: inline-block;
}

.nav-link:hover {
    background-color: #f5f5f5;
}

header h1 {
    margin: 20px 0 0 0;
    text-align: center;
}

header p {
    margin: 5px 0 0 0;
    text-align: center;
}

/* AlphaFold风格搜索部分 */
.search-section {
    background-color: #E0D0E0;
    padding: 20px 10px 10px 10px;
    width: 100%;
    box-sizing: border-box;
}

.search-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.search-box {
    width: 85%;
    padding: 12px 15px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    outline: none;
    background-color: white;
}

.search-button {
    padding: 12px 20px;
    background-color: white;
    color: #D9C1D9;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
}

.search-button:hover {
    background-color: #f5f5f5;
}

.search-examples {
    max-width: 1200px;
    margin: 15px auto 5px;
    color: white;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.examples-label {
    margin-right: 10px;
    font-size: 14px;
}

.example-tag {
    display: inline-block;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    text-decoration: none;
    padding: 5px 10px;
    margin: 5px;
    border-radius: 3px;
    font-size: 14px;
}

.example-tag:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.search-links {
    margin-left: auto;
    display: flex;
    gap: 15px;
}

.help-link, .course-link {
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    font-size: 14px;
}

.help-link:hover, .course-link:hover {
    text-decoration: underline;
}

.circle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: white;
    color: #2055a4;
    margin-left: 5px;
    font-size: 12px;
    font-weight: bold;
}

.preview-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    width: 100%;
    max-width: 1200px;
    margin: 10px auto 20px;
}
.preview-item {
    width: 32%;
    margin-bottom: 0;
    background-color: white;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s;
}
.preview-item:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}
.preview-viewer {
    width: 100%;
    height: 250px;
    position: relative;
    overflow: hidden;
}
.preview-viewer canvas {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
}

/* 确保Molstar插件在预览中占满整个区域 */
.preview-viewer .msp-plugin {
    position: absolute !important;
    width: 100% !important;
    height: 100% !important;
    top: 0;
    left: 0;
}

.preview-viewer .msp-viewport-host {
    position: absolute !important;
    width: 100% !important;
    height: 100% !important;
    top: 0;
    left: 0;
}

.preview-viewer .msp-viewport {
    position: absolute !important;
    width: 100% !important;
    height: 100% !important;
    top: 0;
    left: 0;
}

.preview-title {
    padding: 5px;
    text-align: center;
    background-color: #f2f2f2;
    font-weight: bold;
}
.database-title {
    margin: 20px 20px 5px 20px;
    font-size: 1.5em;
    color: #2c3e50;
}
.container {
    display: flex;
    margin: 20px;
    flex-direction: column;
}
.detail-container {
    display: flex;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    aspect-ratio: 4/3;
}
.database {
    flex: 4;
    margin-right: 20px;
}
.viewer-container {
    flex: 3;
}
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}
th, td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}
th {
    background-color: #f2f2f2;
}
tr:hover {
    background-color: #f5f5f5;
    cursor: pointer;
}
.active {
    background-color: #e0f7fa;
}
.description {
    margin-top: 20px;
    padding: 10px;
    background-color: white;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.info-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.full-width-viewer-container {
    width: 100%;
    max-width: 1200px;
    margin: 20px auto;
}

#myViewer {
    width: 100%;
    height: 0;
    padding-bottom: 75%; /* 4:3比例 */
    background-color: white;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
}

/* 确保molstar插件内容正确定位 */
#myViewer > div {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* 确保主查看器中的Molstar插件保持4:3比例 */
#myViewer .msp-plugin {
    position: absolute !important;
    width: 100% !important;
    height: 100% !important;
}

#myViewer .msp-viewport-host {
    position: absolute !important;
    width: 100% !important;
    height: 100% !important;
}

#myViewer .msp-viewport {
    position: absolute !important;
    width: 100% !important;
    height: 100% !important;
}

/* Molstar 查看器滚动条样式 */
.msp-plugin ::-webkit-scrollbar-thumb {
    background-color: #474748 !important;
    border-radius: 10px;
}

@media (max-width: 768px) {
    .preview-container {
        aspect-ratio: unset;
    }
    
    .preview-item {
        width: 100%;
        margin-bottom: 20px;
    }
    
    .detail-container {
        flex-direction: column;
        aspect-ratio: unset;
    }
    
    .database, .viewer-container {
        flex: none;
        width: 100%;
        margin-right: 0;
    }
    
    #myViewer {
        padding-bottom: 75%; /* 保持4:3比例 */
        height: 0;
    }
    
    .search-container {
        max-width: 95%;
        flex-direction: column;
    }
    
    .search-box {
        width: 100%;
        border-radius: 2px 2px 0 0;
    }
    
    .search-button {
        width: 100%;
        border-radius: 0 0 2px 2px;
    }
    
    .search-examples {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .example-tag {
        margin: 3px;
    }
    
    .search-links {
        margin-left: 0;
        margin-top: 10px;
        width: 100%;
        justify-content: center;
    }

    /* Header adjustments for mobile */
    header {
        padding: 15px; /* Reduce header padding */
        text-align: center; /* Center align header content */
    }

    .top-header {
        flex-direction: column; /* Stack logo and potentially other top elements */
        align-items: center; /* Center items horizontally */
    }

    .logo {
        height: 40px; /* Reduce logo size */
        margin-bottom: 15px; /* Add space below logo */
    }

    /* Target the correct nav class from HTML */
    .top-nav {
        position: static; /* Remove absolute positioning */
        display: flex;
        flex-wrap: wrap; /* Allow buttons to wrap */
        justify-content: center; /* Center buttons */
        gap: 8px; /* Space between buttons */
        margin-top: 15px; /* Add space above nav buttons */
        width: 100%; /* Allow nav to take full width */
        z-index: auto; /* Reset z-index */
    }

    .nav-button { /* Adjust nav button styles */
        padding: 10px 15px;
        font-size: 14px;
        flex-grow: 1; /* Allow buttons to take available space */
        text-align: center;
        min-width: 100px; /* Ensure buttons aren't too small */
        margin-left: 0 !important; /* Override potential inline margin */
    }

    header h1 {
        font-size: 1.6em; /* Adjust title font size */
        margin-top: 15px; /* Adjust top margin */
        margin-bottom: 5px;
    }

    header p {
        font-size: 0.9em; /* Adjust paragraph font size */
        margin-top: 5px;
        margin-bottom: 10px; /* Add some space below subtitle */
    }
}

#csvPdbTable th.sort-asc::after {
    content: ' ▲';
    font-size: 0.8em;
}

#csvPdbTable th.sort-desc::after {
    content: ' ▼';
    font-size: 0.8em;
}

/* Stats Section */
.stats-section {
    width: 100%;
    max-width: 1200px;
    margin: 40px auto;
    padding: 20px;
    box-sizing: border-box;
}

.stats-section h2 {
    text-align: center;
    font-size: 2em;
    color: #333;
    margin-bottom: 30px;
}

.charts-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
}

.chart-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
    padding: 20px;
    box-sizing: border-box;
    flex: 1 1 45%; /* Two cards per row */
    min-width: 300px;
}

.chart-card h3 {
    text-align: center;
    font-size: 1.2em;
    color: #555;
    margin-top: 0;
    margin-bottom: 20px;
}

.chart-full-width {
    flex-basis: 100%;
}