/* ═══════════════════════════════════════════════════════════
   Dropdown menu — a trigger that opens a floating panel of items
   For account/company switchers, overflow (⋯) menus, context menus.
   Light by default (headers, toolbars); add .tn-menu--on-dark for the
   dark sidebar company switcher. Show the panel by adding .is-open to
   the .tn-menu wrapper (framework-agnostic).
   ═══════════════════════════════════════════════════════════ */

.tn-menu {
    position: relative;
    display: inline-block;
}

.tn-menu--block {
    display: block;
}

/* ── Trigger ── */
.tn-menu-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    width: 100%;
    padding: 8px 12px;
    background: var(--tn-bg-card);
    border: 1px solid var(--tn-border);
    border-radius: var(--tn-radius);
    color: var(--tn-text-primary);
    font-size: var(--tn-font-size-sm);
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: background var(--tn-transition), border-color var(--tn-transition);
}

.tn-menu-trigger:hover {
    background: var(--tn-bg-hover);
    border-color: var(--tn-text-muted);
}

.tn-menu-trigger:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--tn-accent);
}

/* Label fills the trigger; chevron sits at the end and flips when open */
.tn-menu-trigger-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tn-menu-chevron {
    flex-shrink: 0;
    font-size: 0.7em;
    opacity: 0.6;
    transition: transform var(--tn-transition);
}

.tn-menu.is-open .tn-menu-chevron {
    transform: rotate(180deg);
}

/* ── Panel ── */
.tn-menu-panel {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 200px;
    max-height: 320px;
    overflow-y: auto;
    background: var(--tn-bg-card);
    border: 1px solid var(--tn-border);
    border-radius: var(--tn-radius);
    box-shadow: var(--tn-shadow-lg);
    z-index: 1100;
    padding: 4px;
}

.tn-menu.is-open .tn-menu-panel {
    display: block;
}

/* Align the panel to the right edge of the trigger instead of the left */
.tn-menu-panel--end {
    left: auto;
    right: 0;
}

/* ── Items ── */
.tn-menu-item {
    display: flex;
    align-items: center;
    gap: 0.6em;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: var(--tn-radius-sm);
    background: transparent;
    color: var(--tn-text-primary);
    font-size: var(--tn-font-size-sm);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background var(--tn-transition);
}

.tn-menu-item > span {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tn-menu-item:hover {
    background: var(--tn-bg-hover);
}

.tn-menu-item:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--tn-accent);
}

.tn-menu-item.is-selected {
    color: var(--tn-accent);
    font-weight: 600;
}

/* Trailing check on the selected item */
.tn-menu-item .tn-menu-check {
    margin-left: auto;
    color: var(--tn-accent);
    flex-shrink: 0;
}

.tn-menu-item:disabled,
.tn-menu-item.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tn-menu-item--danger {
    color: var(--tn-danger);
}

.tn-menu-item--danger:hover {
    background: var(--tn-danger-light);
}

/* Section label + divider inside a panel */
.tn-menu-label {
    padding: 6px 10px 2px;
    font-size: var(--tn-font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--tn-text-muted);
}

.tn-menu-divider {
    height: 1px;
    margin: 4px 0;
    background: var(--tn-border-light);
}

/* ═══════════════════════════════════════════════════════════
   On-dark variant — the company switcher in the dark sidebar
   (matches TNonline / LogEasy: translucent white trigger, dark panel)
   ═══════════════════════════════════════════════════════════ */
.tn-menu--on-dark .tn-menu-trigger {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.08);
    color: var(--tn-text-on-dark-bright);
}

.tn-menu--on-dark .tn-menu-trigger:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.12);
}

.tn-menu--on-dark .tn-menu-panel {
    background: var(--tn-primary);
    border-color: rgba(255, 255, 255, 0.1);
}

.tn-menu--on-dark .tn-menu-item {
    color: var(--tn-text-on-dark);
}

.tn-menu--on-dark .tn-menu-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.tn-menu--on-dark .tn-menu-item.is-selected {
    color: var(--tn-text-on-dark-bright);
    background: var(--tn-sidebar-active);
}

.tn-menu--on-dark .tn-menu-check {
    color: var(--tn-accent);
}
