/* Optional: Pixel font */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
    --border-color-light: #a1a1a1;
    --border-color-dark: #000000;
    --button-bg: #c0c0c0;
    --button-text-color: #ffffff;
    --active-cell-bg: #008080;
}

html {
    font-size: 1vmin;
}

body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: 'Press Start 2P', cursive;
    background-color: #000;
    color: #ffffff;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

#app-container {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#aspect-lock {
    aspect-ratio: 16 / 9;
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    background-color: #008080;
}

#main-container {
    display: flex;
    flex-direction: row;
    justify-content: center;
    height: 100%;
    width: 100%;
    
}

#sounds-container, #layer-container{
    flex-shrink: 0; /* Prevent shrinking */
}

#layer-container {
    display: flex;
    width: fit-content;
    max-width: 12.5em;
    min-width: 12.5em
}

#top-window {
    flex-shrink: 0; /* Prevent shrinking */
}

#main-app-window {
    min-height: 0; /* Allow shrinking below content size */
    display: flex; /* Added */
    flex-direction: column; /* Added */
}

.sequencer {
    flex-grow: 1; /* Allow sequencer to grow */
    min-height: 0; /* Allow shrinking below content size */
    display: flex; /* Added */
    flex-direction: column; /* Added */
}

#sequencer-tools {
    display: flex;
    flex-direction: row;
    opacity: 1;
    flex-wrap: nowrap !important;
}

.grid-wrapper {
    flex-grow: 1;
    min-height: 0;
    overflow-y: hidden;
    display: flex;
    gap: 0.5rem; /* Added gap between note-labels and grid-container */
}

#note-labels {
    flex-shrink: 0; /* Prevent shrinking */
    flex-grow: 1;
    width: 5rem; /* Adjust as needed */
    height: inherit;
    font-size: 1rem;
}

#grid-container {
    flex-grow: 1; /* Allow grid to take up remaining space */
}

.retro-container {
    border: 0.155em solid var(--border-color-light);
    border-right-color: var(--border-color-dark);
    border-bottom-color: var(--border-color-dark);
    background-color: #757575;
    padding: 1rem;
}

.retro-button {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    border: 0.15rem solid var(--border-color-light);
    border-right-color: var(--border-color-dark);
    border-bottom-color: var(--border-color-dark);
    box-shadow: 0.2rem 0.2rem 0px 0px var(--border-color-dark);
    background-color: var(--button-bg);
    color: var(--button-text-color);
    text-shadow: 1px 1px 0px var(--border-color-light);
}

.retro-button:active {
    border: 0.155em solid var(--border-color-dark);
    border-right-color: var(--border-color-light);
    border-bottom-color: var(--border-color-light);
    box-shadow: 0.05rem 0.05rem 0px 0px var(--border-color-dark);
}

.retro-button.active {
    background-color: #555555; /* Dark grey for active state */
    border: 0.155em solid var(--border-color-dark);
    border-right-color: var(--border-color-light);
    border-bottom-color: var(--border-color-light);
    box-shadow: 1px 1px 0px 0px var(--border-color-dark);
}

.retro-input, .retro-checkbox {
    border: 0.155em solid var(--border-color-dark);
    border-right-color: var(--border-color-light);
    border-bottom-color: var(--border-color-light);
    background-color: #ffffff;
    color: #000000;
}

.grid-cell {
    background-color: #c0c0c0;
    /* border: 0,5px solid #808080; */
    cursor: pointer;
    position: relative;
}

.grid-cell.bar-even.row-even {
    background-color: #c0c0c0;
}

.grid-cell.bar-even.row-odd {
    background-color: #b0b0b0;
}

.grid-cell.bar-odd.row-even {
    background-color: #a0a0a0;
}

.grid-cell.bar-odd.row-odd {
    background-color: #909090;
}

.grid-cell.active {
    background-color: var(--active-cell-bg) !important;
    position: relative; /* Needed for pseudo-element positioning */
}

.grid-cell.selected {
    background-color: var(--active-cell-bg) !important;
    border: 0.15em solid #800000 !important;
    box-sizing: border-box; 
}


.grid-cell.erase-hover {
    opacity: 0.5;
}

.keybind-popup {
    position: absolute;
    bottom: calc(100% + 5px); /* Add 5px of space */
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: #fff;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}


.retro-button:hover .keybind-popup {
    opacity: 1;
}

#confirmation-dialog-overlay {
    z-index: 1000; /* Ensure it's on top of everything */
}

#confirmation-dialog-overlay.hidden {
    display: none;
}

#selection-rectangle {
    background-color: rgba(0, 128, 128, 0.3);
    border: 0.05em solid var(--active-cell-bg);
    pointer-events: none;
}

.grid-cell.active.highlighted::before {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    color: white;
    text-shadow: 1px 1px 2px black;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.note-label {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #656565;
    padding: 0.25rem;

    box-sizing: border-box;
    color: #ffffff;
    cursor: default;
}

.note-label.sharp-note-label {
    background-color: #505050; /* Slightly darker for sharp notes */
}

.bpm-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 8px;
    background: #4a5568; /* bg-gray-600 */
    outline: none;
    opacity: 0.7;
    transition: opacity .2s;
}

.bpm-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff; /* blue-400 */
    cursor: pointer;
}

.bpm-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff; /* blue-400 */
    cursor: pointer;
}

.layer-item {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 16rem;
    height: 8rem;
    min-height: 0;
    padding: 0.5rem;
    border: 0.15em solid var(--border-color-dark);
    background-color: #a0a0a0;
    margin-bottom: 0.5rem;
    margin-right: 3%;
    cursor: pointer;
    width: inherit;
    font-size: 1rem;
}

.layer-item.active-layer {
    background-color: #6a6a6a; /* Darker than #a0a0a0, lighter than #757575 6a6a6a(new)*/
    color: white;
    border-color: var(--border-color-light);
}

.layer-item-grid {
    flex: 1 1 0%;
    min-height: 0;
    background-color: #808080;
    overflow: hidden;

}

#layer-list {
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    flex-grow: 1;
    max-width: 100%;
}

/* Custom Scrollbar for Webkit browsers */
#layer-list::-webkit-scrollbar {
    width: 12px;
}

#layer-list::-webkit-scrollbar-track {
    background: #4a5568; /* Match BPM slider background */
    

}

#layer-list::-webkit-scrollbar-thumb {
    background-color: #ffffff; /* Match BPM slider thumb color */
    border-radius: 10px;
    border: 3px solid #4a5568; /* Creates padding around thumb */
}

.delete-layer-btn,
.mute-layer-btn,
.solo-layer-btn {
    width: 1.5em;
    height: 1.5em;
    background-color: #333333; /* Dark grey/black */
    color: #ffffff; /* White X */
    border: 0.1em solid var(--border-color-light);
    border-right-color: var(--border-color-dark);
    border-bottom-color: var(--border-color-dark);
    font-size: 0.8rem;
    line-height: 1.5em; /* Adjusted to match button height for vertical centering */
    text-align: center;
    padding: 0;
    cursor: pointer;
}

.delete-layer-btn:active,
.mute-layer-btn:active,
.solo-layer-btn:active {
    border: 0.1em solid var(--border-color-dark);
    border-right-color: var(--border-color-light);
    border-bottom-color: var(--border-color-light);
}

.mute-layer-btn {
    margin-left: 0.5rem; /* Space from solo button */
}

.delete-layer-btn {
    margin-left: 0.25rem; /* Space from mute button */
}

.mute-layer-btn.active {
    background-color: #ff0000; /* Red when muted */
}

.solo-layer-btn {
    margin-left: 0.25rem; /* Space from layer name */
}

.solo-layer-btn.active {
    background-color: #0000ff; /* Blue when soloed */
}

.layer-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
    min-width: 0;
    width: 0;
    font-size: 1rem;
}

.layer-name-input {
    background-color: #333;
    color: #fff;
    border: none;
    border-radius: 0;
    padding: 0 2px; /* Add a little horizontal padding for cursor */
    margin: 0;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    font-weight: bold;
    outline: 1px solid var(--border-color-light);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

#column-highlight {
    background-color: #80000095;
}

#bus-mixer-container {
    display: flex;
    gap: 1rem;
    flex-wrap: nowrap;
    flex-grow: 1;
    flex-shrink: 0;
    height: 100%;
}

/* Custom Scrollbar for Webkit browsers */
#bus-mixer-container::-webkit-scrollbar {
    height: 100%; /* 12px */
}

#bus-mixer-container::-webkit-scrollbar-track {
    background: #4a5568; /* Match BPM slider background */
    border-radius: 10px;
}

#bus-mixer-container::-webkit-scrollbar-thumb {
    background-color: #ffffff; /* Match BPM slider thumb color */
    border-radius: 10px;
    border: 3px solid #4a5568; /* Creates padding around thumb */
}

.bus-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between; /* Align items to the top and bottom */
    background-color: #c0c0c0;
    padding: 0.5rem;
    border: 0.155em solid var(--border-color-dark);
    border-right-color: var(--border-color-light);
    border-bottom-color: var(--border-color-light);
    height: 100%;
    width: 10%;
    gap: 0.25rem; /* Add a small gap */
    flex-shrink: 0; /* Prevent shrinking */
}

.bus-container.active-bus {
    background-color: #a0a0a0;
}

.bus-label {
    color: white;
    text-shadow: 1px 1px 0 var(--border-color-dark);
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-align: center;
}

.retro-slider-container {
    position: relative;
    width: 100%;
    /* height: 10%;   */
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1/1;

}

.retro-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 10%;
    height: 10%;
    background: #757575;
    outline: none;
    border: 0.14em solid var(--border-color-dark);
    flex-grow: 1;
    flex-shrink: 1;
    transform: rotate(-90deg);
    margin: auto;
}

.retro-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 1em;      /* Responsive: scales with font-size */
    height: 1.5em;   /* Responsive: scales with font-size */
    background: var(--button-bg);
    cursor: pointer;
    border: 0.14em solid var(--border-color-dark);
    box-shadow: 0.1em 0.1em 0 0 var(--border-color-dark);
}

.retro-slider::-moz-range-thumb {
    width: 1em;
    height: 1.5em;
    background: var(--button-bg);
    cursor: pointer;
    border: 0.14em solid var(--border-color-dark);
    box-shadow: 0.1em 0.1em 0 0 var(--border-color-dark);
}

.bus-buttons {
    display: flex;
    justify-content: space-around;
    width: 100%;
    margin-top: 0.25rem;
}

.bus-button {
    width: 20px;
    height: 20px;
    font-size: 12px;
    line-height: 1;
    text-align: center;
    padding: 0;
    border: 0.155em solid var(--border-color-light);
    border-right-color: var(--border-color-dark);
    border-bottom-color: var(--border-color-dark);
    background-color: var(--button-bg);
    color: var(--button-text-color);
    box-shadow: 1px 1px 0px 0px var(--border-color-dark);
}

.bus-button:active {
    border: 0.155em solid var(--border-color-dark);
    border-right-color: var(--border-color-light);
    border-bottom-color: var(--border-color-light);
    box-shadow: none;
}

.bus-button.active {
    background-color: #ff0000; /* Red when active */
}


.bus-container {
    position: relative; /* Add this to be a positioning context for children */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between; /* Align items to the top and bottom */
    background-color: #c0c0c0;
    padding: 0.5rem;
    border: 0.155em solid var(--border-color-dark);
    border-right-color: var(--border-color-light);
    border-bottom-color: var(--border-color-light);
    height: 100%;
    width: 10%;
    gap: 0.25rem; /* Add a small gap */
    flex-shrink: 0; /* Prevent shrinking */
}

.effects-button {
    position: absolute; /* Position relative to the bus-container */
    top: 0.25rem; /* Small offset from the top */
    right: 0.25rem; /* Small offset from the right */
    width: 2.5em;
    height: 1.5em;
    color: #ffffff;
    font-size: 0.8rem;
    text-align: center;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    text-shadow: #333333 2px 2px 0;
    z-index: 10; /* Ensure it's above other elements */
}


#effects-window-overlay {
    z-index: 1000;
}

#settings-window-overlay {
    z-index: 1000;
}

#settings-window-overlay.hidden {
    display: none;
}

#effects-window-overlay.hidden {
    display: none;
}

.effect-section .retro-slider,
.effect-section input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 8px;
    background: #4a5568;
    outline: none;
    opacity: 0.7;
    transition: opacity .2s;
}

.effect-section .retro-slider::-webkit-slider-thumb,
.effect-section input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
}

.effect-section .retro-slider::-moz-range-thumb,
.effect-section input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
}

.effect-section-container {
    background-color: #8a8a8a;
    border: 2px solid #a1a1a1;
    border-right-color: #000000;
    border-bottom-color: #000000;
    padding: 0.25rem;
    margin-bottom: 0.25rem;
    box-shadow: 5px 5px 0px 0px rgba(0,0,0,0.75);
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    flex-shrink: 0;
    height: 10.8rem;
}

.effect-section-container h3 {
    color: #ffffff;
    text-shadow: 2px 2px 0px #000000;
    margin-bottom: 0.25rem;
    font-size: 1rem;
}

.effect-section .grid {
    gap: 0.25rem;
}

.effect-section label {
    font-size: 0.8rem;
}

.effect-section input[type="range"] {
    height: 4px;
}

.effect-section input[type="range"]::-webkit-slider-thumb {
    width: 15px;
    height: 15px;
}

.effect-section input[type="range"]::-moz-range-thumb {
    width: 15px;
    height: 15px;
}

.effect-section .grid {
    gap: 0.5rem;
}

.effect-section label {
    font-size: 0.9rem;
}

.info-icon {
    display: inline-block;
    width: 1.2rem;
    height: 1.2rem;
    border-radius: 50%;
    background-color: #333;
    color: #fff;
    text-align: center;
    font-size: 0.8rem;
    line-height: 1.2rem;
    cursor: pointer;
    margin-left: 0.5rem;
    position: relative;
}

#global-tooltip {
    position: fixed;
    background-color: #333;
    color: #fff;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.9rem;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -120%);
}

#global-tooltip.visible {
    opacity: 1;
}

.flex-grow {
    flex-grow: 1;
}

.h-full {
    height: 100%;
}

.min-h-0 {
    min-height: 0;
}

.noselect {
  -webkit-user-select: none; /* Safari */
  -moz-user-select: none; /* Firefox */
  -ms-user-select: none; /* Internet Explorer/Edge */
  user-select: none; /* Non-prefixed version, currently supported by Chrome and Opera */
}

#bottom-window {
    overflow-y: hidden;
    overflow-x: auto;
    min-width: 0; /* Critical for flex items to allow scrolling */
    flex-grow: 1;
    max-height: 12.5em;
    min-height: 11em;
}

/* Custom Scrollbar for Webkit browsers */
#bottom-window::-webkit-scrollbar {
    height: 1rem; /* Increased height to accommodate the border "padding" */
    width: auto;
}

#bottom-window::-webkit-scrollbar-track {
    background: #4a5568; /* Match BPM slider background */
    border: solid 2px transparent; /* Add transparent border to create space */
    padding-top: 0.5rem;
}

#bottom-window::-webkit-scrollbar-thumb {
    background-color: #ffffff; /* Match BPM slider thumb color */
    border-radius: 10px;
    border: 3px solid #4a5568; /* Creates padding around thumb */
}

.sequencer-arrow-button {
    font-size: 2.5rem;
    padding-top: 1rem;
    padding-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sequencer-arrow-button p {
    line-height: 0;
    position: relative;
    bottom: 5px;
}


#sounds-panel {
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.5rem; /* Add padding for scrollbar spacing */
    min-height: 0;
    flex-grow: 1;
    max-width: 100%;
}

/* Custom Scrollbar for Webkit browsers */
#sounds-panel::-webkit-scrollbar {
    width: 12px;
}

#sounds-panel::-webkit-scrollbar-track {
    background: #4a5568; /* Match BPM slider background */
    border-radius: 10px;
}

#sounds-panel::-webkit-scrollbar-thumb {
    background-color: #ffffff; /* Match BPM slider thumb color */
    border-radius: 10px;
    border: 3px solid #4a5568; /* Creates padding around thumb */
}

.sound-select-button.active {
    background-color: #555555; /* Dark grey for active state */
    border: 0.155em solid var(--border-color-dark);
    border-right-color: var(--border-color-light);
    border-bottom-color: var(--border-color-light);
    box-shadow: 1px 1px 0px 0px var(--border-color-dark);
}

#export-dialog-overlay {
    z-index: 1000; /* Ensure it's on top of everything */
}

#export-dialog-overlay.hidden {
    display: none;
}

.mobile-message {
    display: none; /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: black;
    color: white;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 2000; /* On top of everything */
}

@media (max-aspect-ratio: 16/9) {
    #aspect-lock {
        width: 100vw;
        height: calc(100vw * 9 / 16);
    }
}

@media (min-aspect-ratio: 16/9) {
    #aspect-lock {
        height: 100vh;
        width: calc(100vh * 16 / 9);
    }
}

@media (max-width: 768px) {
    .mobile-message {
        display: flex;
    }

    #app-container {
        display: none;  
    }
}
#app-container {
    display: flex;
    align-items: center;
    justify-content: center;
}
#global-settings {
    width: 2rem;
    height: 2rem;
}
#global-settings p {
    font-size: 2rem;
    line-height: 1rem;
    margin: 0;
    padding: 0;
    position: absolute;
    top: 0rem;
    right: 0.282rem;
}

/* --- Custom Sound Button Slide Left for Delete --- */
.custom-sound-container {
    position: relative;
    width: 100%;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
}
.custom-sound-btn {
    width: 100%;
    transition: transform 0.2s;
    z-index: 0;
}
.custom-sound-container.show-delete .custom-sound-btn {
    transform: translateX(-44px); /* Slide left to make space for delete */
}
.custom-sound-delete {
    opacity: 0;
    pointer-events: none;
    position: absolute;
    right: 8px;
    top: 53%;
    transform: translateY(-55%) translateX(30px);
    width: 32px;
    height: 32px;
    z-index: 1;
    transition: opacity 0.2s, transform 0.2s;
    background: var(--button-bg, #c0c0c0);
    color: #a33;
    border: 0.15rem solid var(--border-color-light, #a1a1a1);
    border-right-color: var(--border-color-dark, #000000);
    border-bottom-color: var(--border-color-dark, #000000);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0.2rem 0.2rem 0px 0px var(--border-color-dark, #000000);
    padding: 0;

}
.custom-sound-delete:hover {
    background: #a33;
    color: #fff;
}
.custom-sound-container.show-delete .custom-sound-delete {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(-50%) translateX(0);
}

#splash-overlay {
  position: fixed;
  z-index: 9999;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s;
}
#splash-overlay.hide {
  opacity: 0;
  pointer-events: none;
}
#splash-image {
  max-width: 100vw;
  max-height: 100vh;
  width: 100vw;
  height: 100vh;
  object-fit: contain;
  aspect-ratio: 16/9;
  background: #111;
  border-radius: 0.5em;
  box-shadow: 0 0 32px #000a;
}
@media (max-aspect-ratio: 16/9) {
  #splash-image {
    width: 100vw;
    height: auto;
  }
}
@media (min-aspect-ratio: 16/9) {
  #splash-image {
    height: 100vh;
    width: auto;
  }
}