/* ================================================================
   AI Model Pricing - Styles
   ================================================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1480px;
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
}

/* --- Header --- */
header {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    padding: 28px 0 24px;
    color: #fff;
}

.header-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.header-brand {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #fff;
}

.tagline {
    font-size: 0.85rem;
    color: #94a3b8;
    font-style: italic;
}

.header-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.subtitle {
    color: #94a3b8;
    font-size: 0.82rem;
    margin-top: 10px;
    max-width: 640px;
}

/* Header button overrides for dark background */
header .btn-primary {
    background: #3b82f6;
    border-color: #3b82f6;
}
header .btn-primary:hover {
    background: #2563eb;
    border-color: #2563eb;
}
header .btn-secondary {
    background: rgba(255,255,255,0.08);
    color: #cbd5e1;
    border-color: rgba(255,255,255,0.12);
}
header .btn-secondary:hover {
    background: rgba(255,255,255,0.14);
    border-color: rgba(255,255,255,0.2);
    color: #fff;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid var(--border);
    white-space: nowrap;
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--bg);
    border-color: var(--text-muted);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

/* --- Controls --- */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin: 20px 0 12px;
}

.search-box {
    flex: 1;
    min-width: 220px;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
    color: var(--text);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

/* --- Multi-select Dropdown --- */
.multi-select {
    position: relative;
    display: inline-block;
}

.ms-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.8rem;
    background: var(--surface);
    cursor: pointer;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 130px;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: var(--font);
}

.ms-trigger:hover {
    border-color: var(--text-muted);
}

.ms-trigger:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.ms-trigger.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.ms-chevron {
    flex-shrink: 0;
    transition: transform 0.15s;
}

.ms-trigger.active .ms-chevron {
    transform: rotate(180deg);
}

.ms-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    width: max-content;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    z-index: 50;
    max-height: 300px;
    display: flex;
    flex-direction: column;
}

.ms-dropdown[hidden] {
    display: none;
}

.ms-search-wrap {
    padding: 6px;
    border-bottom: 1px solid var(--border-light);
}

.ms-search {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
}

.ms-search:focus {
    outline: none;
    border-color: var(--primary);
}

.ms-options {
    overflow-y: auto;
    padding: 4px 0;
}

.ms-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 0.78rem;
    color: var(--text-secondary);
    transition: background 0.1s;
    white-space: nowrap;
}

.ms-option:hover {
    background: var(--primary-light);
}

.ms-option input[type="checkbox"] {
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

.ms-logo {
    width: 14px;
    height: 14px;
    border-radius: 2px;
    object-fit: contain;
    flex-shrink: 0;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
}

.toggle input[type="checkbox"] {
    cursor: pointer;
    accent-color: var(--primary);
}

/* --- Stats --- */
.stats {
    display: flex;
    gap: 16px;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    align-items: center;
}

.sep::after {
    content: "\00b7";
    color: var(--border);
    font-weight: bold;
}

/* --- Loading / Error / No results --- */
.loading, .error, .no-results {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.error {
    color: var(--danger);
}

/* --- Table --- */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
    box-shadow: var(--shadow);
    margin-bottom: 32px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

th {
    background: #f8fafc;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    user-select: none;
}

th.num {
    text-align: right;
}

th.sortable {
    cursor: pointer;
    transition: color 0.1s;
}

th.sortable:hover {
    color: var(--primary);
}

th.sortable::after {
    content: "";
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 4px;
    vertical-align: middle;
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
    border-top: 3px solid transparent;
}

th.sortable.asc::after {
    border-top: 4px solid var(--primary);
}

th.sortable.desc::after {
    border-top: none;
    border-bottom: 4px solid var(--primary);
}

td {
    padding: 7px 12px;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}

td.num {
    text-align: right;
    font-family: var(--mono);
    font-size: 0.78rem;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: #f8fafc;
}

/* Deprecated */
tr.deprecated td {
    color: var(--text-muted);
    text-decoration: line-through;
    opacity: 0.6;
}

/* --- Provider cell --- */
.provider-cell {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.provider-logo {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    flex-shrink: 0;
    object-fit: contain;
}

.provider-name {
    font-weight: 500;
    color: var(--text);
}

.provider-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.provider-link:hover .provider-name {
    color: var(--primary);
    text-decoration: underline;
}

.provider-link:hover .provider-logo {
    transform: scale(1.1);
    transition: transform 0.15s ease;
}

/* --- Model cell with copy --- */
.model-cell {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.model-name {
    font-weight: 500;
    color: var(--text);
}

.model-id {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    transition: color 0.1s;
    max-width: 220px;
}

.model-id-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.model-id:hover {
    color: var(--primary);
}

.model-id .copy-icon {
    opacity: 0;
    transition: opacity 0.1s;
    flex-shrink: 0;
}

.model-id:hover .copy-icon {
    opacity: 1;
}

/* --- Type (modality) icons --- */
.type-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 500;
    background: var(--border-light);
    color: var(--text-secondary);
}

.type-text        { background: #f0fdf4; color: #166534; }
.type-vision      { background: #faf5ff; color: #7c3aed; }
.type-image_gen   { background: #fef3c7; color: #92400e; }
.type-audio       { background: #fce7f3; color: #9d174d; }
.type-video_gen   { background: #ecfeff; color: #155e75; }
.type-embedding   { background: #f0f9ff; color: #0369a1; }
.type-rerank      { background: #f5f3ff; color: #5b21b6; }

/* --- Tier badge --- */
.tier-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 500;
    background: var(--border-light);
    color: var(--text-muted);
}

.tier-batch { background: #fef3c7; color: #92400e; }
.tier-flex  { background: #dbeafe; color: #1e40af; }

/* --- Tooltip --- */
.tooltip-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-muted);
    font-size: 0.6rem;
    font-weight: 700;
    cursor: help;
    position: relative;
    vertical-align: middle;
    margin-left: 3px;
}

.tooltip-trigger:hover::after,
.tooltip-trigger:focus::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: #fff;
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 0.72rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    line-height: 1.5;
    white-space: normal;
    width: 220px;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

/* --- Source link --- */
.source-link {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.source-link:hover {
    color: var(--primary);
    text-decoration: underline;
}

/* --- Verified date --- */
.date-cell {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* --- Family badge --- */
.family-badge {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* --- Context display --- */
.context-cell {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.context-threshold {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 1px;
}

/* --- API Documentation --- */
.api-docs {
    margin: 16px 0 48px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
}

.api-docs h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.api-intro {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 24px;
}

.api-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.api-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.api-card h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.api-card p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.api-url {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    margin-bottom: 8px;
}

.api-url code {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.api-url .param {
    color: var(--primary);
    font-weight: 500;
}

.copy-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px 8px;
    font-size: 0.68rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.copy-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.api-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.api-example-link {
    font-size: 0.7rem;
    color: var(--primary);
    text-decoration: none;
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    background: var(--primary-light);
    transition: background 0.1s;
}

.api-example-link:hover {
    background: #dbeafe;
}

.api-example-code {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow-sm);
}

.api-example-code h3 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.api-example-code pre {
    background: #1e293b;
    color: #e2e8f0;
    border-radius: var(--radius);
    padding: 16px;
    overflow-x: auto;
    font-size: 0.78rem;
    line-height: 1.6;
}

/* --- Copy toast --- */
.copy-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: #fff;
    padding: 8px 20px;
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    transition: opacity 0.2s;
}

.copy-toast[hidden] {
    opacity: 0;
    pointer-events: none;
}

/* --- Footer --- */
footer {
    margin-top: auto;
    padding: 24px 0;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

footer a {
    color: var(--primary);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

footer p + p {
    margin-top: 4px;
}

.footer-credit {
    margin-top: 8px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .filters {
        flex-direction: column;
    }

    .multi-select {
        width: 100%;
    }

    .ms-trigger {
        width: 100%;
    }

    .search-box {
        min-width: unset;
    }

    .header-top {
        flex-direction: column;
        align-items: flex-start;
    }

    header h1 {
        font-size: 1.3rem;
    }

    .tagline {
        font-size: 0.78rem;
    }

    .header-actions {
        width: 100%;
    }

    .stats {
        flex-wrap: wrap;
    }

    .api-grid {
        grid-template-columns: 1fr;
    }
}
