/**
 * fgp-dtc-picker.css — Picker de DTCs (Diagnostic Trouble Codes)
 *
 * Estilo basado en el demo A_v2 elegido por el cliente. Se renderiza
 * inline DEBAJO del mod-item "DTC OFF" del wizard de Nuevo Proyecto.
 *
 * Vinculado a fgp-dtc-picker.js — no cambiar nombres de clases sin
 * actualizar el JS también.
 */

/* ──────────────────────────────────────────────────────────────
   Contenedor (insertado tras .fgp-mod-item del DTC OFF)
   ────────────────────────────────────────────────────────────── */
.fgp-dtc-picker-panel {
    margin: 8px 0 14px 30px;
    padding: 16px;
    background: linear-gradient(135deg, #faf5ff 0%, #f0fdf4 100%);
    border: 2px dashed #c4b5fd;
    border-radius: 10px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1e293b;
}

.fgp-dtc-picker-panel * { box-sizing: border-box; }

/* ──────────────────────────────────────────────────────────────
   Loading state
   ────────────────────────────────────────────────────────────── */
.fgp-dtc-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 36px 20px;
    color: #475569;
    font-size: 13px;
    text-align: center;
}
.fgp-dtc-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #ede9fe;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: fgp-dtc-spin 0.8s linear infinite;
}
@keyframes fgp-dtc-spin {
    to { transform: rotate(360deg); }
}

/* ──────────────────────────────────────────────────────────────
   Error state
   ────────────────────────────────────────────────────────────── */
.fgp-dtc-error {
    padding: 18px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #991b1b;
    text-align: center;
    font-size: 13px;
}
.fgp-dtc-error-actions {
    margin-top: 12px;
}
.fgp-dtc-retry {
    padding: 8px 16px;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 12px;
}
.fgp-dtc-retry:hover { background: #b91c1c; }

/* ──────────────────────────────────────────────────────────────
   Header (título + badge selección)
   ────────────────────────────────────────────────────────────── */
.fgp-dtc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 10px;
}
.fgp-dtc-title {
    font-weight: 700;
    font-size: 14px;
    color: #1e293b;
}
.fgp-dtc-subtitle {
    font-size: 12px;
    color: #64748b;
    margin-top: 2px;
}
.fgp-dtc-sel-badge {
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}
.fgp-dtc-sel-badge.zero {
    background: #cbd5e1;
    color: #475569;
}

/* Variante "no soportado" del header */
.fgp-dtc-header.fgp-dtc-unsupported .fgp-dtc-title { color: #92400e; }
.fgp-dtc-header.fgp-dtc-unsupported .fgp-dtc-subtitle { color: #b45309; }

/* ──────────────────────────────────────────────────────────────
   Toolbar (buscador + botones)
   ────────────────────────────────────────────────────────────── */
.fgp-dtc-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.fgp-dtc-search {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px 8px 32px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-family: ui-monospace, monospace;
    font-size: 13px;
    background: white url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>") no-repeat 10px center;
    color: #1e293b;
}
.fgp-dtc-search:focus {
    outline: 2px solid #c4b5fd;
    outline-offset: -1px;
    border-color: #667eea;
}
.fgp-dtc-btn {
    padding: 8px 12px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    font-family: inherit;
    line-height: 1;
}
.fgp-dtc-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}
.fgp-dtc-btn-primary {
    background: #667eea;
    color: white;
    border-color: #667eea;
}
.fgp-dtc-btn-primary:hover {
    background: #5b21b6;
    border-color: #5b21b6;
}

/* ──────────────────────────────────────────────────────────────
   Tabs (categorías)
   ────────────────────────────────────────────────────────────── */
.fgp-dtc-tabs {
    display: flex;
    gap: 2px;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 10px;
    overflow-x: auto;
    padding-bottom: 0;
}
.fgp-dtc-tab {
    padding: 7px 12px;
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 600;
    color: #64748b;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 5px;
    user-select: none;
}
.fgp-dtc-tab:hover {
    color: #1e293b;
    background: white;
    border-radius: 6px 6px 0 0;
}
.fgp-dtc-tab.active {
    color: #667eea;
    border-color: #667eea;
    background: white;
    border-radius: 6px 6px 0 0;
}
/* "Todos" tab — separador visual */
.fgp-dtc-tab-first {
    border-right: 1px solid #e2e8f0;
    padding-right: 14px;
    margin-right: 4px;
}
.fgp-dtc-count {
    background: #f1f5f9;
    color: #64748b;
    padding: 2px 6px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    text-align: center;
}
.fgp-dtc-tab.active .fgp-dtc-count {
    background: #ede9fe;
    color: #667eea;
}
.fgp-dtc-sel-pill {
    background: #10b981;
    color: white;
    padding: 2px 6px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    min-width: 28px;
    text-align: center;
}

/* ──────────────────────────────────────────────────────────────
   Grid de DTCs (chips)
   ────────────────────────────────────────────────────────────── */
.fgp-dtc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    column-gap: 4px;
    row-gap: 6px;
    max-height: 360px;
    overflow-y: auto;
    padding: 4px;
}
.fgp-dtc-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 10px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    cursor: pointer;
    font-family: ui-monospace, monospace;
    font-size: 12px;
    user-select: none;
    transition: all 0.08s;
    min-width: 0;
    line-height: 1;
}
.fgp-dtc-chip:hover {
    border-color: #c4b5fd;
    background: #faf5ff;
    transform: translateY(-1px);
}
.fgp-dtc-chip input[type="checkbox"] {
    width: 13px;
    height: 13px;
    accent-color: #667eea;
    cursor: pointer;
    flex-shrink: 0;
    margin: 0;
}
.fgp-dtc-chip.checked {
    background: #ede9fe;
    border-color: #667eea;
}
.fgp-dtc-chip.checked .fgp-dtc-code {
    color: #5b21b6;
    font-weight: 700;
}
.fgp-dtc-chip .fgp-dtc-code {
    font-weight: 600;
    color: #4f46e5;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}
.fgp-dtc-chip .fgp-dtc-cat-tag {
    font-size: 9px;
    line-height: 1;
    color: #94a3b8;
    background: #f1f5f9;
    padding: 2px 4px;
    border-radius: 3px;
    flex-shrink: 0;
    font-weight: 700;
    letter-spacing: 0.03em;
}
.fgp-dtc-chip.checked .fgp-dtc-cat-tag {
    color: #5b21b6;
    background: #ddd6fe;
}
.fgp-dtc-empty {
    padding: 24px;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
    grid-column: 1 / -1;
}

/* ──────────────────────────────────────────────────────────────
   Footer (contador)
   ────────────────────────────────────────────────────────────── */
.fgp-dtc-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
    color: #64748b;
}
.fgp-dtc-counter strong {
    color: #1e293b;
    font-weight: 700;
}

/* ──────────────────────────────────────────────────────────────
   Variante "no soportado" — textarea libre
   ────────────────────────────────────────────────────────────── */
.fgp-dtc-textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px 14px;
    border: 1px solid #fbbf24;
    border-radius: 8px;
    background: #fffbeb;
    font-family: ui-monospace, monospace;
    font-size: 13px;
    color: #1e293b;
    resize: vertical;
    line-height: 1.5;
}
.fgp-dtc-textarea:focus {
    outline: 2px solid #fbbf24;
    outline-offset: -1px;
    border-color: #f59e0b;
}

/* ──────────────────────────────────────────────────────────────
   Modal "0 DTCs seleccionados"
   ────────────────────────────────────────────────────────────── */
.fgp-dtc-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.fgp-dtc-modal {
    background: white;
    border-radius: 12px;
    padding: 24px 28px;
    max-width: 460px;
    width: 100%;
    box-shadow: 0 24px 70px rgba(0,0,0,0.35);
}
.fgp-dtc-modal h3 {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
}
.fgp-dtc-modal p {
    margin: 0 0 18px;
    font-size: 14px;
    color: #475569;
    line-height: 1.5;
}
.fgp-dtc-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.fgp-dtc-modal-btn {
    padding: 11px 16px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    text-align: left;
    font-family: inherit;
    transition: all 0.15s;
}
.fgp-dtc-modal-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}
.fgp-dtc-modal-back {
    background: #667eea;
    color: white;
    border-color: #667eea;
}
.fgp-dtc-modal-back:hover {
    background: #5b21b6;
    border-color: #5b21b6;
}
.fgp-dtc-modal-uncheck {
    color: #dc2626;
    border-color: #fecaca;
}
.fgp-dtc-modal-uncheck:hover {
    background: #fef2f2;
    border-color: #f87171;
}

/* ──────────────────────────────────────────────────────────────
   Responsive — móvil: chips más compactos
   ────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .fgp-dtc-picker-panel {
        margin-left: 0;
        padding: 12px;
    }
    .fgp-dtc-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        max-height: 280px;
    }
    .fgp-dtc-chip {
        padding: 7px 8px;
        font-size: 11px;
    }
    .fgp-dtc-toolbar {
        gap: 6px;
    }
    .fgp-dtc-btn {
        padding: 7px 10px;
        font-size: 11px;
    }
}
