/* ===========================
   CSS VARIABLES
   =========================== */
:root {
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #0f172a;
    --muted: #475569;
    --ring: rgba(2, 6, 23, 0.08);
    --ring-strong: rgba(2, 6, 23, 0.16);
    --primary: #1d4ed8;
    --primary-soft: #eff6ff;
}

/* ===========================
   BASE STYLES
   =========================== */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji", "Segoe UI Emoji";
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

h1 {
    margin: 0 0 18px;
    font-size: 28px;
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
}

/* ===========================
   PAGE LAYOUT
   =========================== */
.page {
    max-width: 1600px;
    margin: 0 auto;
    padding: 28px 20px;
    width: 100%;
    position: relative;
}

.actions-bar {
    margin: 0 0 18px;
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 200;
    background-color: var(--bg);
    padding: 12px 0;
    border-bottom: 1px solid transparent;
}

.actions-bar.scrolled {
    border-bottom: 1px solid var(--ring);
}

.site-footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    color: var(--muted);
    font-size: 13px;
    border-top: 1px solid var(--ring);
}

/* ===========================
   FORM CONTROLS
   =========================== */
#search,
#provider-select {
    padding: 8px 12px;
    border: 1px solid var(--ring);
    border-radius: 6px;
    background-color: var(--card-bg);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease;
}

#search {
    width: 300px;
}

#search:focus,
#provider-select:focus {
    border-color: var(--primary);
}

.compare-button {
    padding: 8px 16px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.compare-button:hover:not(:disabled) {
    background-color: #1e40af;
}

.compare-button:disabled {
    background-color: var(--muted);
    opacity: 0.5;
    cursor: not-allowed;
}

.compare-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* ===========================
   TABLE STRUCTURE
   =========================== */
.table-wrapper {
    border: 1px solid var(--ring);
    border-radius: 0;
    overflow: visible;
    background-color: transparent;
    position: relative;
}

.table-header-container {
    position: sticky;
    top: 60px;
    z-index: 100;
    overflow-x: auto;
    overflow-y: hidden;
    background-color: var(--bg);
    border-bottom: 2px solid var(--ring);
}

.table-body-container {
    overflow-x: auto;
    overflow-y: visible;
    position: relative;
}

.models-table {
    width: 100%;
    min-width: max-content;
    border-collapse: collapse;
    background-color: transparent;
    table-layout: fixed;
}

/* ===========================
   TABLE COLUMNS
   =========================== */
.col-compare {
    width: 60px;
    min-width: 60px;
    max-width: 60px;
    text-align: center;
}

.col-model {
    width: 280px;
    min-width: 280px;
    max-width: 280px;
}

.col-provider {
    width: 130px;
    min-width: 130px;
    max-width: 130px;
}

.col-context-length {
    width: 150px;
    min-width: 150px;
    max-width: 150px;
}

.col-open-weight {
    width: 100px;
    min-width: 100px;
    max-width: 100px;
}

.col-input-price,
.col-output-price,
.col-image-generation {
    width: 180px;
    min-width: 180px;
    max-width: 180px;
}

/* ===========================
   TABLE HEADER
   =========================== */
.models-table thead th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 500;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background-color: var(--bg);
}

/* ===========================
   STICKY COLUMNS
   =========================== */
.header-table .col-compare,
.body-table .col-compare,
.alias-row td.col-compare {
    position: sticky !important;
    left: 0 !important;
    z-index: 50;
    background-color: #f8fafc;
}

.header-table .col-compare {
    background-color: var(--bg);
    z-index: 150;
}

.header-table .col-model,
.body-table .col-model,
.alias-row td.col-model {
    position: sticky !important;
    left: 60px !important;
    background-color: #f8fafc;
    z-index: 50;
}

.header-table .col-model {
    background-color: var(--bg);
    z-index: 150;
}

.body-table .col-model::after,
.header-table .col-model::after,
.alias-row td.col-model::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 1px;
    box-shadow: 1px 0 2px rgba(0, 0, 0, 0.05);
    pointer-events: none;
}

/* ===========================
   TABLE ROWS
   =========================== */
.alias-row {
    border-bottom: 1px solid var(--ring);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.alias-row:last-of-type {
    border-bottom: none;
}

.alias-row td {
    padding: 10px 12px;
    vertical-align: middle;
}

.alias-row:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.alias-row:hover .col-model,
.alias-row:hover .col-compare {
    background-color: rgba(0, 0, 0, 0.02) !important;
}

/* ===========================
   TABLE CONTENT
   =========================== */
.model-name {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.model-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.model-icon img {
    width: 24px;
    height: 24px;
}

.provider-badge {
    display: inline-block;
    padding: 3px 8px;
    background-color: transparent;
    color: var(--muted);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    text-transform: capitalize;
    border: 1px solid var(--ring);
}

.context-length-value,
.price-value,
.info-value,
.image-generation-value {
    font-size: 13px;
    font-weight: 400;
    color: var(--text);
}

/* ===========================
   PRICE LIST STYLING
   =========================== */
.price-container {
    display: flex;
    flex-direction: column;
}

.price-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.price-row {
    display: grid;
    grid-template-columns: 60px 1fr;
    align-items: flex-start;
    gap: 4px;
    font-size: 12px;
    line-height: 1.4;
}

.price-label {
    font-weight: 600;
    color: var(--muted);
    text-transform: capitalize;
}

.price-amount {
    color: var(--text);
    font-weight: 400;
}

.price-nested {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.price-nested-row {
    display: grid;
    grid-template-columns: 60px 1fr;
    align-items: flex-start;
    gap: 4px;
    font-size: 11px;
    line-height: 1.4;
}

.price-nested-label {
    color: var(--text);
    font-weight: 400;
}

.price-nested-value {
    color: var(--text);
    font-weight: 400;
}

/* ===========================
   SCROLLBAR STYLING
   =========================== */
.table-body-container::-webkit-scrollbar {
    height: 6px;
}

.table-body-container::-webkit-scrollbar-track {
    background: transparent;
}

.table-body-container::-webkit-scrollbar-thumb {
    background: var(--ring-strong);
    border-radius: 3px;
}

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

/* Hide scrollbar on header container but keep it scrollable */
.table-header-container::-webkit-scrollbar {
    display: none;
}

.table-header-container {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

/* ===========================
   RESPONSIVE: TABLETS
   =========================== */
@media (max-width: 768px) {
    .page {
        padding: 20px 14px;
    }

    h1 {
        font-size: 24px;
        margin-bottom: 16px;
    }

    .models-table thead th {
        padding: 8px 10px;
        font-size: 10px;
    }

    .alias-row td {
        padding: 10px;
    }

    .model-name {
        font-size: 13px;
    }

    .price-value {
        font-size: 12px;
    }

    .model-icon img {
        width: 22px;
        height: 22px;
    }
}

/* ===========================
   RESPONSIVE: MOBILE
   =========================== */
@media (max-width: 520px) {
    .page {
        padding: 16px 12px;
    }

    h1 {
        font-size: 22px;
    }

    .col-model {
        min-width: 150px;
    }

    .col-input-price,
    .col-output-price {
        width: 30px;
        font-size: 12px;
    }

    .models-table thead th {
        padding: 8px;
        font-size: 10px;
    }

    .alias-row td {
        padding: 8px;
    }

    .model-icon img {
        width: 20px;
        height: 20px;
    }

    .model-name {
        font-size: 12px;
    }
}
