/* Inherit base variables from style.css */
:root {
    --chart-bg: rgba(15, 23, 42, 0.6);
    --table-header-bg: rgba(30, 41, 59, 0.9);
    --table-row-hover: rgba(56, 189, 248, 0.1);
}

.dashboard-container {
    padding: 1rem;
    animation: fadeInDown 0.8s ease-out;
}

/* Header Adjustments */
.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    position: relative;
}

.nav-left,
.nav-right {
    flex: 1;
}

.nav-center {
    flex: 2;
    text-align: center;
}

.nav-right {
    display: flex;
    justify-content: flex-end;
}

.back-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s;
}

.back-link:hover {
    color: var(--accent-color);
}

/* Dropdown Menu */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropbtn {
    background-color: rgba(56, 189, 248, 0.1);
    color: var(--accent-color);
    padding: 10px 20px;
    font-size: 0.9rem;
    border: 1px solid rgba(56, 189, 248, 0.3);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s;
}

.dropdown:hover .dropbtn {
    background-color: rgba(56, 189, 248, 0.2);
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    background-color: #1e293b;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.5);
    z-index: 100;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.dropdown-content a {
    color: var(--text-primary);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
}

.dropdown-content a:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.dropdown-content a.active {
    background-color: rgba(56, 189, 248, 0.1);
    color: var(--accent-color);
}

.dropdown:hover .dropdown-content {
    display: block;
}

/* Summary Stats, etc */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    backdrop-filter: blur(12px);
}

.stat-card h3 {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.stat-card p {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-primary);
    background: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Charts */
.charts-grid,
.explorer-section,
.analysis-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.explorer-section {
    grid-template-columns: 1fr;
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1.5rem;
}

/* Explorer Controls */
.explorer-controls {
    display: flex;
    gap: 2rem;
}

.explorer-controls label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
}

.explorer-controls select {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    color: white;
    font-family: inherit;
}

.chart-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    height: 400px;
    display: flex;
    flex-direction: column;
}

.chart-card.full-width {
    grid-column: 1 / -1;
}

.chart-card h3 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
    color: var(--text-primary);
}

canvas {
    flex-grow: 1;
    width: 100% !important;
    height: 100% !important;
    max-height: 320px;
}

/* Data Table */
.data-section {
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1.5rem;
    margin-bottom: 2rem;
    backdrop-filter: blur(12px);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.table-container {
    overflow-x: auto;
}

#search-input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    color: white;
    width: 250px;
}

#rows-limit {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    color: white;
    margin-right: 1rem;
    cursor: pointer;
}

#rows-limit option {
    background: #1e293b;
    color: white;
}

table {
    width: 100%;
    border-collapse: collapse;
    color: var(--text-secondary);
}

th,
td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

th {
    background: var(--table-header-bg);
    color: var(--text-primary);
    font-weight: 600;
}

tr:hover {
    background: var(--table-row-hover);
    color: var(--text-primary);
}

/* Research Section */
.research-section {
    margin-top: 3rem;
    padding-bottom: 3rem;
}

.research-section h2 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.references-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.reference-item {
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1.5rem;
    transition: transform 0.3s;
}

.reference-item:hover {
    transform: translateY(-5px);
    border-color: var(--accent-color);
}

.reference-item h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.citation {
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 1rem;
    font-style: italic;
}

.ref-link {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent-color);
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.85rem;
    transition: background 0.3s;
}

.ref-link:hover {
    background: rgba(56, 189, 248, 0.2);
}

@media (max-width: 768px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }

    .nav-container {
        flex-direction: column;
        gap: 1rem;
    }

    .back-link {
        position: static;
        display: block;
        margin-bottom: 1rem;
    }
}

/* ===================================
   Definitions Page Styles
   =================================== */

.info-card {
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    backdrop-filter: blur(12px);
}

.highlight-card {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
    border-color: rgba(56, 189, 248, 0.3);
}

.info-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.score-definition {
    font-size: 1.2rem;
    line-height: 1.8;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.score-example {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border-left: 3px solid var(--accent-color);
}

/* Algorithm Cards */
.definitions-section {
    margin-bottom: 2rem;
}

.definitions-section h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.section-intro {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.algorithm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.algorithm-card {
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1.5rem;
    transition: transform 0.3s, border-color 0.3s;
}

.algorithm-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent-color);
}

.algo-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.algo-abbrev {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 100%);
    color: white;
    font-weight: 800;
    font-size: 1.1rem;
    border-radius: 10px;
}

.algo-abbrev.algo-e {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.algo-abbrev.algo-igs {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

.algo-abbrev.algo-rl {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.algo-header h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin: 0;
}

.algo-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.algo-traits {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.trait {
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent-color);
    border-radius: 4px;
    border: 1px solid rgba(56, 189, 248, 0.2);
}

/* Grid Size Cards */
.info-section {
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.info-section h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.info-section p {
    color: var(--text-secondary);
    line-height: 1.6;
}

.info-section a {
    color: var(--accent-color);
    text-decoration: none;
}

.info-section a:hover {
    text-decoration: underline;
}

.grid-sizes {
    display: flex;
    gap: 2rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.grid-size-card {
    text-align: center;
}

.grid-visual {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(56, 189, 248, 0.1);
    border: 2px solid rgba(56, 189, 248, 0.3);
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.grid-visual.grid-4x4 {
    width: 80px;
    height: 80px;
}

.grid-visual.grid-5x5 {
    width: 100px;
    height: 100px;
}

.grid-visual span {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
}

.grid-size-card p {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.grid-area {
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

.context-list {
    color: var(--text-secondary);
    padding-left: 1.5rem;
    margin: 1rem 0;
}

.context-list li {
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

/* ===================================
   Table Pagination Styles
   =================================== */

.pagination-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.pagination-btn {
    padding: 0.5rem 1rem;
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent-color);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.pagination-btn:hover:not(:disabled) {
    background: rgba(56, 189, 248, 0.2);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ===================================
   Table Scroll Container
   =================================== */

.table-scroll-container {
    max-height: 500px;
    overflow-y: auto;
    border-radius: 8px;
}

.table-scroll-container::-webkit-scrollbar {
    width: 8px;
}

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

.table-scroll-container::-webkit-scrollbar-thumb {
    background: rgba(56, 189, 248, 0.4);
    border-radius: 4px;
}

.table-scroll-container::-webkit-scrollbar-thumb:hover {
    background: rgba(56, 189, 248, 0.6);
}

/* Sticky table header */
#runs-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Grid Size Analysis Section */
.grid-analysis-section {
    margin-bottom: 2rem;
}

.grid-analysis-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.grid-winner-card {
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
}

.grid-winner-card h4 {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.grid-winner-card .winner-algo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 0.25rem;
}

.grid-winner-card .winner-score {
    color: var(--text-secondary);
    font-size: 0.85rem;
}