/* --- CORE STYLES --- */
html {
	overflow-y: scroll;
	overflow-x: hidden;
}

:root {
	--user-color: #ffffff;
    --bg-dark: #181818;
    --bg-panel: #222;
    --bg-item: #2a2a2a;
    --bg-item-active: #454545;
    --border: #333;
	scrollbar-width: none;
	-webkit-touch-callout: none;
	-webkit-user-select: none;
    user-select: none;
}

::-webkit-scrollbar { width: 0; background: transparent; }

body {
	background-color: var(--bg-dark);
	color: white;
	text-align: center;
	font-size: 16px;
	font-weight: bold;
	padding: 0 0 60px 0;
	margin: 0;
	font-family: Inter, Roobert, Helvetica Neue, Helvetica, Arial, sans-serif;
}

/* --- VISUALIZER --- */
#visualizer {
	background-color: var(--bg-dark);
	position: sticky;
	z-index: 100;
	display: flex;
	justify-content: center;
	align-items: center;
	height: 150px;
	top: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

#userName { width: auto; display: flex; justify-content: center; }

#editText {
	border: none;
	color: white;
	font-weight: bold;
	margin: 0;
	width: auto; 
    max-width: none; 
	resize: none;
    background-color: transparent;
	background-repeat: no-repeat;
	background-size: cover;
	background-position: center;
	overflow: visible;
	white-space: nowrap;
    text-align: center;
    font-size: 70px;
    font-family: inherit;
    padding: 0;
}
#editText:focus { outline: none; }

.text-effect {
	background-clip: text !important;
	background-size: 100% 100%; 
	-webkit-background-clip: text !important;
	-webkit-text-fill-color: transparent;
    color: transparent;
}

/* --- COLLAPSIBLE SECTIONS --- */
.section-header {
    max-width: 900px;
    margin: 10px auto;
    padding: 10px 20px;
    text-align: left;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
}

.section-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: #ddd;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-header:hover h3 {
    color: white;
}

.section-header i {
    font-size: 1rem;
    transition: transform 0.3s ease;
}

.section-header.collapsed i {
    transform: rotate(-90deg);
}

/* --- EDITOR LAYOUT --- */
#editor-wrapper {
    max-width: 900px;
    margin: 0 auto 30px auto;
    padding: 0 20px;
    text-align: left;
    overflow: hidden;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.left-controls, .right-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Fix för att knappar inte ska bryta texten */
.left-controls button, .right-controls button {
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Equal Height Columns */
.editor-columns {
    display: flex;
    gap: 20px;
    height: 500px; /* Fast höjd för hela containern */
}

/* --- LEFT COLUMN (LAYERS) --- */
.column-list {
    flex: 1;
    background: var(--bg-panel);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    height: 100%; /* Fyller 500px */
    box-sizing: border-box;
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: #ccc;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0; 
}

.scrollable-list {
    flex: 1; 
    overflow-y: auto;
    background: #1a1a1a;
    border-radius: 4px;
    padding: 5px;
    margin-bottom: 10px;
    min-height: 0;
}

/* --- RIGHT COLUMN (SETTINGS) --- */
.column-settings {
    flex: 1.5;
    background: var(--bg-panel);
    border-radius: 8px;
    padding: 15px;
    border: 1px solid var(--border);
    height: 100%; /* Fyller 500px */
    box-sizing: border-box;
    overflow-y: auto; /* Intern scroll om inställningarna blir för långa */
}

/* --- DRAG & DROP STYLES --- */
.layer-item {
    background: var(--bg-item);
    padding: 8px 10px;
    margin-bottom: 5px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    border-top: 3px solid transparent;
    border-bottom: 3px solid transparent;
    transition: background 0.1s, opacity 0.2s;
    position: relative;
    z-index: 1;
}

.layer-item:hover { background: #333; }
.layer-item.active { 
    background: var(--bg-item-active); 
    box-shadow: inset 0 0 0 1px #007bff; 
}

/* Style for hidden layers */
.layer-item.hidden-layer {
    opacity: 0.5;
}
.layer-item.hidden-layer .layer-name {
    text-decoration: line-through;
    color: #888;
}

.layer-item.dragging {
    opacity: 0.4;
    background: #000;
}

.layer-item.drag-over-top {
    border-top: 3px solid #007bff !important;
    z-index: 10;
}
.layer-item.drag-over-bottom {
    border-bottom: 3px solid #007bff !important;
    z-index: 10;
}

.layer-handle {
    cursor: grab;
    color: #666;
    margin-right: 1px;
    padding: 5px;
}
.layer-handle:active {
    cursor: grabbing;
}

.layer-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }

.layer-actions {
    display: flex;
    gap: 2px;
}

/* --- SETTINGS STYLES --- */
.setting-group { margin-bottom: 15px; }
.setting-group label { display: block; font-size: 0.8rem; color: #aaa; margin-bottom: 5px; }
.setting-row { display: flex; gap: 10px; align-items: center; margin-bottom: 5px; }

.text-box, .num-input, select {
    background: #111;
    border: 1px solid var(--border);
    color: white;
    padding: 8px;
    border-radius: 4px;
    width: 100%;
    box-sizing: border-box;
}
.num-input { width: 70px; }
input[type="color"] {
    background: none;
    border: none;
    width: 30px;
    height: 30px;
    cursor: pointer;
}

input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    margin-top: -6px; 
}
input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: #444;
    border-radius: 2px;
}

.stop-list { margin-top: 10px; }

.stop-item { 
    display: flex; 
    gap: 10px; 
    align-items: center; 
    margin-bottom: 8px; 
    background: #1a1a1a;
    padding: 5px;
    border-radius: 4px;
}
.stop-item .num-input { width: 60px; }

.color-alpha-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}
.color-alpha-row input[type="color"] {
    width: 40px;
    height: 30px;
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
}
.color-alpha-row input[type="range"] {
    flex-grow: 1;
    cursor: pointer;
}
.color-alpha-row span {
    font-size: 0.8rem;
    color: #aaa;
    width: 35px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* CSS Output */
.css-output-section { margin-top: 20px; }
.css-header { display: flex; justify-content: space-between; margin-bottom: 5px; font-size: 0.9rem; color: #ccc; }

#cleanCss, #seventvJson {
    width: 100%;
    height: 60px;
    background: #111;
    border: 1px solid var(--border);
    color: #00ff88;
    font-family: monospace;
    font-size: 0.8rem;
    padding: 10px;
    border-radius: 4px;
    resize: none;
    box-sizing: border-box;
}
#cleanCss:focus, #seventvJson:focus { border-color: #007bff; outline: none; }
#seventvJson { color: #88aaff; }

/* --- BUTTONS --- */
button { color: white; border: none; padding: 8px 15px; cursor: pointer; border-radius: 4px; font-weight: bold; font-size: 0.9rem; }
.small-btn { padding: 4px 8px; font-size: 0.8rem; background: #444; }
.small-btn:hover { background: #555; }
.red-btn { color: #ff6b6b; } /* Clear button style */
.red-btn:hover { background: #5a2a2a; color: white; }

.icon-btn { background: transparent; color: #888; padding: 2px; font-size: 0.9rem; }
.icon-btn:hover { color: #fff; }
.icon-btn.delete:hover { color: #ff4444; }
.icon-btn.visibility:hover { color: #aaa; }

/* NEW: Fixed width for visibility button to prevent layout shift */
.icon-btn.visibility {
    width: 26px;       /* Fixed width ensures changing icon doesn't move text */
    margin-right: 3px; /* Consistent spacing from layer name */
    display: inline-flex;
    justify-content: center;
}

.green-button { background-color: #28a745; }
.green-button:hover { background-color: #218838; }
.blue-button { background-color: #007bff; }
.blue-button:hover { background-color: #0056b3; }
.purple-button { background-color: #6f42c1; }
.purple-button:hover { background-color: #4a1a7a; }
.red-button { background-color: #dc3545; }
.red-button:hover { background-color: #a71d2a; }
.teal-button { background-color: #17a2b8; }
.teal-button:hover { background-color: #138496; }

/* --- SAVED PAINTS LIST --- */
#paintsSection, #globalPaintsSection { padding: 0 20px; }
.allCosmetics { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-bottom: 80px; }

.paintContainer {
	background-color: #1f1f1f;
	border-radius: 10px;
    transition: transform 0.2s ease;
    position: relative; 
}
.paintContainer:hover { transform: scale(1.05); }
.paintContainer.active { background-color: #454545; }

.paint {
	display: flex;
    flex-direction: column; 
    align-items: center; 
    justify-content: center;
	border-radius: 10px; 
    cursor: pointer; 
    font-size: 1rem; 
    overflow: hidden;
    word-wrap: break-word; 
    height: 2rem;
    padding: 0 10px;
    width: auto;
}

/* Delete Button on Saved Paint */
.delete-paint-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 10px;
    display: none; 
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    z-index: 10;
}
.paintContainer:hover .delete-paint-btn {
    display: flex;
}
.delete-paint-btn:hover {
    background: #a71d2a;
    transform: scale(1.1);
}

#globalPaintList p { font-weight: normal; font-size: 0.9rem; color: #888; }

/* --- SEARCH BAR --- */
#search-container {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 200;
    display: flex;
    align-items: center;
    background: rgba(30, 30, 30, 0.9);
    backdrop-filter: blur(5px);
    padding: 10px;
    border-radius: 50px;
    border: 1px solid #444;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}
.search-icon { color: #888; margin-right: 10px; margin-left: 5px; }
#search-field {
    background: transparent;
    border: none;
    color: white;
    font-size: 1rem;
    outline: none;
    width: 150px;
    transition: width 0.3s ease;
}
#search-field:focus { width: 200px; }

@media (max-width: 768px) {
    .editor-columns { flex-direction: column; height: auto; }
}