/* Import Poppins font */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

body {
    font-family: 'Poppins', Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f0f0f0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    background-color: #fff;
    padding: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

#logo {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    max-width: 65px;
    height: auto;
    margin: 0;
    fill: #ff4d4d;
}

h1 {
    margin: 0;
    color: #ff4d4d;
    font-family: 'Poppins', Arial, sans-serif;
    text-align: center;
}

.container {
    width: 800px;
    margin: 20px auto;
    padding: 20px;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

.info-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.2em;
/*    font-weight: bold;*/
    font-weight: 500;
    margin-bottom: 20px;
    padding: 10px;
    background-color: #f8f8f8;
    border-radius: 5px;
    border: 1px solid #e0e0e0;
}

#preset-display, #device-info {
    flex: 1;
}

#device-info {
    text-align: right;
    font-size: 0.9em;
    color: #666;
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 10px; /* This adds 10px spacing between flex items */
}

.controls > div {
    display: flex;
    align-items: center;
    flex: 1; /* This makes each div take up equal space */
}

.controls label {
    white-space: nowrap;
    margin-right: 10px;
}

.controls select {
    flex-grow: 1; /* This makes the select boxes fill the available space */
    min-width: 0; /* This allows the select to shrink below its default size if needed */
}

/* Adjust the last select to not have a right margin */
.controls select:last-child {
    margin-right: 0;
}

select {
    width: 100%;
    padding: 5px 10px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: #f8f8f8;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23007CB2%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    cursor: pointer;
}

select::-ms-expand {
    display: none;
}

select:focus {
    outline: none;
    border-color: #007CB2;
    box-shadow: 0 0 5px rgba(0,124,178,0.5);
}

select, .styled-select {
    width: 100%;
    padding: 5px 30px 5px 10px; /* Increased right padding */
    font-size: 16px;
    font-family: 'Poppins', Arial, sans-serif;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: #f8f8f8;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23007CB2%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    cursor: pointer;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}

.control-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.input-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    margin-top: 10px;
}

/* Ensure consistent height for all input types */
.input-container input[type="range"],
.input-container select,
.double-slider {
    height: 35px; /* Adjust this value as needed */
    margin: 0; /* Remove any margins */
}

/* Additional styling for better visual consistency */
.input-container input[type="range"] {
    margin: 0px 0; /* Adjust vertical margins to center the slider */
}

.input-container select {
    padding: 5px;
/*    margin-top: auto;*/
}


/* Update the ccSliders grid to ensure consistent sizing */
#ccSliders {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}


/* Common styles for all sliders */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 30px;
    border-radius: 5px;
    background: #d3d3d3;
    outline: none;
    opacity: 0.7;
    transition: opacity .2s;
    margin:0;
/*    margin: 7px 0;*/
}

input[type="range"]:hover {
    opacity: 1;
}

/* Remove default slider thumb for non-center sliders */
input[type="range"]:not(.center-slider)::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 0;
    height: 0;
}

input[type="range"]:not(.center-slider)::-moz-range-thumb {
    width: 0;
    height: 0;
    border: none;
}

/* Style for center sliders - rectangular handle */
input[type="range"].center-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 10px;
    height: 20px;
    background: #ff4d4d;
    cursor: pointer;
    border-radius: 2px;
}

input[type="range"].center-slider::-moz-range-thumb {
    width: 10px;
    height: 20px;
    background: #ff4d4d;
    cursor: pointer;
    border-radius: 2px;
    border: none;
}

/* Align sliders with dropdowns */
/*.control-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.input-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}
*/

/* Style the expression slider to match ccSliders */
.expression-slider {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.expression-slider label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

/* Apply common slider styles to expression slider */
#expression {
    /* Inherit common styles from input[type="range"] */
    margin-top: auto; /* Push the slider to the bottom of its container */
    height: 30px;
}

#expression::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 0;
    height: 0;
}

#expression::-moz-range-thumb {
    width: 0;
    height: 0;
    border: none;
}

.buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

button {
    padding: 10px 20px;
    font-size: 14px;
    font-family: 'Poppins', Arial, sans-serif;
    cursor: pointer;
    background-color: #f8f8f8;
    border: 1px solid #ccc;
    border-radius: 5px;
    transition: all 0.3s ease;
}

button:hover {
    background-color: #e0e0e0;
}

#presetButtons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 20px;
}

#presetButtons button.preset-button-active {
    background-color: #ff4d4d;
    color: white;
    border-color: #ff3333;
}

#presetButtons button {
    padding: 10px;
    font-size: 14px;
    text-align: center;
    background-color: #f8f8f8;
    border: 1px solid #ccc;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#presetButtons button:hover {
    background-color: #e0e0e0;
}

#presetButtons button.preset-button-active {
    background-color: #ff4d4d;
    color: white;
    border-color: #ff3333;
}

#presetButtons button.preset-button-active:hover {
    background-color: #ff3333;
}

#bypass.active {
    background-color: #ff4d4d;
    color: white;
}

#rampon.active {
    background-color: #ff4d4d;
    color: white;
}

#tap.active {
    background-color: #ff4d4d;
    color: white;
}

.config-container, .help-container {
    margin-top: 30px;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    overflow: hidden;
}

#toggle-config, #toggle-help {
    width: 100%;
    padding: 10px;
    background-color: #f8f8f8;
    border: none;
    border-bottom: 1px solid #e0e0e0;
    text-align: left;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

#toggle-config:hover, #toggle-help:hover {
    background-color: #e0e0e0;
}

.config-section, .help-section {
    padding: 15px;
    background-color: #ffffff;
}

.config-section h3 {
    margin-top: 0;
    color: black;
}

.help-section h2 {
    margin-top: 0;
    color: #ff4d4d;
}

.help-section ol {
    padding-left: 20px;
}

.help-section li {
    margin-bottom: 10px;
}

.hidden {
    display: none;
}

footer {
    background-color: #333;
    color: #fff;
    text-align: center;
    padding: 10px;
    margin-top: auto;
}

footer a {
    color: #fff;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

.styled-select {
    width: 100%;
    padding: 5px 10px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: #f8f8f8;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
/*    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23007CB2%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');*/
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    cursor: pointer;
    margin-top: 10px;
}

.styled-select::-ms-expand {
    display: none;
}

.styled-select:focus {
    outline: none;
    border-color: #007CB2;
    box-shadow: 0 0 5px rgba(0,124,178,0.5);
}

#preset-display {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex-grow: 1;
}

.preset-row {
    display: flex;
    align-items: center;
    width: 100%;
}

.preset-button-active {
    background-color: #ff4d4d;
    color: white;
    border-color: #ff3333;
}

#preset-number {
    font-weight: bold;
    margin-right: 10px;
    white-space: nowrap;
}

#preset-name {
    flex-grow: 1;
    padding: 5px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: #f8f8f8;
    margin-right: 10px;
}

#preset-name:focus {
    outline: none;
    border-color: #ff4d4d;
    box-shadow: 0 0 5px rgba(255, 77, 77, 0.5);
}

#save-preset, #save-to-preset {
    padding: 5px 10px;
    font-size: 14px;
    background-color: #ff4d4d;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    white-space: nowrap;
    min-width: 70px;
}

#save-preset:hover, #save-to-preset:hover {
    background-color: #ff3333;
}

#save-to-preset {
    margin-left: 5px;
    min-width: 85px; /* Increased width to accommodate "Save To..." */
}

#error-message {
    color: #ff0000;
    font-size: 14px;
    margin-top: 5px;
    width: 100%;
    text-align: left;
}

#success-message {
    color: #ff0000;
    font-size: 14px;
    margin-top: 5px;
    width: 100%;
    text-align: left;
}

#firmware-warning {
    background-color: #fff3cd;
    color: #856404;
    padding: 10px;
    margin-bottom: 20px;
    border: 1px solid #ffeeba;
    border-radius: 5px;
    font-size: 14px;
    line-height: 1.5;
}

#firmware-warning a {
    color: #0056b3;
    text-decoration: none;
    font-weight: bold;
}

#firmware-warning a:hover {
    text-decoration: underline;
}

.double-slider-container {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.double-slider-top {
 order:1;
}


.double-slider-label {
    order:2;
    flex-grow: 1;
    padding: 5px 10px;
    font-size: 14px;
    background-color: #f8f8f8;
    border: 1px solid #ccc;
    border-radius: 5px;
    text-align: center;
    cursor: pointer;
    margin-top: 10px; /* Added margin-bottom for spacing between label and slider */
}

.double-slider {
  -webkit-appearance: none;
  width: 100%;
  margin:0;
  height: 15px;
  border-radius: 5px;
  background: #d3d3d3;
  outline: none;
  opacity: 0.7;
  transition: opacity .2s;
}

.double-slider::-webkit-slider-thumb {
    flex-grow: 1;
  -webkit-appearance: none;
  appearance: none;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: #ff4d4d;
  cursor: pointer;
}

.double-slider::-moz-range-thumb {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: #ff4d4d;
  cursor: pointer;
}

.new-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 20px 0;
}

.new-buttons button {
    padding: 10px 15px;
    font-size: 14px;
    background-color: #f8f8f8;
    border: 1px solid #ccc;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.new-buttons button:hover {
    background-color: #e0e0e0;
}

.config-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

.config-buttons button {
    padding: 10px 20px;
    font-size: 16px;
    background-color: #f8f8f8;
    border: 1px solid #ccc;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.config-buttons button:hover {
    background-color: #e0e0e0;
}

.config-control {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
}

.config-control label {
    margin-bottom: 5px;
    font-weight: bold;
}

.config-control input[type="number"],
.config-control select {
    width: 100%;
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}

.config-control input[type="number"] {
    -moz-appearance: textfield;
}

.config-control input[type="number"]::-webkit-inner-spin-button,
.config-control input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.config-control {
    display: flex;
    flex-direction: column;
}

.config-control label {
    margin-bottom: 5px;
    font-weight: bold;
}

.config-control .input-wrapper {
    display: flex;
    align-items: center;
}

.config-control input[type="number"],
.config-control select {
    flex-grow: 1;
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}

.config-control .range-info {
    margin-top: 10px;
    margin-left: 10px;
    font-size: 14px;
    color: #666;
}

/* Dark mode styles */
body.dark-mode {
    background-color: #333;
    color: #f0f0f0;
}

.dark-mode header {
    background-color: #222;
    color: #fff;
}

.dark-mode .container {
    background-color: #444;
}

.dark-mode .info-display {
    background-color: #555;
    border-color: #666;
}

.dark-mode select,
.dark-mode .styled-select {
    background-color: #e0e0e0;
    color: #333;
    border-color: #666;
}

.dark-mode input[type="range"] {
    background: #555;
}

.dark-mode input[type="range"]::-webkit-slider-thumb {
    background: #ff4d4d;
}

.dark-mode input[type="range"]::-moz-range-thumb {
    background: #ff4d4d;
}

.dark-mode button {
    background-color: #555;
    color: #f0f0f0;
    border-color: #666;
}

.dark-mode button:hover {
    background-color: #666;
}

/* Updated styles for preset buttons in dark mode */
.dark-mode #presetButtons button {
    background-color: #555;
    color: #f0f0f0;
    border-color: #777;
}

.dark-mode #presetButtons button:hover {
    background-color: #666;
}

.dark-mode #presetButtons button.preset-button-active {
    background-color: #ff4d4d;
    color: #fff;
    border-color: #ff3333;
}

/* Updated styles for help and config sections in dark mode */
.dark-mode .config-container,
.dark-mode .help-container {
    border-color: #666;
}

.dark-mode #toggle-config,
.dark-mode #toggle-help {
    background-color: #555;
    color: #f0f0f0;
    border-color: #666;
}

.dark-mode #toggle-config:hover,
.dark-mode #toggle-help:hover {
    background-color: #666;
}

.dark-mode .config-section,
.dark-mode .help-section {
    background-color: #444;
    color: #f0f0f0;
}

/* Ensure headers in help and config sections are visible */
.dark-mode .config-section h3,
.dark-mode .help-section h2 {
    color: #ff4d4d;
}

.dark-mode footer {
    background-color: #222;
}

#darkModeToggle {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 5px 10px;
    background-color: #f0f0f0;
    color: #333;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.dark-mode #darkModeToggle {
    background-color: #333;
    color: #f0f0f0;
}

/* Ensure text inputs and labels are visible in dark mode */
.dark-mode input[type="text"],
.dark-mode input[type="number"] {
    background-color: #555;
    color: #f0f0f0;
    border-color: #666;
}

.dark-mode label {
    color: #f0f0f0;
}

/* Improve visibility of success and error messages in dark mode */
.dark-mode #success-message {
    color: #4CAF50;
}

.dark-mode #error-message {
    color: #ff6b6b;
}

.dark-mode #preset-name {
    background-color: #555;
    color: #f0f0f0;
    border-color: #777;
}

.dark-mode #preset-name:focus {
    border-color: #ff4d4d;
    box-shadow: 0 0 5px rgba(255, 77, 77, 0.5);
}

/* Updated styles for double slider label button in dark mode */
.dark-mode .double-slider-label {
    background-color: #555;
    color: #f0f0f0;
    border-color: #777;
}

.dark-mode .double-slider-label:hover {
    background-color: #666;
}

/* Ensure text inputs and labels are visible in dark mode */
.dark-mode input[type="text"],
.dark-mode input[type="number"] {
    background-color: #555;
    color: #f0f0f0;
    border-color: #666;
}

.dark-mode label {
    color: #f0f0f0;
}

/* Improve visibility of success and error messages in dark mode */
.dark-mode #success-message {
    color: #4CAF50;
}

.dark-mode #error-message {
    color: #ff6b6b;
}

/* Additional styles to ensure all interactive elements are visible in dark mode */
.dark-mode .config-control input[type="number"],
.dark-mode .config-control select {
    background-color: #555;
    color: #f0f0f0;
    border-color: #777;
}

.dark-mode .config-control .range-info {
    color: #bbb;
}

.dark-mode #device-info {
    color: #bbb;
}

/* Ensure the firmware warning is readable in dark mode */
.dark-mode #firmware-warning {
    background-color: #554400;
    color: #ffdd99;
    border-color: #775500;
}

.dark-mode #firmware-warning a {
    color: #ffaa00;
}

.dark-mode select option {
    background-color: #e0e0e0;
    color: #333;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        text-align: center;
        padding: 15px;
    }
    
    #logo {
        position: static;
        transform: none;
        margin-bottom: 10px;
        max-width: 120px;
    }
    
    h1 {
        font-size: 1.5em;
    }
}