/*
           calculadora-tokens-ia — estilos específicos
           */

/* Contador en tiempo real */
.textarea-wrap {
    position: relative;
}

.token-textarea {
    width: 100%;
    min-height: 180px;
    padding: 0.9rem 1rem 2.5rem;
    border: 2px solid var(--border, #e2e8f0);
    border-radius: 10px;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.9rem;
    color: var(--text, #1e293b);
    background: var(--bg-input, #f8fafc);
    resize: vertical;
    transition: border-color 0.18s, box-shadow 0.18s;
    box-sizing: border-box;
    line-height: 1.7;
}

.token-textarea:focus {
    outline: none;
    border-color: var(--primary, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
    background: #fff;
}

.textarea-footer {
    position: absolute;
    bottom: 0.5rem;
    right: 0.75rem;
    display: flex;
    gap: 0.75rem;
    align-items: center;
    pointer-events: none;
}

.live-counter {
    font-size: 0.75rem;
    font-family: 'Ubuntu', monospace, sans-serif;
    font-weight: 700;
    color: var(--text-muted, #94a3b8);
    background: var(--bg-alt, #f1f5f9);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 6px;
    padding: 0.15rem 0.5rem;
}

.live-counter.has-text {
    color: var(--primary, #2563eb);
    background: rgba(37, 99, 235, 0.08);
    border-color: rgba(37, 99, 235, 0.2);
}

/* Selector de modelo */
.model-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.65rem;
    margin: 1.25rem 0;
}

.model-card {
    border: 2px solid var(--border, #e2e8f0);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    cursor: pointer;
    transition: all 0.16s;
    background: transparent;
    text-align: left;
    font-family: 'Montserrat', sans-serif;
}

.model-card:hover {
    border-color: var(--primary, #2563eb);
    background: rgba(37, 99, 235, 0.03);
}

.model-card.selected {
    border-color: var(--primary, #2563eb);
    background: rgba(37, 99, 235, 0.06);
}

.model-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.model-logo {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.ml-openai {
    background: #10a37f;
}

.ml-anthropic {
    background: #cc785c;
}

.ml-google {
    background: #4285f4;
}

.ml-meta {
    background: #0866ff;
}

.ml-mistral {
    background: #ff6f00;
}

.model-name {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text, #1e293b);
    line-height: 1.2;
}

.model-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.4rem;
}

.model-tag {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    font-family: 'Montserrat', sans-serif;
}

.tag-ctx {
    background: rgba(37, 99, 235, 0.1);
    color: #2563eb;
}

.tag-in {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
}

.tag-out {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.tag-free {
    background: rgba(139, 92, 246, 0.1);
    color: #7c3aed;
}

/* Config de tokens de salida */
.output-config {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--bg-alt, #f8fafc);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.output-config label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text, #1e293b);
    font-family: 'Montserrat', sans-serif;
    white-space: nowrap;
}

.output-config input[type="range"] {
    flex: 1;
    min-width: 120px;
    accent-color: var(--primary, #2563eb);
    cursor: pointer;
}

.output-config .range-val {
    font-family: 'Ubuntu', monospace, sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary, #2563eb);
    min-width: 65px;
    text-align: right;
}

.output-config .range-hint {
    font-size: 0.72rem;
    color: var(--text-muted, #94a3b8);
    font-family: 'Montserrat', sans-serif;
    width: 100%;
    margin-top: -0.25rem;
}

/* Panel de resultados */
.results-dashboard {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.dash-card {
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--border, #e2e8f0);
    background: #fff;
    text-align: center;
}

.dash-card.dash-primary {
    border-color: var(--primary, #2563eb);
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.07), rgba(99, 102, 241, 0.05));
}

.dash-card .dash-icon {
    font-size: 1.3rem;
    margin-bottom: 0.35rem;
    color: var(--primary, #2563eb);
}

.dash-card.dash-input .dash-icon {
    color: #16a34a;
}

.dash-card.dash-output .dash-icon {
    color: #dc2626;
}

.dash-card .dash-val {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'Ubuntu', monospace, sans-serif;
    color: var(--text, #1e293b);
    line-height: 1.1;
}

.dash-card.dash-primary .dash-val {
    font-size: 1.75rem;
    color: var(--primary, #2563eb);
}

.dash-card .dash-label {
    font-size: 0.72rem;
    font-weight: 600;
    font-family: 'Montserrat', sans-serif;
    color: var(--text-muted, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 0.2rem;
}

.dash-card .dash-sub {
    font-size: 0.75rem;
    color: var(--text-muted, #94a3b8);
    font-family: 'Montserrat', sans-serif;
    margin-top: 0.2rem;
}

/* Desglose de costes */
.cost-breakdown {
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1.25rem;
}

.cost-breakdown-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.1rem;
    background: var(--primary, #2563eb);
    color: #fff;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.875rem;
    font-weight: 700;
}

.cost-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1.1rem;
    border-bottom: 1px solid var(--border, #e2e8f0);
    font-family: 'Montserrat', sans-serif;
    font-size: 0.84rem;
}

.cost-row:last-child {
    border-bottom: none;
}

.cost-row:nth-child(even) {
    background: var(--bg-alt, #f8fafc);
}

.cost-row .cr-label {
    color: var(--text-muted, #64748b);
    font-weight: 600;
}

.cost-row .cr-val {
    font-family: 'Ubuntu', monospace, sans-serif;
    font-weight: 700;
    color: var(--text, #1e293b);
}

.cost-row.cr-total {
    background: rgba(37, 99, 235, 0.06);
    font-weight: 700;
}

.cost-row.cr-total .cr-label {
    color: var(--text, #1e293b);
    font-size: 0.9rem;
}

.cost-row.cr-total .cr-val {
    color: var(--primary, #2563eb);
    font-size: 1.05rem;
}

/* Comparativa de modelos */
.compare-table-wrap {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border, #e2e8f0);
}

.compare-table-wrap table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
    min-width: 520px;
}

.compare-table-wrap thead {
    background: var(--primary, #2563eb);
    color: #fff;
}

.compare-table-wrap thead th {
    padding: 0.65rem 1rem;
    text-align: left;
    font-weight: 700;
    font-family: 'Montserrat', sans-serif;
    white-space: nowrap;
}

.compare-table-wrap thead th:not(:first-child):not(:nth-child(2)) {
    text-align: right;
}

.compare-table-wrap tbody tr {
    transition: background 0.1s;
}

.compare-table-wrap tbody tr:nth-child(even) {
    background: var(--bg-alt, #f8fafc);
}

.compare-table-wrap tbody tr:hover {
    background: rgba(37, 99, 235, 0.05);
}

.compare-table-wrap tbody tr.row-selected {
    background: rgba(37, 99, 235, 0.08);
    font-weight: 700;
}

.compare-table-wrap tbody td {
    padding: 0.55rem 1rem;
    border-bottom: 1px solid var(--border, #e2e8f0);
    font-family: 'Montserrat', sans-serif;
    vertical-align: middle;
    color: var(--text, #1e293b);
}

.compare-table-wrap tbody tr:last-child td {
    border-bottom: none;
}

.compare-table-wrap tbody td:not(:first-child):not(:nth-child(2)) {
    text-align: right;
    font-family: 'Ubuntu', monospace, sans-serif;
}

.provider-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.4rem;
    vertical-align: middle;
}

.cheapest-badge {
    display: inline-block;
    font-size: 0.62rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    background: rgba(34, 197, 94, 0.15);
    color: #16a34a;
    border-radius: 8px;
    margin-left: 0.3rem;
    font-family: 'Montserrat', sans-serif;
    vertical-align: middle;
}

.cost-bar-cell {
    min-width: 100px;
}

.cost-bar {
    height: 6px;
    border-radius: 3px;
    background: var(--primary, #2563eb);
    opacity: 0.6;
    transition: width 0.4s ease;
}

/* Chips de ejemplos rápidos */
.quick-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.75rem 0 1rem;
}

.quick-chips span {
    font-size: 0.75rem;
    color: var(--text-muted, #64748b);
    font-weight: 600;
    font-family: 'Montserrat', sans-serif;
    align-self: center;
}

.qchip {
    padding: 0.28rem 0.7rem;
    border: 1.5px solid var(--border, #e2e8f0);
    border-radius: 20px;
    background: transparent;
    color: var(--text, #1e293b);
    font-family: 'Montserrat', sans-serif;
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.14s;
    white-space: nowrap;
}

.qchip:hover {
    border-color: var(--primary, #2563eb);
    background: var(--primary, #2563eb);
    color: #fff;
}

/* Error Styles */
.parse-error {
    display: flex;
    justify-self: center;
    margin-bottom: 1rem;
    padding: 12px;
    color: red;
    border-radius: 8px;
    border: solid;
    border-width: 1px;
}

/* Responsive */
@media (max-width: 600px) {
    .results-dashboard {
        grid-template-columns: 1fr 1fr;
    }

    .results-dashboard .dash-primary {
        grid-column: 1 / -1;
    }

    .model-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 400px) {
    .model-grid {
        grid-template-columns: 1fr;
    }
}