/* --- Tag Selection Styles --- */
/* Common styles */
.tag_selection_area {
    display: flex;
    flex-wrap: wrap;
    gap: calc(8 * var(--ws-unit, 1px));
    align-items: center;
    box-sizing: border-box;
}

/* Sidebar Mode */
.new_event_section .tag_selection_area {
    padding: var(--spacing-sm);
    border-top: calc(1 * var(--ws-unit, 1px)) solid var(--border-color);
}

/* Window Mode */
.new_event_section_w .tag_selection_area {
    padding: var(--spacing-sm) var(--spacing-xs);
    border-top: calc(1 * var(--ws-unit, 1px)) solid var(--border-color);
}

.tag_list_selected {
    display: flex;
    flex-wrap: wrap;
    gap: calc(6 * var(--ws-unit, 1px));
}

.tag_chip {
    display: inline-flex;
    align-items: center;
    gap: calc(6 * var(--ws-unit, 1px));
    padding: calc(4 * var(--ws-unit, 1px)) calc(10 * var(--ws-unit, 1px));
    border-radius: var(--radius-full, calc(9999 * var(--ws-unit, 1px)));
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    color: var(--theme-text-emphasis, #fff);
    cursor: default;
    transition: transform 0.2s, background-color 0.2s;
    user-select: none;
    border: calc(1 * var(--ws-unit, 1px)) solid var(--border-subtle, rgba(255, 255, 255, 0.08));
}

.tag_chip_remove {
    cursor: pointer;
    font-size: var(--font-size-base);
    line-height: 1;
    opacity: 0.7;
    transition: opacity var(--duration-fast, 150ms) ease,
                transform 80ms var(--ease-out, cubic-bezier(0.23, 1, 0.32, 1));
}

.tag_chip_remove:hover {
    opacity: 1;
}

.tag_chip_remove:active {
    transform: scale(0.85);
}

.add_tag_btn {
    width: calc(24 * var(--ws-unit, 1px));
    height: calc(24 * var(--ws-unit, 1px));
    border-radius: 50%;
    border: calc(1 * var(--ws-unit, 1px)) solid transparent;
    background: transparent;
    color: var(--theme-text-muted, #888);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    font-size: calc(18 * var(--ws-unit, 1px));
    line-height: 1;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    transition: background-color var(--duration-fast, 150ms) ease,
                color var(--duration-fast, 150ms) ease,
                transform 80ms var(--ease-out, cubic-bezier(0.23, 1, 0.32, 1));
}

.add_tag_btn img,
.add_tag_btn svg {
    width: calc(16 * var(--ws-unit, 1px));
    height: calc(16 * var(--ws-unit, 1px));
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.add_tag_btn:focus {
    outline: none;
}

.add_tag_btn:hover,
.add_tag_btn.active,
.add_tag_btn.open {
    border-color: transparent !important;
    outline: none;
    color: var(--text-primary);
    background-color: var(--bg-hover, rgba(255, 255, 255, 0.1));
}

.add_tag_btn:active {
    transform: scale(0.92);
}

/* Custom Tag Dropdown Menu */
#tag_dropdown_menu {
    position: fixed;
    width: calc(220 * var(--ws-unit, 1px));
    background-color: var(--bg-secondary);
    border: calc(1 * var(--ws-unit, 1px)) solid var(--border-color);
    border-radius: var(--radius-md, calc(8 * var(--ws-unit, 1px)));
    z-index: 20001;
    box-shadow: 0 calc(8 * var(--ws-unit, 1px)) calc(32 * var(--ws-unit, 1px)) var(--theme-shadow, rgba(0, 0, 0, 0.4));
    padding: 0 0 calc(4 * var(--ws-unit, 1px)) 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tag_dropdown_list_container {
    position: relative;
    padding: 0;
}

.tag_dropdown_list {
    max-height: calc(250 * var(--ws-unit, 1px));
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    scrollbar-width: none;
    /* Firefox */
}

.tag_dropdown_list::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.tag_dropdown_item {
    display: flex;
    align-items: center;
    gap: calc(8 * var(--ws-unit, 1px));
    padding: 0 var(--spacing-sm, calc(8 * var(--ws-unit, 1px)));
    margin: var(--spacing-xs, calc(4 * var(--ws-unit, 1px))) var(--spacing-xs, calc(4 * var(--ws-unit, 1px))) 0 var(--spacing-xs, calc(4 * var(--ws-unit, 1px)));
    min-height: calc(32 * var(--ws-unit, 1px));
    border-radius: var(--radius-sm, calc(4 * var(--ws-unit, 1px)));
    cursor: pointer;
    transition: background-color var(--duration-fast, 150ms) ease, color var(--duration-fast, 150ms) ease;
    font-size: var(--font-size-base) !important;
    color: var(--text-secondary, #ccc);
    box-sizing: border-box;
    max-width: 100%;
    min-width: 0;
}

/* 태그 이름 span: 말줄임, 자연 크기를 가지되 오버플로우 시 수삵 */
.tag_dropdown_item span {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: text;
    outline: none;
}

/* X 버튼은 항상 우측 끝에 정렬 */
.tag_item_remove {
    flex-shrink: 0;
    margin-left: auto;
    opacity: 0;
    cursor: pointer;
    font-size: var(--font-size-base);
    color: var(--theme-text-muted, #666);
    transition: opacity var(--duration-fast, 150ms) ease, color var(--duration-fast, 150ms) ease;
    padding: calc(2 * var(--ws-unit, 1px)) calc(5 * var(--ws-unit, 1px));
    line-height: 1;
}

.tag_dropdown_item:hover {
    background-color: var(--theme-surface-hover, #333);
    color: var(--theme-text-emphasis, #fff);
}

.tag_dropdown_item.dragging {
    opacity: 0.4;
    background-color: var(--theme-surface-input, #444);
}

.tag_dropdown_item.drag-over {
    box-shadow: 0 calc(-2 * var(--ws-unit, 1px)) 0 #8B5CF6;
}


.tag_dot {
    width: calc(10 * var(--ws-unit, 1px));
    height: calc(10 * var(--ws-unit, 1px));
    border-radius: 50%;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform var(--duration-fast, 150ms) var(--ease-out, cubic-bezier(0.23, 1, 0.32, 1)), border-color var(--duration-fast, 150ms) ease;
    position: relative;
    border: calc(3 * var(--ws-unit, 1px)) solid transparent;
    /* Keep comfortable click area */
    background-clip: padding-box;
}

.tag_dot:hover {
    transform: scale(1.25);
}

.tag_dropdown_item.selected {
    background-color: rgba(139, 92, 246, 0.15);
    color: var(--theme-accent-text, #8B5CF6);
    font-weight: 600;
}
.tag_dropdown_item:hover .tag_item_remove {
    opacity: 1;
}

.tag_item_remove:hover {
    color: var(--theme-danger-text, #ff6b6b);
    transform: scale(1.2);
}

.tag_dropdown_item.editing span,
.tag_new_editing span {
    flex-grow: 1;
    background-color: var(--theme-surface-main, #191919) !important;
    color: var(--theme-text-primary, #d1d1d1) !important;
    border: calc(1 * var(--ws-unit, 1px)) solid var(--theme-border, #505050) !important;
    border-radius: calc(5 * var(--ws-unit, 1px)) !important;
    padding: calc(2 * var(--ws-unit, 1px)) calc(6 * var(--ws-unit, 1px)) !important;
    font-weight: bold !important;
    font-size: var(--font-size-base) !important;
    outline: none !important;
    box-sizing: border-box !important;
    min-width: 0;
    overflow: visible;
    text-overflow: clip;
    white-space: pre;
}

/* Color Picker & Create Section UI */
.tag_create_section {
    border-top: calc(1 * var(--ws-unit, 1px)) solid var(--theme-border, #333);
    padding-top: calc(12 * var(--ws-unit, 1px));
    display: flex;
    flex-direction: column;
    gap: calc(10 * var(--ws-unit, 1px));
}

.tag_create_input {
    width: 100%;
    background-color: var(--theme-surface-main, #1a1a1a);
    border: calc(1 * var(--ws-unit, 1px)) solid var(--border-color, rgba(255, 255, 255, 0.12));
    border-radius: var(--radius-sm, calc(6 * var(--ws-unit, 1px)));
    padding: calc(6 * var(--ws-unit, 1px)) calc(10 * var(--ws-unit, 1px));
    color: var(--theme-text-emphasis, #fff);
    font-size: var(--font-size-xs);
    outline: none;
    transition: border-color 0.2s;
}

.tag_create_input:focus {
    border-color: #8B5CF6;
}

.tag_color_picker {
    display: flex;
    gap: calc(6 * var(--ws-unit, 1px));
    flex-wrap: wrap;
    justify-content: flex-start;
}

.color_option {
    width: calc(18 * var(--ws-unit, 1px));
    height: calc(18 * var(--ws-unit, 1px));
    border-radius: 50%;
    cursor: pointer;
    border: calc(2 * var(--ws-unit, 1px)) solid transparent;
    transition: transform 0.1s;
}

.color_option:hover {
    transform: scale(1.15);
}

.color_option.selected {
    border-color: var(--theme-border, #fff);
    box-shadow: 0 0 calc(5 * var(--ws-unit, 1px)) rgba(var(--theme-foreground-rgb, 255, 255, 255), 0.3);
}

.tag_create_btn {
    background-color: #8B5CF6;
    color: #fff;
    border: none;
    border-radius: var(--radius-sm, calc(6 * var(--ws-unit, 1px)));
    padding: calc(8 * var(--ws-unit, 1px));
    font-size: var(--font-size-xs);
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.tag_create_btn:hover {
    background-color: #7c3aed;
}

.tag_dropdown_list_container .custom-scrollbar-track {
    top: 0;
    bottom: 0;
    right: calc(-2 * var(--ws-unit, 1px));
}

/* Tag Color Picker Popup */
.tag_color_popup {
    position: fixed;
    background-color: var(--theme-surface-panel, #242424);
    border: calc(1 * var(--ws-unit, 1px)) solid var(--border-color, rgba(255, 255, 255, 0.12));
    border-radius: var(--radius-lg, calc(14 * var(--ws-unit, 1px)));
    padding: calc(15 * var(--ws-unit, 1px));
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: calc(12 * var(--ws-unit, 1px));
    box-shadow: 0 calc(12 * var(--ws-unit, 1px)) calc(40 * var(--ws-unit, 1px)) var(--theme-shadow, rgba(0, 0, 0, 0.6));
    z-index: 20003;
    animation: tagColorPopIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    width: calc(210 * var(--ws-unit, 1px));
}

@keyframes tagColorPopIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateX(calc(15 * var(--ws-unit, 1px)));
    }

    to {
        opacity: 1;
        transform: scale(1) translateX(0);
    }
}

.color_popup_option,
.custom_preview_circle {
    width: calc(22 * var(--ws-unit, 1px));
    height: calc(22 * var(--ws-unit, 1px));
    border-radius: 50%;
    cursor: pointer;
    border: calc(2 * var(--ws-unit, 1px)) solid transparent;
    transition: transform var(--duration-fast, 150ms) var(--ease-out, cubic-bezier(0.23, 1, 0.32, 1)), border-color var(--duration-fast, 150ms) ease, box-shadow var(--duration-fast, 150ms) ease;
    flex-shrink: 0;
}

.color_popup_option:hover,
.custom_preview_circle:hover.valid {
    transform: scale(1.2);
    border-color: rgba(var(--theme-foreground-rgb, 255, 255, 255), 0.4);
}

.color_popup_option.selected,
.custom_preview_circle.valid {
    border-color: rgba(var(--theme-foreground-rgb, 255, 255, 255), 0.2);
}

.color_popup_option.selected {
    border-color: var(--theme-border, #fff);
    box-shadow: 0 0 calc(10 * var(--ws-unit, 1px)) rgba(var(--theme-foreground-rgb, 255, 255, 255), 0.5);
}

.custom_preview_circle {
    border: calc(1.5 * var(--ws-unit, 1px)) dashed var(--theme-border, #555);
    background-color: transparent;
}

.custom_preview_circle.valid {
    border-style: solid;
}

.custom_hex_input {
    grid-column: span 3;
    margin-top: 0;
    height: calc(23 * var(--ws-unit, 1px));
    background-color: var(--theme-surface-main, #1a1a1a);
    border: calc(1 * var(--ws-unit, 1px)) solid var(--theme-border, #444);
    border-radius: calc(11 * var(--ws-unit, 1px));
    padding: 0 calc(10 * var(--ws-unit, 1px));
    color: var(--theme-text-primary, #eee);
    font-size: var(--font-size-base);
    font-family: 'Pretendard', sans-serif;
    outline: none;
    text-align: center;
    transition: border-color var(--duration-fast, 150ms) ease, background-color var(--duration-fast, 150ms) ease;
    line-height: calc(23 * var(--ws-unit, 1px));
}

.custom_hex_input:focus {
    border-color: #8B5CF6;
    background-color: var(--theme-surface-panel, #222);
}
