:root {
    --bg-main: #0f172a;
    --bg-secondary: #1e293b;
    --bg-glass: rgba(30, 41, 59, 0.7);
    --border-glass: rgba(255, 255, 255, 0.1);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;

    --accent-primary: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-gradient: linear-gradient(135deg, #3b82f6, #8b5cf6);

    --success: #10b981;
    --danger: #ef4444;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    --radius-md: 8px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

/* App Layout */
.app-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    height: 100vh;
}

/* Header */
.app-header {
    position: relative;
    padding: 2rem;
    border-radius: var(--radius-lg);
    background: var(--accent-gradient);
    overflow: hidden;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-lg);
    flex-shrink: 0;
}

.header-content {
    position: relative;
    z-index: 2;
}

.header-content h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-content p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1rem;
    max-width: 600px;
}

/* Decorative Orbs */
.glass-orb {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    z-index: 1;
}

.orb-1 {
    width: 300px;
    height: 300px;
    top: -150px;
    right: -50px;
}

.orb-2 {
    width: 150px;
    height: 150px;
    bottom: -50px;
    right: 200px;
    background: rgba(255, 255, 255, 0.05);
}

/* Main Content Area */
.main-layout {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    flex: 1;
    min-height: 0;
}

/* Top Panel: Data Table & Filters */
.data-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 0;
    max-height: 100vh;
    /* Limits table block to half the viewport height, forcing a scrollbar */
}

/* Controls */
.controls-panel {
    padding: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1.5rem;
}

.search-box {
    flex: 1;
    min-width: 300px;
    position: relative;
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 1.25rem;
}

.search-box input {
    width: 100%;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    padding: 0.75rem 1rem 0.75rem 3rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-width: 150px;
}

.filter-group label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.filter-group select {
    width: 100%;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1em;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.filter-group select option {
    background: var(--bg-main);
    color: var(--text-primary);
}

.stats {
    width: 100%;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: right;
}

#resultCount {
    font-weight: 600;
    color: var(--accent-hover);
}

/* Table */
.table-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
}

/* Custom Scrollbar */
.table-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
    background: var(--border-glass);
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

table {
    width: 100%;
    min-width: 800px; /* Ensures the table doesn't get smashed on mobile, enabling horizontal scroll instead */
    border-collapse: collapse;
    text-align: left;
    table-layout: fixed;
    /* Force fixed layout so columns don't stretch forever */
}

/* Specific column widths to ensure good layout */
th:nth-child(1),
td:nth-child(1) {
    width: 15%;
}

th:nth-child(2),
td:nth-child(2) {
    width: 35%;
}

th:nth-child(3),
td:nth-child(3) {
    width: 30%;
}

th:nth-child(4),
td:nth-child(4) {
    width: 10%;
}

th:nth-child(5),
td:nth-child(5) {
    width: 10%;
}

thead th {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    padding: 1rem 1.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-glass);
    z-index: 10;
}

tbody td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.95rem;
    word-break: break-word;
}

tbody tr {
    transition: all 0.2s ease;
    cursor: pointer;
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

tbody tr.active {
    background: rgba(59, 130, 246, 0.15);
    border-left: 3px solid var(--accent-primary);
}

.badge-pdb {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-md);
    font-family: monospace;
    font-weight: 600;
    color: var(--accent-hover);
    text-decoration: none;
    transition: background 0.2s;
}

.badge-pdb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.center {
    text-align: center;
}

.paper-link {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 1.25rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
}

.paper-link.illuminated {
    color: #fff;
    background: rgba(59, 130, 246, 0.8);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.6);
}

.paper-link.illuminated:hover {
    background: rgba(59, 130, 246, 1);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.9);
    transform: translateY(-2px);
}

.paper-link.disabled {
    color: rgba(255, 255, 255, 0.15);
    pointer-events: none;
    background: transparent;
}

/* Bottom Panel: 3D Viewer */
.viewer-section {
    display: flex;
    flex-direction: column;
    min-height: 700px; /* Increased viewer length */
    width: 100%;
}

.viewer-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.viewer-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.6);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.1);
}

.badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.badge.active {
    background: var(--accent-primary);
    color: white;
}

.viewer-container {
    flex: 1;
    position: relative;
    background: #000;
    overflow: hidden;
}

.mol-viewer {
    width: 100%;
    height: 100%;
    position: absolute;
}

.viewer-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem;
    background: var(--bg-main);
    z-index: 10;
    transition: opacity 0.3s;
}

.viewer-placeholder i {
    font-size: 3rem;
    opacity: 0.5;
}

.viewer-details {
    padding: 1.5rem;
    border-top: 1px solid var(--border-glass);
    max-height: 250px;
    overflow-y: auto;
}

.viewer-details h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.sequence-box {
    font-family: monospace;
    font-size: 0.85rem;
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: var(--radius-md);
    word-break: break-all;
    line-height: 1.4;
    color: #e2e8f0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .app-container {
        padding: 1rem;
    }
    
    .app-header {
        padding: 1.5rem;
    }
    
    .controls-panel {
        padding: 1rem;
        flex-direction: column;
        align-items: stretch;
    }

    .filters {
        flex-direction: column;
    }
}