/* Specific styles for add-item-group elements */
.add-item-group .new-item-input {
    margin-bottom: 0; /* Ensure no extra margin */
    box-sizing: border-box; /* Ensure padding is included in height */
}

.add-item-group .add-item-button {
    display: flex;
    align-items: center;
    justify-content: center; /* Center content horizontally within the button */
}

.config-tabs {
    width: 90%;
    max-width: 1000px;
    background-color: var(--block-color);
    border-radius: 10px;
    box-shadow: 0 0 20px var(--block-color);
    padding: 20px;
    box-sizing: border-box;
}

.tab-buttons {
    list-style: none;
    padding: 0;
    margin: 0 0 15px 0;
    display: flex;
    flex-wrap: wrap;
    border-bottom: 2px solid var(--secondary-color);
}

.tab-buttons li {
    padding: 10px 15px;
    margin-right: 5px;
    background-color: #FFFFFF; /* Changed */
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    color: var(--block-color); /* Changed */
    font-weight: bold;
    position: relative;
    display: flex;
    align-items: center;
    gap: 5px;
}

.tab-buttons li:hover:not(.active):not(.add-tab-button) {
    background-color: #f0f0f0; /* Changed */
}

.tab-buttons li.active {
    background-color: var(--secondary-color); /* Changed */
    color: var(--text-color); /* Changed */
    margin-bottom: -2px; /* Overlap border */
    border-bottom: 2px solid var(--secondary-color); /* Changed */
    z-index: 1;
}

.tab-buttons li.add-tab-button {
    background-color: #4a4a6e;
    font-size: 1.5em;
    padding: 10px;
    margin-left: auto;
    border-radius: 50%;
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 1;
    min-height: 25px; /* Added */
    min-width: 25px; /* Added */
}

.tab-buttons li.add-tab-button:hover {
    background-color: #6a6a9e;
}

.tab-close-button {
    background: none;
    border: none;
    color: inherit; /* Changed */
    font-size: 1em;
    cursor: pointer;
    padding: 0;
    margin-left: 5px;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.tab-close-button:hover {
    opacity: 1;
    color: inherit; /* Changed */
}

/* --- Drag and Drop Feedback --- */
.tab-button.dragging,
.item-list li.dragging {
    opacity: 0.5;
    background-color: rgba(var(--block-color-rgb), 0.7);
}

.tab-button.drag-over-top,
.item-list li.drag-over-top {
    border-top: 2px solid var(--primary-color);
}

.tab-button.drag-over-bottom,
.item-list li.drag-over-bottom {
    border-bottom: 2px solid var(--primary-color);
}

/* --- Draggable Icon --- */
.draggable-handle {
    width: 1em;
    height: 1em;
    margin-right: 5px;
    fill: currentColor; /* Inherit color from parent text */
    cursor: grab;
}

.tab-content-pane {
    display: none;
    padding: 15px 0;
    border-top: 2px solid var(--primary-color);
}

.tab-content-pane.active {
    display: block;
}

.tab-content-pane h3 {
    color: var(--primary-color);
    margin-top: 0;
}

.item-list {
    list-style: none;
    padding: 0;
    margin: 10px 0;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--secondary-color);
    border-radius: 5px;
    background-color: var(--background-color);
}

.item-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px dashed var(--secondary-color);
}

.item-list li:last-child {
    border-bottom: none;
}

.item-list li .remove-item-button {
    background-color: #cc3333;
    color: white;
    padding: 5px 8px;
    font-size: 0.8em;
    border-radius: 4px;
    box-shadow: none;
}

.item-list li .remove-item-button:hover {
    background-color: #ff4d4d;
    transform: none;
}

.add-item-group {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.add-item-group input {
    flex-grow: 1;
}

.config-actions {
    margin: 40px 0;
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* --- Custom Popup --- */
#popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1100; /* Increased z-index */
    transition: opacity 0.3s ease;
}

#popup-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#popup-box {
    background-color: var(--block-color);
    padding: 30px 40px;
    border-radius: 15px;
    border: 2px solid var(--primary-color);
    box-shadow: 0 0 30px rgba(var(--block-color-rgb), 0.5);
    text-align: center;
    max-width: 400px;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

#popup-overlay:not(.hidden) #popup-box {
    transform: scale(1);
}

#popup-message {
    font-size: 1.2em;
    margin: 0 0 25px 0;
    line-height: 1.5;
}

#popup-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.cancel-button {
    background-color: var(--text-color-base); /* Use variable */
    box-shadow: 0 4px 15px rgba(var(--text-color-base-rgb), 0.4); /* Shadow matches text color */
}

.cancel-button:hover {
    background-color: #bbb; /* Even lighter gray on hover */
}

/* --- Hamburger Menu --- */
#hamburger-menu {
    position: relative;
}

#hamburger-btn {
    font-size: 2em;
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    box-shadow: none;
    padding: 0 10px;
}

#hamburger-btn:hover {
    background-color: var(--secondary-color);
    transform: none;
}

#dropdown-menu {
    position: absolute;
    top: 50px;
    right: 0;
    background-color: var(--block-color);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    box-shadow: 0 4px 15px var(--block-color);
    display: flex;
    flex-direction: column;
    z-index: 110;
    width: max-content; /* Ensure width is based on content */
}

#dropdown-menu.hidden {
    display: none !important;
}

#dropdown-menu a {
    color: var(--text-color);
    text-decoration: none;
    padding: 12px 20px;
    border-bottom: 1px solid var(--secondary-color);
    white-space: nowrap;
}

#dropdown-menu a:last-child {
    border-bottom: none;
}

#dropdown-menu a:hover {
    background-color: var(--secondary-color);
}

/* --- Settings Popup --- */
#settings-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.3s ease;
}

#settings-popup-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}


#settings-popup-overlay #popup-box {
    background-color: var(--block-color);
    padding: 30px 40px;
    border-radius: 15px;
    border: 2px solid var(--primary-color);
    box-shadow: 0 0 30px rgba(var(--block-color-rgb), 0.5);
    text-align: center;
    max-width: 400px;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

#settings-popup-overlay:not(.hidden) #popup-box {
    transform: scale(1);
}


.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    font-size: 1.1em;
}

.setting-item label {
    margin-right: 20px;
}

#theme-color-picker {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 50px;
    height: 50px;
    background-color: transparent;
    border: none;
    cursor: pointer;
}
#theme-color-picker::-webkit-color-swatch {
    border-radius: 50%;
    border: 2px solid var(--border-color);
}
#theme-color-picker::-moz-color-swatch {
    border-radius: 50%;
    border: 2px solid var(--border-color);
}

#volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 150px;
    height: 10px;
    background: var(--secondary-color);
    outline: none;
    border-radius: 5px;
}

#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 25px;
    height: 25px;
    background: var(--primary-color);
    cursor: pointer;
    border-radius: 50%;
    border: 2px solid var(--block-color);
}

#volume-slider::-moz-range-thumb {
    width: 25px;
    height: 25px;
    background: var(--primary-color);
    cursor: pointer;
    border-radius: 50%;
    border: 2px solid var(--block-color);
}

#volume-value {
    min-width: 45px; /* Reserve space for "100%" text */
    text-align: right;
    margin-left: 10px;
}

/* --- Touch Drag Placeholder and Dragging Feedback --- */
.touch-drag-placeholder {
    background-color: rgba(var(--primary-color-rgb), 0.2); /* Light primary color */
    border: 1px dashed var(--primary-color);
    border-radius: 8px;
    margin: 5px 0; /* Match typical item spacing */
    box-sizing: border-box;
    visibility: hidden; /* Hidden by default, made visible during drag */
}

.dragging {
    cursor: grabbing;
    opacity: 0.9; /* Slightly transparent */
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2); /* Elevated shadow */
    transform: rotate(2deg); /* Slight rotation for visual flair */
}