/*
 * Shared row-actions menu (kebab trigger + dropdown panel).
 *
 * Used by templates/menu/actions.html.twig wherever knp_menu_render hits
 * the actions template. Replaces a hand-authored Tailwind palette
 * (bg-white, gray-100, text-gray-700, text-red-600) with design-system
 * tokens. Behavior is unchanged: Flowbite still drives open/close via
 * data-dropdown-toggle. This file only restyles the surfaces.
 *
 * Reference targets (DESIGN.md): Linear's row-context menu (quiet trigger,
 * dense items), Raycast command palette items (heavy weight, restrained
 * color). Not Material kebab menus.
 */

.actions-menu__trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--text-soft);
    cursor: pointer;
    transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}

.actions-menu__trigger:hover {
    background: var(--surface);
    border-color: var(--line);
    color: var(--text);
}

.actions-menu__trigger:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.actions-menu__trigger[aria-expanded="true"] {
    background: var(--surface-strong);
    border-color: var(--line-strong);
    color: var(--text);
}

.actions-menu__trigger-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/*
 * Dropdown panel. Tinted neutral surface on top of the page frame.
 * The system shadow vocabulary is kept light (no `shadow-lg` Tailwind
 * blur), favoring a 1px line + tinted ambient cast.
 */

.actions-menu__panel {
    width: 200px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-strong);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow:
        0 18px 44px color-mix(in srgb, var(--color-primary) 8%, rgba(4, 23, 17, 0.32)),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .actions-menu__panel {
    background: color-mix(in srgb, var(--frame) 92%, var(--color-primary) 8%);
    box-shadow:
        0 18px 38px color-mix(in srgb, var(--color-primary) 14%, transparent),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/*
 * Opacity-only fade. We intentionally do NOT animate transform here:
 * Flowbite uses inline `transform: translate(...)` to position the panel
 * relative to its trigger, and a keyframed transform override would clobber
 * that positioning, dumping the dropdown into the top-left corner.
 */
@media (prefers-reduced-motion: no-preference) {
    .actions-menu__panel:not(.hidden) {
        animation: actions-menu-fade 140ms cubic-bezier(0.22, 1, 0.36, 1) both;
    }
}

@keyframes actions-menu-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.actions-menu__list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.actions-menu__form {
    margin: 0;
    display: block;
}

/*
 * Menu items. Single set of tokens; modifiers carry the color shift for
 * danger and the alignment shift for button-shaped items.
 */

.actions-menu__item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font-size: 13px;
    font-weight: 760;
    line-height: 1.4;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 180ms ease, color 180ms ease;
}

.actions-menu__item:hover {
    background: var(--surface);
    color: var(--text);
}

.actions-menu__item:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 1px;
}

.actions-menu__item:active {
    background: var(--surface-strong);
}

.actions-menu__item--button {
    /* Native <button> resets — keep typography in lockstep with the
       <a>-based items so Mover Arriba/Abajo match Editar/Borrar. */
    text-align: left;
    font-family: inherit;
}

/* --color-danger, not --color-accent. BrandingExtension maps --color-accent to the
   sponsor's own accent (getBrandAccent), so the destructive action inherited whatever
   colour that sponsor picked — for Berríos, #00992E, and "Borrar" rendered green.
   --color-danger is a semantic token in theme-tokens.css (#E64545 light / #FF6B6B
   dark) that sponsor branding does not override. */
/* Mixed toward --text rather than used raw: #E64545 on the light panel measures
   3.21:1, under the 4.5:1 AA floor (the previous accent green failed too, at the
   wrong hue). The mix darkens in light mode and lightens in dark mode, since --text
   flips with the theme, so it clears the floor in both while staying clearly red. */
.actions-menu__item--danger {
    color: color-mix(in srgb, var(--color-danger) 62%, var(--text));
}

.actions-menu__item--danger:hover {
    background: color-mix(in srgb, var(--color-danger) 14%, transparent);
    color: color-mix(in srgb, var(--color-danger) 62%, var(--text));
}

.actions-menu__item--danger:active {
    background: color-mix(in srgb, var(--color-danger) 22%, transparent);
}

@media (prefers-reduced-motion: reduce) {
    .actions-menu__trigger,
    .actions-menu__item {
        transition: none;
    }
}
