/* Componentes reutilizables. Tailwind (CDN) se encarga del resto. */

:root {
    --brand: #4f46e5;
    --brand-dark: #4338ca;
    --good: #0ca30c;
    --warning: #fab219;
    --critical: #d03b3b;
}

html { scroll-behavior: smooth; }
body { font-family: 'Poppins', ui-sans-serif, system-ui, sans-serif; }
[hidden] { display: none !important; }

/* --- Botones --- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    padding: .55rem 1rem; border-radius: .6rem; font-weight: 600; font-size: .9rem;
    border: 1px solid transparent; transition: background-color .15s, color .15s, border-color .15s, box-shadow .15s;
    cursor: pointer; white-space: nowrap;
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgb(79 70 229 / .35); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-secondary { background: #fff; color: #334155; border-color: #cbd5e1; }
.btn-secondary:hover:not(:disabled) { background: #f1f5f9; }
.btn-ghost { background: transparent; color: #475569; }
.btn-ghost:hover:not(:disabled) { background: #f1f5f9; color: #0f172a; }
.btn-danger { background: #fff; color: #b91c1c; border-color: #fecaca; }
.btn-danger:hover:not(:disabled) { background: #fef2f2; }
.btn-success { background: #15803d; color: #fff; }
.btn-success:hover:not(:disabled) { background: #166534; }
.btn .spinner { width: 1rem; height: 1rem; border-width: 2px; border-left-color: currentColor; }

/* --- Formularios --- */
.form-label { display: block; margin-bottom: .35rem; font-size: .875rem; font-weight: 500; color: #334155; }
.form-input {
    width: 100%; padding: .6rem .75rem; border: 1px solid #cbd5e1; border-radius: .6rem; background: #fff;
    color: #0f172a; transition: border-color .15s, box-shadow .15s;
}
.form-input::placeholder { color: #94a3b8; font-weight: 300; }
.form-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgb(79 70 229 / .2); }
.form-input.is-invalid, .is-invalid .form-input { border-color: #dc2626; box-shadow: 0 0 0 3px rgb(220 38 38 / .15); }
textarea.form-input { resize: vertical; min-height: 5rem; }

/* --- Navegación --- */
.nav-link { white-space: nowrap; padding: .5rem .75rem; border-radius: .5rem; font-size: .9rem; font-weight: 500; color: #475569; }
.nav-link:hover { background: #f1f5f9; color: #0f172a; }
.nav-link.active { background: #eef2ff; color: var(--brand); font-weight: 600; }
#mobile-nav-links .nav-link { padding: .75rem 1rem; font-size: 1rem; }

/* --- Tarjetas y tablas --- */
.card { background: #fff; border: 1px solid #e2e8f0; border-radius: 1rem; }
.data-table th { padding: .75rem 1rem; text-align: left; font-size: .75rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: #64748b; background: #f8fafc; }
.data-table td { padding: .85rem 1rem; white-space: nowrap; }
.data-table tbody tr { border-top: 1px solid #f1f5f9; }
.row-link { cursor: pointer; }
.row-link:hover { background: #f8fafc; }
.row-link:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .6rem; border-radius: 9999px; font-size: .75rem; font-weight: 600; line-height: 1.25rem; }

/* --- Valoración Buena / Regular / Mala --- */
.rating-group { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.rating-option input { position: absolute; opacity: 0; pointer-events: none; }
.rating-option span {
    display: flex; align-items: center; justify-content: center; gap: .4rem; min-height: 3rem;
    border: 2px solid #e2e8f0; border-radius: .75rem; font-weight: 600; color: #475569; cursor: pointer;
    transition: all .15s; user-select: none;
}
.rating-option span:hover { border-color: #94a3b8; }
.rating-option input:focus-visible + span { box-shadow: 0 0 0 3px rgb(79 70 229 / .35); }
.rating-option input[value="Buena"]:checked + span { border-color: #15803d; background: #f0fdf4; color: #166534; }
.rating-option input[value="Regular"]:checked + span { border-color: #b45309; background: #fffbeb; color: #92400e; }
.rating-option input[value="Mala"]:checked + span { border-color: #b91c1c; background: #fef2f2; color: #991b1b; }
.question-card.is-invalid { border-color: #dc2626; box-shadow: 0 0 0 3px rgb(220 38 38 / .12); }

/* --- Tooltip --- */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after, [data-tooltip]:focus-visible::after {
    content: attr(data-tooltip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
    width: max-content; max-width: 16rem; padding: .5rem .65rem; border-radius: .5rem; background: #1e293b; color: #fff;
    font-size: .75rem; font-weight: 400; line-height: 1.35; white-space: normal; text-align: left; z-index: 50; pointer-events: none;
}

/* --- Spinner y skeleton --- */
.spinner { width: 36px; height: 36px; border: 4px solid rgb(0 0 0 / .1); border-left-color: var(--brand); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, #eef2f7 25%, #f8fafc 50%, #eef2f7 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: .5rem; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* --- Transición entre vistas --- */
.view-enter { animation: view-in .25s ease-out; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* --- Toasts --- */
.toast {
    pointer-events: auto; display: flex; align-items: flex-start; gap: .75rem; width: 100%; max-width: 24rem;
    padding: .9rem 1rem; border-radius: .75rem; background: #fff; border: 1px solid #e2e8f0; border-left-width: 4px;
    box-shadow: 0 10px 25px -5px rgb(0 0 0 / .12); font-size: .9rem;
    opacity: 0; transform: translateY(-8px); transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: none; }
.toast-success { border-left-color: #15803d; }
.toast-error { border-left-color: #b91c1c; }
.toast-info { border-left-color: var(--brand); }

/* --- Modales --- */
.modal-backdrop { position: fixed; inset: 0; z-index: 70; display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 1rem; background: rgb(15 23 42 / .45); }
@media (min-width: 640px) { .modal-backdrop { align-items: center; } }
.modal-panel { width: 100%; max-width: 32rem; margin: auto; background: #fff; border-radius: 1rem; box-shadow: 0 25px 50px -12px rgb(0 0 0 / .25); }

/* --- Firma --- */
.signature-box { position: relative; height: 16rem; border: 2px dashed #cbd5e1; border-radius: .75rem; background: #f8fafc; touch-action: none; }
.signature-box canvas { width: 100%; height: 100%; border-radius: .75rem; }
.signature-box::after { content: 'Firma aquí'; position: absolute; left: 1rem; bottom: .75rem; font-size: .8rem; color: #94a3b8; pointer-events: none; }

/* --- Impresión (detalle de evaluación) --- */
@media print {
    .no-print, header, #mobile-menu, #toast-container { display: none !important; }
    body { background: #fff; }
    .card { border: none; }
    main { padding: 0 !important; max-width: none !important; }
}
