/* Buttons */
button {
    font-family: inherit;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    border-radius: var(--radius);
    outline: none;
}

.icon-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--text-muted);
    position: relative;
}

.icon-btn:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.icon-btn-small {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius);
}

.icon-btn-small:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.tool-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-lg);
    position: relative;
}

.tool-btn:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.tool-btn.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent);
    box-shadow: inset 2px 0 0 var(--accent);
}

.primary-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--accent);
    color: white;
    font-weight: 500;
}

.primary-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.secondary-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    font-weight: 500;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.text-btn {
    background: transparent;
    color: var(--accent);
    padding: 6px 12px;
    font-size: 0.85rem;
}

.text-btn:hover {
    background: rgba(59, 130, 246, 0.1);
}

.icon-text-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 8px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    font-size: 0.8rem;
    border: 1px solid transparent;
}

.icon-text-btn:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.icon-text-btn i {
    width: 18px;
    height: 18px;
}

/* Panels and Properties */
.panel-section {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.panel-section h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.adj-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.adj-group label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.adj-group label span {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.adj-number {
    width: 50px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--accent);
    border-radius: 4px;
    text-align: center;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    outline: none;
    padding: 2px 4px;
}

.adj-number:focus {
    border-color: var(--accent);
}

.adj-number::-webkit-inner-spin-button,
.adj-number::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.action-buttons-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

/* Attributes inside toolbar */
.tool-attributes {
    width: 250px;
    position: absolute;
    left: 70px;
    top: 60px;
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transform: translateX(-10px);
    transition: var(--transition);
}

.tool-attributes.show {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

.attr-group label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 8px;
    color: var(--text-muted);
}

/* Inputs */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.color-picker-wrapper {
    width: 100%;
    height: 36px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

input[type="color"] {
    width: 120%;
    height: 120%;
    border: none;
    margin: -10%;
    cursor: pointer;
}

.color-palette {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-top: 10px;
}

.palette-swatch {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: transform 0.1s;
    padding: 0;
}

.palette-swatch:hover {
    transform: scale(1.1);
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.2);
}

.ui-select {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: var(--radius);
    outline: none;
    font-size: 0.9rem;
    cursor: pointer;
    font-family: inherit;
}

.ui-select option {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

/* Batch Panel */
.batch-panel {
    position: fixed;
    bottom: 20px;
    right: 320px;
    /* Offset from right sidebar */
    width: 320px;
    background: rgba(26, 29, 36, 0.9);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    z-index: 20;
    max-height: 400px;
    transform: translateY(0);
    transition: var(--transition);
}

.batch-panel.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
}

.batch-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.batch-header h4 {
    margin: 0;
    font-size: 0.95rem;
}

.batch-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.batch-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius);
    font-size: 0.85rem;
}

.batch-item-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.batch-item-status {
    color: var(--text-muted);
}

.batch-item-status.done {
    color: var(--success);
}

.batch-footer {
    padding: 12px;
    border-top: 1px solid var(--border-color);
}

/* Drag & Drop Overlay */
#drop-zone {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 17, 21, 0.85);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

#drop-zone.hidden {
    opacity: 0;
    pointer-events: none;
}

.drop-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--accent);
    font-size: 1.5rem;
    font-weight: 600;
    pointer-events: none;
}

.drop-message i {
    width: 64px;
    height: 64px;
}

/* Brush Cursor */
.brush-cursor {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: 100;
    transform: translate(-50%, -50%);
    /* Center cursor over mouse pointer */
    /* Inner white, outer black */
    border: 1px solid white;
    box-shadow: 0 0 0 1px black;
}

.brush-cursor.hidden {
    display: none;
}

/* Floating Text Input for Text Tool */
.canvas-text-input {
    position: absolute;
    background: transparent;
    border: 1px dashed rgba(255, 255, 255, 0.5);
    outline: none;
    padding: 0;
    margin: 0;
    line-height: 1.2;
    z-index: 50;
    white-space: pre;
    overflow: hidden;
    resize: none;
    min-width: 1em;
    min-height: 1.2em;
    transform-origin: top left;
}

.canvas-text-input:focus {
    border: 1px dashed rgba(255, 255, 255, 0.9);
}

/* Export Popover */
.export-popover {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 10px;
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    padding: 12px;
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    display: flex;
    gap: 8px;
    z-index: 50;
    opacity: 1;
    transform: translateY(0);
    transition: var(--transition);
}

.export-popover.hidden {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

.ui-input-text {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: var(--radius);
    outline: none;
    font-size: 0.9rem;
    font-family: inherit;
    width: 200px;
}

.ui-input-text:focus {
    border-color: var(--accent);
}

.primary-btn-small {
    background: var(--accent);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
}

.primary-btn-small:hover {
    background: var(--accent-hover);
}