/* 浮层：自绘下拉菜单、条目右键菜单、Toast 与消息弹窗。视觉与桌面版同源 */

/* 1. 自绘下拉菜单：触发器 + 弹出列表，原生 select 留在原地当数据源 */
.dropdown {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
    max-width: 100%;
}
.dropdown-source {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.dropdown-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
    min-width: 0;
    text-align: left;
    cursor: pointer;
}
.dropdown-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dropdown-arrow {
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform .15s;
}
.dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}
.dropdown-trigger:disabled,
.dropdown-trigger.disabled {
    opacity: .4;
    cursor: not-allowed;
}

.dropdown-menu {
    position: fixed;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 300px;
    overflow-y: auto;
    padding: 4px;
    background: var(--bg-list);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    animation: dropdownIn .12s ease-out;
}
.dropdown-menu[hidden] {
    display: none;
}
@keyframes dropdownIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
}
.dropdown-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 12.5px;
    line-height: 1.4;
    text-align: left;
    cursor: pointer;
}
.dropdown-option:hover,
.dropdown-option.highlight {
    background: var(--item-active);
}
.dropdown-option.active {
    color: var(--accent);
}
.dropdown-option:disabled {
    opacity: .45;
    cursor: not-allowed;
}
.dropdown-option-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dropdown-check {
    flex-shrink: 0;
    color: var(--accent);
    visibility: hidden;
}
.dropdown-option.active .dropdown-check {
    visibility: visible;
}
.dropdown-group-label {
    padding: 6px 10px 2px;
    color: var(--text-muted);
    font-size: 11px;
    letter-spacing: .4px;
}
/* 「新建」菜单：条目少、文字短，用固定宽度，不跟着触发器走 */
.new-item-menu {
    min-width: 148px;
}

/* 2. 条目右键菜单 */
.context-menu {
    position: fixed;
    background: var(--bg-list);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 4px;
    min-width: 160px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 2px;
    animation: dropdownIn 0.12s ease-out;
}
.context-menu-item {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background-color 0.12s, color 0.12s;
}
.context-menu-item:hover {
    background: var(--item-active);
}
.context-menu-item.danger {
    color: var(--danger);
}
.context-menu-item.danger:hover {
    background: var(--danger-bg);
}
.context-menu-divider {
    height: 1px;
    margin: 2px 4px;
    background: var(--border-light);
}

/* 3. Toast 提示 */
.toast-box {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast-item {
    background: var(--bg-titlebar);
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideUp 0.15s ease-out;
    max-width: 340px;
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.toast-item.is-leaving {
    animation: fadeOutUp 0.2s var(--ease-standard) forwards;
}
@keyframes fadeOutUp {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-6px); }
}
@media (prefers-reduced-motion: reduce) {
    .toast-item {
        transition: opacity 0.2s linear;
    }
    .toast-item.is-leaving {
        opacity: 0;
    }
}

/* 4. 消息弹窗：桌面版里由主进程独立开窗，网页版改为覆盖在工作区上的一层浮层 */
.dialog-mask {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(1, 4, 9, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: maskIn 0.12s ease-out;
}
@keyframes maskIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.dialog-box {
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px 20px 18px;
    background-color: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
    animation: dialogIn 0.14s ease-out;
}
@keyframes dialogIn {
    from { opacity: 0; transform: translateY(6px) scale(0.99); }
    to { opacity: 1; transform: none; }
}
.dialog-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.dialog-icon {
    font-size: 22px;
    flex-shrink: 0;
    margin-top: 1px;
    color: var(--accent);
}
.dialog-icon.warning { color: var(--warning); }
.dialog-icon.error { color: var(--danger); }
.dialog-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.dialog-message {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.5;
    word-break: break-word;
    user-select: text;
}
.dialog-detail {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    user-select: text;
}
.dialog-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.dialog-field-label {
    font-size: 12px;
    color: var(--text-secondary);
}
.dialog-input {
    width: 100%;
    background: var(--item-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-size: 13px;
    color: var(--text-primary);
    user-select: text;
}
.dialog-input:focus {
    border-color: var(--accent);
}
.dialog-input::placeholder {
    color: var(--text-muted);
}
.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.dialog-btn {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    border: 1px solid transparent;
    transition: background 0.15s, opacity 0.15s, color 0.15s;
}
.dialog-btn.default {
    color: var(--text-secondary);
}
.dialog-btn.default:hover {
    background: var(--item-hover);
    color: var(--text-primary);
}
.dialog-btn.primary {
    background: var(--accent);
    color: var(--accent-fg);
}
.dialog-btn.danger {
    background: var(--danger);
    color: #ffffff;
}
.dialog-btn.primary:hover,
.dialog-btn.danger:hover {
    opacity: 0.9;
}
