/* ==========================================================================
   Index Page (Table View) Styles
   ========================================================================== */

body {
    min-height: 100vh;
    padding: 20px;
}

/* ---------- Layout ---------- */
.container {
    max-width: 95%;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

@media (min-width: 1600px) {
    .container {
        max-width: 98%;
    }
}

@media (min-width: 2000px) {
    .container {
        max-width: 99%;
    }
}

/* ---------- Header ---------- */
header {
    background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
    color: white;
    padding: 40px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 700;
}

header p {
    font-size: 1.1em;
    opacity: 0.9;
}

/* ---------- Search ---------- */
.search-section {
    padding: 30px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
}

.search-container {
    display: flex;
    gap: 10px;
    max-width: 600px;
    margin: 0 auto;
}

#searchInput {
    flex: 1;
    padding: 15px 20px;
    font-size: 16px;
    border: 2px solid #cbd5e1;
    border-radius: 8px;
    transition: all 0.3s;
    background: #ffffff;
    color: #1e293b;
}

#searchInput:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

#searchButton {
    padding: 15px 30px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

#searchButton:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

/* ---------- API Links ---------- */
.api-links {
    padding: 20px 30px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    text-align: center;
}

.api-links-title {
    font-size: 0.9em;
    color: #64748b;
    margin-bottom: 10px;
    font-weight: 500;
}

.api-links-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.api-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #ffffff;
    color: #1e40af;
    text-decoration: none;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.2s;
}

.api-link:hover {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

/* ---------- Stats ---------- */
.stats {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
    padding: 25px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.stat-item {
    text-align: center;
    padding: 15px 25px;
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    min-width: 120px;
}

.stat-value {
    font-size: 2em;
    font-weight: 700;
    color: #1e40af;
}

.stat-label {
    font-size: 0.9em;
    color: #64748b;
    margin-top: 5px;
    font-weight: 500;
}

/* ---------- Table section ---------- */
.table-section {
    padding: 30px 30px 45px 30px;
    overflow-x: auto;
    overflow-y: visible;
    position: relative;
    scrollbar-width: auto;
    scrollbar-color: #3b82f6 #e2e8f0;
    scroll-behavior: smooth;
}

/* Scrollbar - WebKit */
.table-section::-webkit-scrollbar {
    height: 16px;
    display: block !important;
}

.table-section::-webkit-scrollbar-track {
    background: #e2e8f0;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
}

.table-section::-webkit-scrollbar-thumb {
    background: #3b82f6;
    border-radius: 8px;
    border: 2px solid #e2e8f0;
    min-width: 50px;
}

.table-section::-webkit-scrollbar-thumb:hover {
    background: #2563eb;
}

.table-section::-webkit-scrollbar-thumb:active {
    background: #1d4ed8;
}

.table-section:hover::-webkit-scrollbar-thumb {
    background: #3b82f6;
}

/* ---------- Table ---------- */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

@media (min-width: 1400px) {
    table {
        min-width: auto;
    }
}

@media (max-width: 1399px) {
    table {
        min-width: 1200px;
    }
}

thead {
    background: #1e40af;
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: #ffffff;
    border-bottom: 2px solid #1e3a8a;
    white-space: nowrap;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
}

th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
    padding-right: 30px;
}

th.sortable:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

th.sortable::after {
    content: '⇅';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.5;
    font-size: 12px;
}

th.sortable.sort-asc::after {
    content: '↑';
    opacity: 1;
    color: #60a5fa;
}

th.sortable.sort-desc::after {
    content: '↓';
    opacity: 1;
    color: #60a5fa;
}

td {
    padding: 12px 15px;
    border-bottom: 1px solid #e2e8f0;
    color: #334155;
}

tbody tr {
    transition: background 0.2s;
    background: #ffffff;
}

tbody tr:hover {
    background: #f1f5f9;
}

tbody tr:nth-child(even) {
    background: #f8fafc;
}

tbody tr:nth-child(even):hover {
    background: #f1f5f9;
}

/* ---------- Codename badge ---------- */
.codename-badge {
    background: #e0e7ff;
    color: #4338ca;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s;
}

.codename-badge:hover {
    box-shadow: 0 2px 4px rgba(67, 56, 202, 0.3);
}

/* ---------- Loading / Error / Empty states ---------- */
.loading {
    text-align: center;
    padding: 60px;
    color: #64748b;
}

.error {
    text-align: center;
    padding: 60px;
    color: #dc2626;
    background: #fef2f2;
    margin: 20px;
    border-radius: 8px;
    border: 1px solid #fecaca;
}

.empty-state {
    text-align: center;
    padding: 60px;
    color: #64748b;
    background: #f8fafc;
    margin: 20px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

/* ---------- Pagination ---------- */
.pagination-container {
    padding: 20px 30px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.pagination-info {
    display: flex;
    align-items: center;
    font-size: 14px;
    color: #64748b;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pagination-btn {
    padding: 8px 16px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #1e293b;
}

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

.page-info {
    padding: 0 12px;
    font-size: 14px;
    color: #475569;
    font-weight: 500;
}

#pageSizeSelect {
    margin: 0 8px;
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 14px;
}

#pageSizeSelect:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

#paginationInfo {
    margin-left: 20px;
    color: #64748b;
}

/* ---------- Mobile responsive ---------- */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header {
        padding: 20px;
    }

    header h1 {
        font-size: 1.8em;
    }

    .search-container {
        flex-direction: column;
    }

    .stats {
        flex-wrap: wrap;
        gap: 10px;
        justify-content: center;
    }

    .stat-item {
        min-width: 100px;
        flex: 1 1 calc(50% - 10px);
    }

    .api-links-container {
        flex-direction: column;
        gap: 10px;
    }

    .table-section {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        font-size: 11px;
        min-width: 800px;
    }

    th, td {
        padding: 6px 8px;
    }

    .pagination-container {
        flex-direction: column;
        gap: 15px;
        padding: 15px 20px;
    }

    .pagination-info {
        flex-wrap: wrap;
        justify-content: center;
        text-align: center;
        font-size: 12px;
        width: 100%;
    }

    .pagination-info span {
        display: inline-block;
        margin: 2px 4px;
    }

    #paginationInfo {
        display: block;
        width: 100%;
        margin-top: 8px;
        margin-left: 0 !important;
    }

    .pagination-controls {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    .pagination-btn {
        padding: 8px 12px;
        font-size: 13px;
        min-width: 70px;
    }

    .page-info {
        width: 100%;
        text-align: center;
        padding: 8px 0;
        font-size: 13px;
    }

    #pageSizeSelect {
        font-size: 13px;
        padding: 6px 8px;
    }
}