@import url('https://fonts.googleapis.com/css2?family=Pixelify+Sans:wght@400..700&display=swap');
:root {
    --bg-color: #1c1c1e; 
    --text-color: #f5f5f7;
    --primary-accent: #b10aff; 
    --secondary-accent: #3a3a3c; 
    --border-color: #424245;
    --container-bg: #2c2c2e;
    --font-family: 'Courier New', monospace, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    --border-radius: 12px; 
    --box-shadow: 0 4px 10px rgba(0,0,0,0.2), 0 1px 3px rgba(0,0,0,0.1);
    --box-shadow-inset: inset 0 1px 2px rgba(0,0,0,0.3);
    --input-bg: #3a3a3c;
    --input-text: #f5f5f7;
    --slider-track-bg: #48484a;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden; 
    font-size: 14px;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--secondary-accent); border-radius: var(--border-radius); }
::-webkit-scrollbar-thumb { background: var(--primary-accent); border-radius: var(--border-radius); }
::-webkit-scrollbar-thumb:hover { background: #b700ff; }

.top-bar {
    background: linear-gradient(180deg, rgba(44,44,46,0.95) 0%, rgba(44,44,46,0.85) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--box-shadow);
    position: relative;
    z-index: 100;
}

.top-bar h1 { font-size: 1.5em; font-weight: 600; margin: 0; color: var(--text-color); text-shadow: 0 1px 1px rgba(0,0,0,0.2); }
.top-buttons { display: flex; gap: 8px; }
.title {
    font-family: 'Pixelify Sans', monospace;
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    margin-right: auto;
}
.btn {
    background-color: var(--secondary-accent); color: var(--text-color); border: 1px solid var(--border-color);
    padding: 7px 14px; border-radius: var(--border-radius); cursor: pointer; font-size: 0.85em; font-weight: 500;
    transition: background-color 0.2s ease, transform 0.1s ease; box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.btn:hover { background-color: var(--primary-accent); color: white; border-color: var(--primary-accent); transform: translateY(-1px); }
.btn:active { transform: translateY(0px); background-color: #b700dc; }
.btn:disabled { background-color: var(--slider-track-bg); color: #888; cursor: not-allowed; border-color: var(--secondary-accent); }

.main-layout { display: flex; flex-grow: 1; overflow: hidden; }
.canvas-container {
    flex-grow: 1; display: flex; flex-direction: column; justify-content: center; align-items: center;
    background-color: var(--bg-color); padding: 20px; position: relative; overflow: hidden;
}
#uploadButtonContainer { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 10; }
#btnUploadImage {
    padding: 15px 30px; font-size: 1.1em; background-image: linear-gradient(45deg, var(--primary-accent) 0%, #b700ff 100%);
    color: white; border: none; box-shadow: 0 4px 15px rgba(132, 0, 255, 0.3);
}
#btnUploadImage:hover { background-image: linear-gradient(45deg, #b700ff 0%, #be00ee 100%); box-shadow: 0 6px 20px rgba(204, 0, 255, 0.4); }
#asciiCanvas {
    display: none; background-color: #000; object-fit: contain;
    box-shadow: var(--box-shadow); cursor: default;
}

.sidebar {
    width: 230px; min-width: 210px; background-color: var(--container-bg); padding: 15px;
    display: flex; flex-direction: column; gap: 15px; overflow-y: auto; border-left: 1px solid var(--border-color);
}
.icon-panel { 
    background-color: var(--secondary-accent); 
    padding: 5px; 
    border-radius: var(--border-radius); 
    box-shadow: var(--box-shadow-inset); 
    width: 36px;
    height: 100%;
}
.control-panel { background-color: var(--secondary-accent); padding: 15px; border-radius: var(--border-radius); box-shadow: var(--box-shadow-inset); }
.control-panel h2 {
    font-size: 1em; font-weight: 600; margin-top: 0; margin-bottom: 15px; color: var(--text-color);
    padding-bottom: 8px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center;
}
.control-item { margin-bottom: 12px; }
.control-item:last-child { margin-bottom: 0; }
.control-item label, .control-item .label-like { display: block; font-size: 0.85em; margin-bottom: 6px; color: #ccc; }
.control-item label span, .control-item .label-like span { font-weight: 500; color: var(--primary-accent); float: right; min-width: 30px; text-align: right; }
.control-item label:after, .control-item .label-like:after { content: ""; display: table; clear: both; }

input[type="range"] {
    width: 100%; cursor: pointer; accent-color: var(--primary-accent); background: transparent;
    -webkit-appearance: none; appearance: none; height: 18px; margin-top: 4px;
}
input[type="range"]::-webkit-slider-runnable-track { width: 100%; height: 6px; background: var(--slider-track-bg); border-radius: 3px; }
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none; margin-top: -5px; width: 16px; height: 16px;
    background: var(--primary-accent); border-radius: 50%; border: 2px solid var(--container-bg); box-shadow: 0 0 2px rgba(0,0,0,0.5);
}
input[type="range"]::-moz-range-track { width: 100%; height: 6px; background: var(--slider-track-bg); border-radius: 3px; }
input[type="range"]::-moz-range-thumb {
    width: 16px; height: 16px; background: var(--primary-accent); border-radius: 50%;
    border: 2px solid var(--container-bg); box-shadow: 0 0 2px rgba(0,0,0,0.5);
}

select, input[type="number"], input[type="text"] {
    width: 100%; padding: 8px 10px; border-radius: calc(var(--border-radius) - 4px); border: 1px solid var(--border-color);
    background-color: var(--input-bg); color: var(--input-text); font-size: 0.9em; box-sizing: border-box;
}
select:focus, input[type="number"]:focus, input[type="text"]:focus { outline: none; border-color: var(--primary-accent); box-shadow: 0 0 0 2px rgba(0,122,255,0.4); }
select:disabled, input[type="text"]:disabled { opacity: 0.5; cursor: not-allowed; }

.toggle-switch { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.toggle-switch .label-like { margin-bottom: 0; }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider-knob {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--slider-track-bg); transition: .4s; border-radius: 24px;
}
.slider-knob:before {
    position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px;
    background-color: white; transition: .4s; border-radius: 50%;
}
input:checked + .slider-knob { background-color: var(--primary-accent); }
input:checked + .slider-knob:before { transform: translateX(20px); }

.sub-control-item { padding-left: 15px; margin-top: 10px; padding-top: 8px; border-left: 2px solid var(--primary-accent); font-size: 12px;}
.sub-control > .toggle-switch { margin-bottom: 8px; }
#customCharSetInputContainer { display: none; }

#statusModal {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); padding: 12px 25px;
    background-color: var(--primary-accent); font-weight: 500; border-radius: var(--border-radius);
    box-shadow: var(--box-shadow); z-index: 1001; opacity: 0;
    transition: opacity 0.3s ease-in-out, bottom 0.3s ease-in-out; pointer-events: none;
    
}
#statusModal.show { opacity: 1; bottom: 30px; pointer-events: auto; }
.icon-btn {
    width: 38px;
    height: 38px;
    background: var(--secondary-accent);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 10px;
    color: var(--text-color);
    font-family: monospace;
}
.icon-btn:hover {
    background: #b10aff;
    transform: translateY(-2px);
}
.icon-btn:hover .tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(100%) translateX(0%);
}

.icon-btn img {
    width: 38px;
    height: 38px;
}
.icon-btn-small{
    width: 34px;
    height: 34px;
    background: var(--secondary-accent);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 10px;
    color: var(--text-color);
    font-family: monospace;
    display: flex;
}
.icon-btn-small:hover {
    background: #ba0aff;
    transform: translateX(+2px);
}
.icon-btn-small img {
    width: 32px;
    height: 32px;
}
.tooltip {
    position: absolute;
    right: -10px;
    top: 50%;
    transform: translateY(0%) translateX(0%);
    background: var(--secondary-accent);
    color: #ffffff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    border: 1px solid #b10aff;
    z-index: 1000;
}
@media (max-width: 768px) {
    .sidebar .control-panel {
        display: none; /* Hide control panels in the sidebar on small screens */
    }

    .sidebar .icon-panel {
        /* Removed flexbox properties and height/width adjustments */
        /* Position the icon panel absolutely */
        position: absolute;
        top: 0;
        left: 0;
        width: 50px; /* Set width to match sidebar width */
        height: 100%; /* Make icon panel take full height */
        display: flex !important; /* Ensure it's displayed as flex */
        flex-direction: column;
        align-items: center;
        gap: 15px; /* Increased gap for more space between buttons */
        padding-top: 15px; /* Add some padding at the top */
        z-index: 600; /* Give it a z-index higher than the canvas */
        background-color: var(--sidebar-bg); /* Add background color */
    }

    .sidebar {
        /* Removed absolute positioning and height adjustments */
        /* Keep it in the normal flow but with zero width */
        width: 0;
        min-width: 0;
        padding: 0; /* Remove padding */
        display: block; /* Change display to block */
    }

    .main-layout {
        /* Keep display as block */
        display: block;
        /* Adjusted margin-left to create space for the icon panel */
        margin-left: 10px; /* Space for the icon panel width */
        min-height: 100vh; /* Ensure main layout takes at least full viewport height */
        position: relative; /* Needed for positioning canvas-container */
    }

    .canvas-container {
        /* Keep absolute positioning */
        position: absolute;
        top: 0px;
        /* Added margin-left to create space for the icon panel */
        left: 30px;
        right: 0;
        bottom: 0;
        padding-bottom: 10vh;
        /* Keep padding-bottom for the bottom panel */
        /* padding-bottom: 33vh;  Assuming bottom panel height is 33vh */
    }

    #uploadButtonContainer {
        position: absolute; /* Position the upload button absolutely */
        top: 30%; /* Center vertically */
        left: 50%; /* Center horizontally */
        z-index: 500; /* Ensure it's above the canvas but below the bottom panel */
    }

    .bottom-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 33vh; /* Approximately 1/3 of viewport height */
        background-color: var(--container-bg);
        box-shadow: var(--box-shadow);
        z-index: 1000; /* Ensure it's above other content */
        overflow-y: auto;
        display: flex; /* Changed display to flex and added centering properties */
        justify-content: center; /* Center content horizontally */
        align-items: flex-start; /* Align content to the top vertically */
        padding: 15px;
        box-sizing: border-box;
    }

    /* New rule to make control panels inside bottom-panel take full width */
    .bottom-panel .control-panel {
        width: 100%; /* Make the control panel take the full width of the bottom panel */
    }
}


