/* Componentes compartidos del SWISH Design System (equivalente vanilla de
   design_handoff_automatizacion_reportes/prototype/rp-shell.jsx).
   Extraídos de automatizacion-reportes.css para reutilizarlos en otras páginas
   (Automatización de Reportes, Calculadora Ventas y RevShare). Mantienen el
   prefijo .rp- original para no tocar el HTML/JS ya existente.
   Tokens de design-tokens.css (importado desde styles.css): cargar este fichero
   después de styles.css y antes del CSS propio de cada página. */

/* ── Cabecera ─────────────────────────────────────────────────────────────── */
.rp-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-6);
    flex-wrap: wrap;
}

.rp-header-text {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.rp-eyebrow {
    font-size: 12px;
    font-weight: 600;
    color: var(--grey-500);
}

.rp-header-text h1 {
    margin: 0;
}

.rp-lead {
    margin: 0;
    color: var(--grey-500);
    max-width: 560px;
}

/* ── Botones genéricos ────────────────────────────────────────────────────── */
/* Reafirma explícitamente cada propiedad que la .btn genérica de styles.css
   fija de forma distinta (width:100%, max-width, margin, display:block) — si
   no, esas quedan "vivas" por cascada aunque display cambie de valor aquí. */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    width: auto;
    max-width: none;
    height: 40px;
    margin: 0;
    padding: 0 var(--space-7);
    border-radius: var(--radius);
    border: none;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.12s ease, opacity 0.12s ease;
}

.btn-primary {
    background: var(--coral-500);
    color: #fff;
}

.btn-primary:hover {
    background: var(--coral-600);
}

.btn-secondary {
    background: var(--grey-100);
    color: var(--grey-700);
}

.btn-secondary:hover {
    background: var(--grey-300);
}

.btn-danger {
    background: var(--coral-500);
    color: #fff;
}

.btn-danger:hover {
    background: var(--coral-600);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.rp-btn-icon {
    color: #fff;
}

/* ── Tarjeta de tabla ─────────────────────────────────────────────────────── */
.rp-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.rp-search-field {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    height: 44px;
    padding: 0 14px;
    border-radius: var(--radius);
    background: #fff;
    box-sizing: border-box;
    border: 1px solid var(--border-ui);
    flex: 1 1 260px;
    max-width: 360px;
}

.rp-search-field:focus-within {
    border-color: var(--grey-700);
}

.rp-search-field input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: none;
    font-family: inherit;
    font-size: 14px;
    color: var(--grey-700);
    background: transparent;
}

.rp-search-clear {
    display: inline-flex;
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    color: var(--grey-400);
}

.rp-icon-btn {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: var(--radius);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--grey-500);
    transition: background-color 0.12s ease, color 0.12s ease;
}

.rp-icon-btn:hover {
    background: var(--grey-100);
}

.rp-icon-btn[data-danger="true"]:hover {
    background: var(--coral-100);
    color: var(--coral-600);
}

/* ── Pill de frecuencia ───────────────────────────────────────────────────── */
.rp-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
    background: var(--grey-100);
    color: var(--grey-700);
}

.rp-pill[data-tone="daily"] { background: var(--blue-100); color: var(--blue-600); }
.rp-pill[data-tone="weekly"] { background: var(--green-100); color: rgb(0, 110, 83); }
.rp-pill[data-tone="monthly"] { background: var(--yellow-100); color: rgb(150, 70, 0); }
.rp-pill[data-tone="annual"] { background: var(--coral-100); color: var(--coral-700); }

/* ── Estados vacío / carga ────────────────────────────────────────────────── */
.rp-empty {
    padding: 64px var(--space-6);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    text-align: center;
}

.rp-empty-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--grey-100);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--grey-500);
}

.rp-empty h4 {
    margin: 0;
}

.rp-empty p {
    margin: 0;
    color: var(--grey-500);
}

.rp-skeleton {
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.rp-skeleton-row {
    height: 56px;
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, var(--grey-100) 25%, var(--grey-200) 37%, var(--grey-100) 63%);
    background-size: 400% 100%;
    animation: rp-skeleton-pulse 1.4s ease infinite;
}

@keyframes rp-skeleton-pulse {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}


/* ── Toast ────────────────────────────────────────────────────────────────── */
.rp-toast {
    position: fixed;
    bottom: var(--space-6);
    left: 50%;
    transform: translateX(-50%);
    z-index: 1200;
    background: var(--grey-800);
    color: #fff;
    border-radius: var(--radius);
    padding: var(--space-3) var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
}

.rp-toast[hidden] {
    display: none;
}

.rp-toast-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    background: var(--green-500);
    color: #fff;
}

.rp-toast[data-tone="danger"] .rp-toast-icon,
.rp-toast[data-tone="error"] .rp-toast-icon {
    background: var(--coral-500);
}

/* ── Modal de confirmación ────────────────────────────────────────────────── */
.rp-modal-scrim {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(22, 25, 36, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
}

.rp-modal-scrim[hidden] {
    display: none;
}

.rp-modal {
    width: 440px;
    max-width: 100%;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.rp-modal h3 {
    margin: 0;
}

.rp-modal-body {
    font-size: 14px;
    line-height: 1.4;
    color: var(--grey-600);
}

.rp-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    margin-top: var(--space-2);
}

.rp-text-input {
    height: 44px;
    border-radius: var(--radius);
    border: 1px solid var(--border-ui);
    padding: 0 14px;
    font-family: inherit;
    font-size: 14px;
    color: var(--grey-700);
    background: #fff;
    box-sizing: border-box;
    width: 100%;
}

.rp-text-input:focus {
    outline: none;
    border-color: var(--grey-700);
}

/* ── Checkbox / Radio accesibles (input real oculto + span visual) ───────── */
.rp-checkbox,
.rp-radio {
    position: relative;
    display: inline-flex;
    flex: none;
    cursor: pointer;
}

.rp-checkbox-input,
.rp-radio-input {
    position: absolute;
    width: 20px;
    height: 20px;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.rp-checkbox-box {
    /* El clic atraviesa la caja y llega al input real (oculto debajo). */
    pointer-events: none;
    width: 20px;
    height: 20px;
    flex: none;
    border-radius: var(--radius-sm);
    box-sizing: border-box;
    border: 1.5px solid var(--grey-400);
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: background-color 0.12s ease, border-color 0.12s ease;
}

.rp-checkbox-box .icon {
    display: none;
}

.rp-checkbox-input:checked + .rp-checkbox-box {
    border: none;
    background: var(--coral-500);
}

.rp-checkbox-input:checked + .rp-checkbox-box .icon {
    display: inline-block;
}

.rp-checkbox-input:indeterminate + .rp-checkbox-box {
    border: none;
    background: var(--coral-500);
    position: relative;
}

.rp-checkbox-input:indeterminate + .rp-checkbox-box::after {
    content: "";
    width: 10px;
    height: 2px;
    border-radius: 1px;
    background: #fff;
}

.rp-checkbox-input:focus-visible + .rp-checkbox-box {
    outline: 2px solid var(--grey-700);
    outline-offset: 2px;
}

.rp-checkbox--sm .rp-checkbox-box,
.rp-checkbox--sm .rp-checkbox-input {
    width: 18px;
    height: 18px;
}

.rp-radio-circle {
    pointer-events: none;
    width: 20px;
    height: 20px;
    flex: none;
    border-radius: 50%;
    box-sizing: border-box;
    border: 1.5px solid var(--grey-400);
    background: #fff;
    transition: border-color 0.12s ease, border-width 0.12s ease;
}

.rp-radio-input:checked + .rp-radio-circle {
    border: 6px solid var(--coral-500);
}

.rp-radio-input:focus-visible + .rp-radio-circle {
    outline: 2px solid var(--grey-700);
    outline-offset: 2px;
}

.btn-dark {
    background: var(--grey-800);
    color: #fff;
}

.btn-dark:hover {
    background: var(--ink);
}

/* ── Toast con acción (p. ej. "Deshacer") ─────────────────────────────────── */
.rp-toast-action {
    border: 0;
    background: transparent;
    padding: 0 0 0 var(--space-2);
    margin-left: var(--space-1);
    border-left: 1px solid rgba(255, 255, 255, 0.25);
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    color: var(--coral-300);
    cursor: pointer;
    white-space: nowrap;
}

.rp-toast-action[hidden] {
    display: none;
}

.rp-toast-action:hover {
    text-decoration: underline;
}

/* ── Segmentado (ui/segmented.js) ─────────────────────────────────────────── */
.rp-segmented {
    display: inline-flex;
    flex: none;
    gap: 2px;
    padding: 3px;
    border-radius: var(--radius);
    background: var(--grey-100);
}

.rp-segmented-btn {
    height: 34px;
    padding: 0 14px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--grey-600);
    cursor: pointer;
    white-space: nowrap;
}

.rp-segmented[data-size="sm"] .rp-segmented-btn {
    /* 32px: objetivo táctil mínimo (README §14), no los 26px del prototipo */
    height: 32px;
    padding: 0 10px;
    font-size: 12px;
}

.rp-segmented-btn[aria-checked="true"] {
    background: #fff;
    box-shadow: var(--shadow-sm);
    color: var(--ink);
    font-weight: 700;
}

.rp-segmented-btn:disabled {
    color: var(--grey-400);
    cursor: not-allowed;
}

.rp-segmented-btn:focus-visible,
.rp-dropbtn:focus-visible,
.rp-menu-item:focus-visible,
.rp-fchip-x:focus-visible {
    outline: 2px solid var(--coral-500);
    outline-offset: 2px;
}

/* ── Desplegable (ui/dropdown.js) ─────────────────────────────────────────── */
.rp-dropdown {
    position: relative;
}

.rp-dropbtn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 40px;
    padding: 0 10px 0 12px;
    border: 1px solid var(--border-ui);
    border-radius: var(--radius);
    background: #fff;
    font-family: inherit;
    font-size: 13px;
    color: var(--grey-600);
    cursor: pointer;
    white-space: nowrap;
}

.rp-dropbtn[data-active="true"] {
    border-color: var(--grey-800);
}

.rp-dropbtn strong {
    color: var(--ink);
    font-weight: 700;
}

.rp-dropbtn .icon {
    color: var(--grey-500);
}

.rp-popover {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    min-width: 240px;
    max-width: min(360px, calc(100vw - 32px));
    padding: 6px;
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow-lg);
    box-sizing: border-box;
}

.rp-popover--wide {
    min-width: 300px;
}

.rp-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 0 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}

.rp-menu-item:hover {
    background: var(--grey-100);
}

.rp-menu-item[aria-checked="true"],
.rp-menu-item[aria-pressed="true"] {
    background: rgb(255, 244, 244);
}

.rp-menu-item--stacked {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 10px;
}

.rp-menu-item-label {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
}

.rp-menu-item[aria-checked="true"] .rp-menu-item-label,
.rp-menu-item[aria-pressed="true"] .rp-menu-item-label {
    font-weight: 700;
}


.rp-menu-item-meta {
    font-size: 12px;
    color: var(--grey-600); /* --grey-500 no llega a 4,5:1 sobre el hover/selección */
    white-space: nowrap;
}

.rp-menu-item--stacked .rp-menu-item-meta {
    white-space: normal;
}

.rp-menu-divider {
    height: 1px;
    margin: 4px 0;
    background: var(--grey-200);
}

.rp-menu-list {
    display: flex;
    flex-direction: column;
    max-height: 300px;
    overflow-y: auto;
}

.rp-menu-check {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 0 10px;
    border-radius: 6px;
    font-size: 14px;
    color: var(--ink);
    cursor: pointer;
}

.rp-menu-check:hover {
    background: var(--grey-100);
}

.rp-menu-check:focus-within {
    outline: 2px solid var(--coral-500);
    outline-offset: -2px;
}

/* ── Chip de filtro activo (ui/chip.js) ───────────────────────────────────── */
.rp-fchip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 32px;
    padding: 0 4px 0 12px;
    border-radius: 16px;
    background: var(--grey-800);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.rp-fchip-dim {
    color: var(--grey-300);
    font-weight: 500;
}

.rp-fchip-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #fff;
    cursor: pointer;
}

.rp-fchip-x:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ── Solo para lectores de pantalla ───────────────────────────────────────── */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Pestañas subrayadas (ui/tabs.js) ─────────────────────────────────────── */
.rp-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
}

.rp-tab {
    border: 0;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    color: var(--grey-600);
    padding: 10px 14px;
    border-bottom: 2px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    white-space: nowrap;
    margin-bottom: -1px;
}

.rp-tabs[data-size="sm"] .rp-tab {
    font-size: 14px;
    padding: 10px 12px;
}

.rp-tab:hover {
    color: var(--ink);
}

.rp-tab[aria-selected="true"] {
    font-weight: 700;
    color: var(--ink);
    border-bottom-color: var(--coral-500);
}

.rp-tab:focus-visible {
    outline: 2px solid var(--grey-700);
    outline-offset: -2px;
    border-radius: var(--radius-sm);
}

.rp-tab-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--grey-600);
}

.rp-tab-count[data-hot="true"] {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    box-sizing: border-box;
    border-radius: 10px;
    background: var(--coral-600);
    color: #fff;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ── Avatar con iniciales (ui/avatar.js) ──────────────────────────────────── */
.rp-avatar {
    --rp-avatar-size: 36px;
    width: var(--rp-avatar-size);
    height: var(--rp-avatar-size);
    flex: none;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--rp-avatar-size) * 0.36);
    font-weight: 700;
    background: var(--blue-100);
    color: var(--blue-600);
}

.rp-avatar[data-size="sm"] { --rp-avatar-size: 28px; }
.rp-avatar[data-size="lg"] { --rp-avatar-size: 48px; }
.rp-avatar[data-tone="1"] { background: var(--green-100); color: rgb(0, 110, 83); }
.rp-avatar[data-tone="2"] { background: var(--yellow-100); color: rgb(150, 70, 0); }
.rp-avatar[data-tone="3"] { background: var(--coral-100); color: rgb(165, 32, 52); }
.rp-avatar[data-tone="muted"] { background: var(--grey-100); color: var(--grey-600); }

/* ── Drawer lateral (ui/drawer.js) ────────────────────────────────────────── */
.rp-drawer-scrim {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(22, 25, 36, 0.32);
    display: flex;
    justify-content: flex-end;
}

.rp-drawer-scrim[hidden] {
    display: none;
}

body.rp-drawer-open {
    overflow: hidden;
}

.rp-drawer {
    width: 520px;
    max-width: 100%;
    height: 100%;
    background: #fff;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    animation: rp-drawer-in 0.18s ease-out;
}

@keyframes rp-drawer-in {
    from { transform: translateX(24px); opacity: 0; }
    to { transform: none; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .rp-drawer { animation: none; }
}

.rp-drawer-head {
    padding: var(--space-5) var(--space-6) 0;
    border-bottom: 1px solid var(--grey-300);
}

.rp-drawer-head-row {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding-bottom: var(--space-5);
}

.rp-drawer-head-main {
    flex: 1;
    min-width: 0;
}

.rp-drawer-tabs:empty {
    display: none;
}

.rp-drawer-tabs .rp-tabs {
    margin-top: calc(var(--space-1) * -1);
}

.rp-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-6);
}

.rp-drawer-foot {
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--grey-300);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.rp-drawer-foot[hidden] {
    display: none;
}
