/* ========================================
   Undo Close Dropdown
   ======================================== */

/* Wrapper — same pattern as volume-wrapper */
.undo-wrapper {
    position: absolute;
    right: 180px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
}

.undo-btn {
    position: relative;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.35rem;
    border-radius: 50%;
    transition: all 0.2s ease;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.undo-btn:hover {
    background: var(--border);
    color: var(--text);
}

/* Dropdown Panel */
.undo-dropdown {
    position: absolute;
    top: 100%;
    padding-top: 6px;
    right: -30px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2), 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 5000;
    min-width: 320px;
    max-width: 380px;
    height: 480px;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: undoDropdownIn 0.18s ease-out;
}

/* Shown via JS .open class on click */
.undo-dropdown.open {
    display: flex;
}

body.dark-theme .undo-dropdown {
    background: rgba(44, 44, 46, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

@keyframes undoDropdownIn {
    from {
        opacity: 0;
        transform: translateY(-6px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Scroll area — flex accordion */
.undo-scroll-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}




/* Tab sections — accordion flex items */
.undo-section {
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    transition: flex 0.15s ease;
}

.undo-section.collapsed {
    flex: 0 0 auto;
}

body.dark-theme .undo-section {
    border-color: rgba(255, 255, 255, 0.08);
}

.undo-section:last-child {
    border-bottom: none;
}

/* Section content — scrollable when expanded */
.undo-section-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(150, 150, 150, 0.3) transparent;
}

.undo-section-content::-webkit-scrollbar {
    width: 4px;
}

.undo-section-content::-webkit-scrollbar-track {
    background: transparent;
}

.undo-section-content::-webkit-scrollbar-thumb {
    background: rgba(150, 150, 150, 0.3);
    border-radius: 4px;
}

.undo-section-content.collapsed {
    display: none;
}

/* Chevron rotation */
.undo-section-header.collapsed .undo-section-chevron {
    transform: rotate(-90deg);
}

/* Section headers */
.undo-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 12px 14px 8px;
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
}

.undo-section-header .undo-section-chevron {
    transition: transform 0.15s ease;
}

.undo-section-header:hover {
    background: rgba(0, 0, 0, 0.02);
}

body.dark-theme .undo-section-header:hover {
    background: rgba(255, 255, 255, 0.03);
}

.undo-section-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.undo-section-icon {
    width: 16px;
    height: 16px;
    color: var(--primary);
    flex-shrink: 0;
    opacity: 0.8;
}

.undo-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.undo-section-count {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--border);
    padding: 1px 6px;
    border-radius: 8px;
    min-width: 18px;
    text-align: center;
}

body.dark-theme .undo-section-count {
    background: rgba(255, 255, 255, 0.1);
}

.undo-section-chevron {
    width: 14px;
    height: 14px;
    color: var(--text-secondary);
    opacity: 0.5;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.undo-section-header.collapsed .undo-section-chevron {
    transform: rotate(-90deg);
}

/* Section content — padding only */
.undo-section-content {
    padding: 0 6px 8px;
}

/* Tab items */
.undo-tab-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s ease;
}

.undo-tab-item:hover {
    background: var(--border);
}

body.dark-theme .undo-tab-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

/* Checkbox */
.undo-tab-check {
    width: 15px;
    height: 15px;
    border: 1.5px solid var(--text-secondary);
    border-radius: 4px;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}

.undo-tab-check.checked {
    background: var(--primary);
    border-color: var(--primary);
}

.undo-tab-check.checked svg {
    opacity: 1;
}

.undo-tab-check svg {
    width: 10px;
    height: 10px;
    color: white;
    opacity: 0;
    transition: opacity 0.12s ease;
}

/* Favicon */
.undo-tab-favicon {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    flex-shrink: 0;
    object-fit: contain;
}

/* Title + URL */
.undo-tab-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.undo-tab-title {
    font-size: 0.75rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
}

.undo-tab-url {
    font-size: 0.62rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0.7;
}

/* Time ago */
.undo-tab-time {
    font-size: 0.6rem;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
    opacity: 0.6;
}

/* Device section items */
.undo-device-name {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px 4px;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-secondary);
    opacity: 0.8;
}

.undo-device-name svg {
    width: 12px;
    height: 12px;
    opacity: 0.6;
}

/* Restore bar */
.undo-restore-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--primary);
    color: white;
    flex-shrink: 0;
    border-radius: 0 0 14px 14px;
    animation: undoRestoreIn 0.15s ease-out;
}

.undo-restore-bar.visible {
    display: flex;
}

body.dark-theme .undo-restore-bar {
    background: rgba(37, 99, 235, 0.9);
}

@keyframes undoRestoreIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.undo-restore-count {
    font-size: 0.75rem;
    font-weight: 600;
}

.undo-restore-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 5px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s ease;
}

.undo-restore-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* Empty state */
.undo-empty {
    padding: 16px 12px;
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

/* Scrollbar */
.undo-section-content::-webkit-scrollbar {
    width: 4px;
}

.undo-section-content::-webkit-scrollbar-track {
    background: transparent;
}

.undo-section-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

body.dark-theme .undo-section-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
}

/* Tooltip override — hide when dropdown is open */
.undo-dropdown.open~.undo-btn::after,
.undo-dropdown.open~.undo-btn::before,
.undo-wrapper.open .undo-btn::after,
.undo-wrapper.open .undo-btn::before {
    display: none !important;
}