:root {
    /* Light theme variables */
    --background-primary-light: #f9f9f9;
    --background-secondary-light: #fff;
    --background-tertiary-light: #ddd;
    --background-accent-light: #4e453fbf;
    --background-translucent-light: #ffffffcc;
    --text-primary-light: #333;
    --text-secondary-light: #fff;
    --border-primary-light: #ddd;
    --border-secondary-light: grey;

    /* Dark theme variables */
    --background-primary-dark: #121212;
    --background-secondary-dark: #1e1e1e;
    --background-tertiary-dark: #2d2d2d;
    --background-accent-dark: #4e453fef;
    --background-translucent-dark: rgba(18, 18, 18, 0.75);
    --text-primary-dark: #eeeeee;
    --text-secondary-dark: #fff;
    --border-primary-dark: #404040;
    --border-secondary-dark: #666;

    /* Add form-specific colors for dark theme */
    --input-background-dark: #2d2d2d;
    --input-text-dark: #e0e0e0;
    --input-border-dark: #404040;
    --input-background-light: #ffffff;
    --input-text-light: #333333;
    --input-border-light: var(--border-primary-light);

    /* Common theme variables that don't change */
    --theme-primary: #6A9AD9;
    --theme-primary-hover: #6a9ad9ca;
    --theme-secondary: #C4B4A0;
    --theme-secondary-hover: #4E453F;

    --color-info: #6A9AD9CC;
    --color-success: #4CAF50CC;
    --color-warning: #FF9800CC;
    --color-error: #E53935CC;

    --color-success-dark: #4CAF50CC;

    /* Default to light theme */
    --background-primary: var(--background-primary-light);
    --background-secondary: var(--background-secondary-light);
    --background-tertiary: var(--background-tertiary-light);
    --background-accent: var(--background-accent-light);
    --background-translucent: var(--background-translucent-light);
    --text-primary: var(--text-primary-light);
    --text-secondary: var(--text-secondary-light);
    --border-primary: var(--border-primary-light);
    --border-secondary: var(--border-secondary-light);

    --background-info: var(--color-info);
    --background-success: var(--color-success);
    --background-warning: var(--color-warning);
    --background-error: var(--color-error);
    
    --border-accent: var(--theme-primary);
    --border-hover: var(--theme-primary-hover);
    
    --shadow-primary: 0 0 20px var(--border-secondary);
    
    --transition-fast: 0.1s ease-in-out;
    --transition-medium: 0.250s ease;
    --transition-slow: 1s ease;

    /* Add to default theme variables */
    --input-background: var(--input-background-light);
    --input-text: var(--input-text-light);
    --input-border: var(--input-border-light);

    /* Add dark theme specific colors */
    --theme-primary-dark: #585858;          /* Main button color in dark mode */
    --theme-primary-hover-dark: #686868;    /* Button hover color in dark mode */
}

/* Dark theme class */
:root[data-theme="dark"] {
    --background-primary: var(--background-primary-dark);
    --background-secondary: var(--background-secondary-dark);
    --background-tertiary: var(--background-tertiary-dark);
    --background-accent: var(--background-accent-dark);
    --background-translucent: var(--background-translucent-dark);
    --text-primary: var(--text-primary-dark);
    --text-secondary: var(--text-secondary-dark);
    --border-primary: var(--border-primary-dark);
    --border-secondary: var(--border-secondary-dark);
    
    --input-background: var(--input-background-dark);
    --input-text: var(--input-text-dark);
    --input-border: var(--input-border-dark);

    /* Update text colors for common elements */
    --theme-secondary-hover: var(--text-primary-dark);  /* Updates h1, h2 colors */

    /* Override theme colors for dark mode */
    --theme-primary: var(--theme-primary-dark);
    --theme-primary-hover: var(--theme-primary-hover-dark);

    --color-info: #6A9AD9;
    --color-success: #4CAF50;
    --color-warning: #FF9800;
    --color-error: #E53935;
}

:root[data-theme="dark"] {
    color: var(--text-primary-dark);
}

/* Fix selection container text in dark mode */
:root[data-theme="dark"] .selection-container {
    color: var(--text-primary-dark);
    background: var(--theme-primary-dark);
}

/* Ensure custom inputs have proper contrast */
:root[data-theme="dark"] .custom-input {
    color: var(--text-primary-dark);
}

/* Add smooth transitions for theme switching */
body * {
    transition: background-color var(--transition-fast),
                color var(--transition-fast),
                border-color var(--transition-fast);
}

@font-face {
    font-family: 'Roboto';
    src: url('../webfonts/Roboto-VariableFont_wdth,wght.ttf') format('truetype');
    font-weight: 100 900; /* Variable range of weights */
    font-stretch: 75% 100%; /* Variable width range (optional) */
    font-style: normal;
}


/* General

/* General Styling */
body {
    margin: 0;
    font-family: 'Roboto', sans-serif;
    background: var(--background-primary);
    display: flex;
    flex-direction: column;
    position: relative;
}

body * {
    box-sizing: border-box;
}

h1, h2 {
    margin: 0;
}

header {
    position: sticky;
    height: 50px;
    top: 0;
    z-index: 20;
    background: var(--background-primary);
    display: flex;
    justify-content: center;
    align-items: center;
}

h1, h2 {
    color: var(--theme-secondary-hover);
    transition: var(--transition-slow) color;
}

h3 {
    margin: 10px 0;
}


/* Inputs */
input, select, textarea {
    display: block;
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid var(--input-border);
    border-radius: 5px;
    font-size: 1rem;
    background-color: var(--input-background);
    color: var(--input-text);
}

/* Custom Input Wrapper */
.custom-input {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    color: var(--text-primary);
    cursor: pointer;
    flex: 1 1 auto;
}

/* Hide the Native Input */
.custom-input input {
    display: none;
}

/* Checkbox and Radio Styles */
.custom-checkbox,
.custom-radio {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--theme-primary);
    background-color: var(--background-secondary);
    position: relative;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Checkbox Specific */
.custom-checkbox {
    border-radius: 4px;
}
.custom-checkbox::after {
    content: '';
    width: 10px;
    height: 10px;
    background-color: var(--theme-primary);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.2s ease-in-out;
}

/* Radio Specific */
.custom-radio {
    border-radius: 50%;
}
.custom-radio::after {
    content: '';
    width: 10px;
    height: 10px;
    background-color: var(--theme-primary);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    border-radius: 50%;
    transition: transform 0.2s ease-in-out;
}

/* Checked State */
.custom-input input:checked + .custom-checkbox::after,
.custom-input input:checked + .custom-radio::after {
    transform: translate(-50%, -50%) scale(1);
}

.custom-input input:checked + .custom-checkbox,
.custom-input input:checked + .custom-radio {
    background-color: var(--theme-primary);
    border-color: var(--theme-primary-hover);
}

/* Focus State */
.custom-input input:focus-visible + .custom-checkbox,
.custom-input input:focus-visible + .custom-radio {
    outline: 2px dashed var(--theme-primary);
    outline-offset: 2px;
}

/* Hover Effects */
.custom-checkbox:hover,
.custom-radio:hover {
    border-color: var(--theme-primary-hover);
}


/* Scrollable Selection Styles */
.scrollable-selection {
    display: flex;
    flex-direction: row;
    align-items: center;
    min-width: 50%;
    position: relative;
}

.scroll-arrow {
    border: none;
    padding: 5px;
    width: 100%;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

.scroll-arrow:hover {
    background: var(--theme-primary-hover);
}

.selection-container {
    overflow: hidden;
    height: 50px; /* Adjust based on visible area */
    width: 100%;
    position: relative;
    border: 1px solid var(--border-primary);
    background: var(--theme-primary);
    color: var(--text-secondary);
    border-radius: 5px;
    font-weight: bold;
}

.nav-items {
    position: absolute;
    right: 0;
    top: 0;
    display: flex;
    height: 100%;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.selection-container .nav-items > button {
    height: 50%;
    padding: 0;
    width: 100% !important;
}

.selection-container .nav-items > button:hover {
    background: var(--text-secondary);
    color: var(--theme-primary);
}

.selection-items {
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    padding-right: 30px;
}

.selection-item {
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 5px;
    transition: background-color 0.3s ease;
}

.selection-item:hover {
    background: var(--theme-primary-hover);
    color: var(--text-secondary);
}

/* Buttons */
button {
    background: var(--theme-primary);
    color: var(--text-secondary);
    padding: 10px 15px;
    border: none;
    font-weight: bold;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition-medium) all;
    display: flex;
    justify-content: center;
    align-items: center;
}

button:not(.no-bg):hover{
    background: var(--background-info);
}

button.cancel {
    flex-grow: 0;
}

button.cancel:hover {
    background: var(--color-error);
}

button.cta:hover {
    background: var(--theme-primary-hover);
}

button.warn:hover {
    background: var(--color-warning);
}

button.warning:hover{}

/* App Layout */
.app {
    min-height: calc(100vh - 110px);
    display: flex;
    flex-direction: column;
}

.hidden:not(.sticky) {
    display: none !important;
}

/* Tabs */
.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
}

.app > .tab-content {
    background: var(--background-secondary);
}

.tab-content.active {
    display: flex;
    position: relative;
    flex-direction: column;
}

section {
    padding: 15px;
    display: flex;
    flex-direction: column;
}

section.main {
    flex-grow: 1;
}

section.debug {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
}

section.version {
    flex-direction: row;
    justify-content: space-between;
    flex-wrap: wrap;
}

section#settings-container > section{
    padding-left: 0;
    padding-right: 0;
}

.version .header {
    width: 100%;
}

.version #motor_selection h3 {
    width: 100%;
    flex-grow: 1;
}

.version #motor_selection {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
}

.version select#manual_motor_type {
    margin: 0 20px 0 0;
    flex: 1;
}

section.sticky {
    position: fixed;
    background-color: var(--background-translucent);
    backdrop-filter: blur(10px);
    bottom: 60px;
    border-top: 1px solid var(--border-primary);
    box-shadow: var(--shadow-primary);
    transform: translateY(0);
    transition: var(--transition-medium) transform, var(--transition-medium) height;
    visibility: visible;
    max-height: 75vh;
    width: 100%;
    z-index: 10;
}

section.sticky.fullscreen {
    position: fixed;
    top: 50px;
    left: 0;
    width: 100vw;
    max-height: none;
}

section.sticky.hidden {
    transform: translateY(100%);
    visibility: hidden;
    width: 100%;
    position: absolute;
    overflow:hidden;
    height: 0;
    padding: 0;
}

section .header {
    position: relative;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 10px;
    width: 100%;
}

section .header h2 {
    flex-grow: 1;
}

section .header #open-settings-button:hover{
    color: var(--theme-primary);
}

/* Close Button Styling */
button.no-bg {
    background: none;
    border: none;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-primary);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    height: 100%;
    width: auto;
    aspect-ratio: 1 / 1;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-left: 10px;
}

.close-button:hover {
    color: var(--color-error);
}

.fullscreen-button:hover {
    color: var(--color-warning);
}

section .header .add-button {
    height: 35px;
    width: 35px;
    padding: 0;
}

/* Playlist */
.add-to-playlist {
    margin-top: 15px;
}

.add-to-playlist button {
    margin-bottom: 10px;
}

.add-to-container {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

#add-to-playlist-container {
    display: flex;
    flex-wrap: wrap;
}

#add-to-playlist-container h3{
    margin: 0 10px 0 0;
    align-self: center;
}

#add-to-playlist-container select{
    width: auto;
    flex-grow: 1;
    margin: 0;
}

#add-to-playlist-container .action-buttons {
    margin-top: 10px;
}

.playlist-parameters {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.playlist-parameters .control-group button.small.cancel {
    align-self: flex-end;
    margin-bottom: 4px;
}

#clear_pattern {
    margin: 0;
}

.playlist-parameters .input-group input,
.playlist-parameters .input-group select {
    width: 100%; /* Ensure inputs/selects stretch to full width */
    padding: 10px;
    border: 1px solid var(--border-primary);
    border-radius: 5px;
    font-size: 1rem;
}

.empty-placeholder {
    color: gray;
    font-style: italic;
    text-align: center;
    padding: 10px;
}

/* Style for the filename span */
.filename {
    flex-grow: 1; /* Use available space */
    font-size: 1rem;
    color: var(--text-primary);
    margin-right: 10px; /* Space between filename and buttons */
    word-wrap: break-word;
    width: 100%;
    display: flex;
    align-items: center;
}


/* File List */
.file-list {
    list-style: none;
    padding: 0;
    margin: 0;
    border: 1px solid var(--border-primary);
    border-radius: 5px;
    overflow-y: auto;
    background: var(--background-primary);
    flex-grow: 1;
}

.file-list#playlist_items{
    margin-bottom: 10px;
    max-height: 20vh;
}

.file-list li {
    display: flex;
    padding: 10px;
    border-bottom: 1px solid var(--border-primary);
    cursor: pointer;
    transition: background-color var(--transition-medium);
}

.file-list li:hover {
    background-color: var(--background-tertiary);
}

.file-list li.selected {
    background: var(--theme-primary);
    color: var(--text-secondary);
    font-weight: bold;
}

.file-list li.selected .filename {
    font-weight: bold;
    color: var(--text-secondary);
}

.file-list button {
    margin-left: 5px;
    background: none;
    color: black;
    font-weight: bold;
    height: 40px;
    width: 40px;
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

.file-list button:hover:not(:focus) {
    background: var(--background-primary);
    box-shadow: inset 0 0 4px var(--border-secondary);
}

.file-list button.remove-button {
    color: var(--color-error);
}

.title-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rename-button {
    margin-left: 10px;
    background: var(--theme-primary-hover);
    color: var(--text-secondary);
    border: none;
    border-radius: 5px;
    padding: 5px 10px;
    cursor: pointer;
    transition: background 0.3s ease;
}

/* Bottom Navigation */
.bottom-nav {
    display: flex;
    position: sticky;
    justify-content: space-around;
    bottom: 0;
    height: 60px;
    width: 100%;
    border-top: 1px solid var(--theme-primary);
    flex-wrap: wrap;
    z-index: 10;
}

.tab-button {
    flex: 1;
    height: 60px;
    padding: 20px 10px;
    text-align: center;
    font-size: 1rem;
    font-weight: bold;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    transition: background 0.3s ease;
    background: var(--background-info);
    backdrop-filter: blur(2px);
    border-radius: 0;
}

.bottom-nav .tab-button.active {
    background: rgba(255, 255, 255, 0.75);
    color: var(--theme-primary);
}

/* Quick Action Buttons */
.action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    width: 100%;
    justify-content: space-between;
}

.action-buttons .scrollable-selection {
    width: calc(50% - 10px);
}

.action-buttons.square button {
    padding: 5px;
    aspect-ratio: 1 / 1;
    width: calc(25% - 10px);
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.action-buttons.square button i{
    font-size: 2.5rem;
}

button i + span{
    font-size: 1.25rem;
}

button i + span{
    margin-left: 5px;
}

.action-buttons.square button i + span{
    margin: 3px;
}

button i + span.small {
    font-size: 0.75rem;
}

.action-buttons button i + span{
    display: block;
}

.action-buttons button.m {
    width: calc(50% - 10px);
}

.action-buttons button.l {
    width: 100%;
}

.action-buttons button.small {
    flex: 0;
    flex-basis: calc(25% - 10px);
}

.action-buttons button.cta {
    flex-grow: 1;
}

button#debug_button {
    width: 40px;
    padding: 0;
    height: 40px;
    background: transparent;
    color: var(--text-primary);
    font-size: 1.5rem;
    margin-left: 40px;
    flex: 0 0 auto;
    transition: var(--transition-medium) all;
}

button#debug_button:hover,
button#debug_button.active {
    box-shadow: inset 0 0 4px var(--border-secondary);
}

#device-tab .dropdown {
    width: 50%;
}

#settings-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--background-translucent);
    backdrop-filter: blur(10px);
    z-index: 1000;
    overflow-y: auto;
    display: none; /* Hidden by default */
    flex-direction: column;
}

#settings-container.open{
    display: flex;
}

#open-settings-button {
    aspect-ratio: auto;
}

#open-settings-button span {
    order: -1;
    margin-right: 5px;
}

#theme-toggle .fa-sun:not(:hover) {
    color: #ffd700;
}

#theme-toggle .fa-moon:not(:hover) {
    color: var(--color-info);
}

/* Preview Canvas */
#patternPreviewCanvas {
    width: 100%;
    max-width: 300px;
    aspect-ratio: 1/1;
    border: 1px solid var(--border-primary);
    background: var(--theme-secondary);
    border-radius: 100%;
    padding: 15px;
}

#pattern-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

#pattern-preview-container.fullscreen #patternPreviewCanvas {
    width: initial;
    max-width: calc(100vw - 30px);
}

.pre-execution {
    width: 100%;
    display: flex;
}

.pre-execution h3 {
    flex-grow: 1;
    margin: 0;
    align-content: center;
}

.pre-execution .control-group {
    width: auto;
    flex-grow: 1;
    margin: 0;
}

.pre-execution select {
    margin: 0;
}

/* Currently Playing Section Styling */
body.playing .bottom-nav {
    height: 200px;
    align-items: flex-end;
}

#currently-playing-container {
    align-items: center;
    background: var(--background-accent);
    color: var(--text-secondary);
}

#currently-playing-container h3,
#currently-playing-container .open-button
{
    color: var(--text-secondary);
}

#currently-playing-container h3 {
    margin: 0;
}

body:not(.playing) #currently-playing-container {
    display: none;
}

#currently-playing-container.open {
    max-height: none;
    bottom: 60px;
}

body.playing #currently-playing-container:not(.open) {
    height: 140px;
    overflow:hidden;
    flex-direction: row;
    flex-wrap: wrap;
    bottom: 60px;
}

body.playing #currently-playing-container .header{
    justify-content: center;
    margin-bottom: 0;
}

body.playing #currently-playing-container .header .open-button {
    width: 100%;
    height: 20px;
    padding-top: 10px;
    margin: 0;
}


body.playing #currently-playing-container:not(.open) .header .fullscreen-button,
body.playing #currently-playing-container:not(.open) .header .close-button,
body.playing #currently-playing-container:not(.open) .header h3 {
    display: none;
}

body.playing #currently-playing-container:not(.open) #currently-playing-details{
    flex-grow: 1;
    flex-basis: 50%;
    align-items: flex-start;
    margin: 0 0 0 10px;
    overflow-y: auto;
}

body.playing #currently-playing-container:not(.open) .play-buttons button {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;/* Center within flex container */
}

body.playing #currently-playing-container:not(.open) #progress-container {
    width: 100%;
}


#currentlyPlayingCanvas {
    width: 100px;
    aspect-ratio: 1/1;
    border: 1px solid var(--border-primary);
    background: var(--theme-secondary);
    border-radius: 100%;
    padding: 10px;
}

#currently-playing-details {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 15px;
}

#currently-playing-details p {
    margin: 5px 0;
    font-size: 1rem;
}

#currently-playing-file,
#next-file {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}


#progress-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    flex-wrap: wrap;
}

#play_progress {
    width: auto;
    flex-grow: 1;
    height: 8px;
    appearance: none;
    background-color: var(--border-primary);
    border-radius: 4px;
    overflow: hidden;
    margin-right: 20px !important;  /* Add forced margin to ensure spacing */
}

#play_progress_text {
    font-size: 0.9rem;
    min-width: 45px;  /* Ensure consistent spacing for different percentages */
    flex-shrink: 0;   /* Prevent text from shrinking */
}

/* Progress Bar Styles */
#play_progress::-webkit-progress-bar {
    background-color: var(--border-primary);
}

#play_progress::-webkit-progress-value {
    background-color: var(--theme-primary);
    transition: width 0.25s ease;
}

/* Add dark mode specific styles */
:root[data-theme="dark"] #play_progress {
    background-color: var(--background-tertiary-dark);
}

:root[data-theme="dark"] #play_progress::-webkit-progress-bar {
    background-color: var(--background-tertiary-dark);
}

:root[data-theme="dark"] #play_progress::-webkit-progress-value {
    background-color: var(--color-success);  /* Using success color for better visibility */
}

/* Progress text color in dark mode */
:root[data-theme="dark"] #play_progress_text {
    color: var(--text-secondary-dark);
}

.play-buttons {
    display: flex;
    gap: 20px;
    justify-content: flex-end;
    width: 100%;
}

.play-buttons button {
    width: 75px;
    height: 75px;
    aspect-ratio: 1/1;
    font-size: 3rem;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
}

#pausePlayCurrent {
    border-radius: 50%;
}

body.playing #currently-playing-container.open {
    position: absolute;
    bottom: 0;
}

body.playing #currently-playing-container:not(.open) #currently-playing-details {
    flex-direction: row;
    align-items: center;
}

#currently-playing-container h3 {
    flex-grow: 1;
}

body.playing #currently-playing-container.open .header {
    display: none;
}

#open-settings-button span {
    opacity: 0;
    transition: var(--transition-medium) opacity;
}

#open-settings-button:hover span {
    opacity: 1;
}

/* Debug Log */
#status_log {
    background: #000;
    color: var(--text-secondary);
    font-family: monospace;
    font-size: 0.9rem;
    border-top: 1px solid var(--border-primary);
    padding: 10px;
    max-height: 200px;
    overflow-y: scroll;
    display: none;
    width: 100%;
}

#status_log p {
    margin: 0;
}

.control-group {
    display: flex;
    margin-bottom: 10px;
    flex-wrap: wrap;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 0 10px;
}

.control-group input {
    margin-bottom: 0;
}

.control-group h3 {
    width: 100%;
}

.control-group .item {
    display: flex;
    align-items: center;
    flex: 1;
}

.control-group .item.cta {
    justify-content: flex-end;
}

.control-group .item.column {
    flex-direction: column;
    text-align: center;
}

.control-group .item label {
    padding: 5px;
}

#serial_ports_container > * {
    display: inline-block;
}

#serial_ports_container select {
    margin: 10px;
    flex-basis: 100px;
    flex-grow: 0;
}

#serial_ports {
    width: auto;
    min-width: 200px;
}

#serial_status_container {
    margin-bottom: 10px;
}

#connection_status_header::before {
    content: '';
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 8px;
    background-color: var(--text-primary);
    display: inline-block;
    transition: var(--transition-slow) background-color;
}

#connection_status_header.connected::before {
    background-color: var(--color-success);
}

#connection_status_header.not-connected::before {
    background-color: var(--color-error);
}

#serial_ports_buttons {
    display: flex;
    gap: 10px;
}

.status.connected {
    color: var(--color-success);
    font-weight: bold;
}

.status.not-connected {
    color: var(--color-error);
    font-weight: bold;
}

/* Speed Control Section */
.speed-control {
    display: flex;
}

.speed-control label {
    font-weight: bold;
    font-size: 1rem;
    color: var(--text-primary);
    flex-shrink: 0;
}

.speed-control input[type="number"] {
    width: 100px; /* Consistent input width */
    padding: 8px;
    font-size: 1rem;
    border: 1px solid var(--border-primary);
    border-radius: 5px;
    outline: none;
    transition: all 0.3s ease;
}

input[type="number"]:focus {
    border-color: var(--theme-primary);
    box-shadow: 0 0 4px var(--background-info);
}

#speed_status {
    margin-top: 10px;
    font-size: 0.9rem;
}

#serial_ports_container > * {
    display: inline-block;
}

#serial_ports_container select {
    margin: 10px;
    flex-basis: 100px;
    flex-grow: 0;
}

#serial_ports {
    width: auto;
    min-width: 200px;
}


#wled-container {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
}

#wled_ip {
    margin-right: 10px;
}

#wled-frame {
    flex: 1 1 auto;
    width: 100%;
    border: none;
}

/* Notification Styles */
.notification {
    display: flex;
    position: absolute;
    top: 0;
    left: 0;
    font-weight: bold;
    z-index: 1000;
    color: var(--text-secondary);
    width: 100%;
    height: 100%;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity var(--transition-medium);
    cursor: pointer;
}
.notification.show {
    opacity: 1; /* Fully visible */
}

.notification .close-button {
    color: var(--text-secondary);
    font-size: 1.5rem;
    top: 0;
    right: 0;
    position: absolute;
}

/* Notification Types */
.notification.success { background-color: var(--background-success); }
.notification.warning { background-color: var(--background-warning); }
.notification.error { background-color: var(--background-error); }
.notification.info { background-color: var(--background-info); }

.footer {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    margin-bottom: 20px;
    width: 100%;
}

#github {
    align-content: center;
    display: flex;
    font-size: 0.8em;
}

#github img {
    margin: 0 5px
}

/* Responsive Design */
@media (max-width: 1023px) {
    body {
        font-size: 0.9rem;
    }

    .tab-button {
        font-size: 0.9rem;
    }

    .footer {
        display: none;
    }

}

/* On larger screens, display all tabs in a 3-column grid */
@media screen and (min-width: 1024px) {
    .app {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 0 16px;
        height: calc(100vh - 60px);
        padding: 0 15px;
    }

    #status_log {
        grid-column: span 3;
        align-self: flex-end;
        height: 100%;
    }

    section.sticky {
        position: sticky;
        bottom: 0;
    }

    .bottom-nav .tab-button {
        display: none;
    }

    .bottom-nav {
        border-top: 0;
    }

    /* Show all tabs in grid layout */
    .tab-content {
        flex-direction: column;
        overflow-y: auto;
        overflow-x: hidden;
        position: relative;
    }

    .app > .tab-content {
        display: flex !important; /* Always display main tab-content */
        border-radius: 8px;
        background-color: var(--background-primary);
        border: 1px solid var(--border-primary);
    }

    body.playing .app {
        padding: 15px 0 150px 15px;
        margin-bottom: -140px;
    }

    body.playing .bottom-nav {
        height: 140px;
    }

    body:not(.playing) .bottom-nav {
        display: none;
    }

}

/* Add specific styles for dark mode inputs */
:root[data-theme="dark"] input::placeholder,
:root[data-theme="dark"] select::placeholder,
:root[data-theme="dark"] textarea::placeholder {
    color: #999;
}

/* Style the file list items in dark mode */
:root[data-theme="dark"] .file-list {
    background: var(--background-secondary-dark);
}

:root[data-theme="dark"] .file-list li {
    color: var(--text-primary-dark);
}

:root[data-theme="dark"] .file-list .filename {
    color: var(--text-primary-dark);
}

:root[data-theme="dark"] .file-list li:hover {
    background-color: var(--background-tertiary-dark);
}

:root[data-theme="dark"] .file-list button {
    color: var(--text-primary-dark);
}

/* Update status log colors for dark mode */
:root[data-theme="dark"] #status_log {
    background: #000000;
    border-color: var(--border-primary-dark);
}

/* Update notification backgrounds for dark mode */
:root[data-theme="dark"] .notification {
    /* Remove this line to keep original colors */
    /* background-color: var(--background-secondary-dark); */
}

/* Notification Types - Update opacity for better visibility in dark mode */
:root[data-theme="dark"] .notification.success { background-color: var(--color-success); }
:root[data-theme="dark"] .notification.warning { background-color: var(--color-warning); }
:root[data-theme="dark"] .notification.error { background-color: var(--color-error); }
:root[data-theme="dark"] .notification.info { background-color: var(--color-info); }

/* Make notification text white for better contrast */
:root[data-theme="dark"] .notification {
    color: white;
}

/* Update button colors for better visibility in dark mode */
:root[data-theme="dark"] button.no-bg:not(:hover) {
    color: var(--text-primary-dark);
}

:root[data-theme="dark"] .file-list button:hover:not(:focus) {
    background: var(--background-tertiary-dark);
    box-shadow: inset 0 0 4px var(--border-secondary-dark);
}

/* Update custom checkbox/radio colors in dark mode */
:root[data-theme="dark"] .custom-checkbox,
:root[data-theme="dark"] .custom-radio {
    border-color: var(--theme-primary-dark);
}

:root[data-theme="dark"] .custom-checkbox::after,
:root[data-theme="dark"] .custom-radio::after {
    background-color: var(--theme-primary-dark);
}

:root[data-theme="dark"] .custom-input input:checked + .custom-checkbox,
:root[data-theme="dark"] .custom-input input:checked + .custom-radio {
    background-color: var(--theme-primary-dark);
    border-color: var(--theme-primary-hover-dark);
}

/* Update scroll arrow hover in dark mode */
:root[data-theme="dark"] .scroll-arrow:hover {
    background: var(--theme-primary-hover-dark);
}

/* Update tab button hover in dark mode */
:root[data-theme="dark"] .tab-button {
    background: var(--color-success);
    color: var(--text-secondary);
}
:root[data-theme="dark"] .tab-button:hover {
    background: var(--color-success);
}

:root[data-theme="dark"] .tab-button.active {
    background: var(--background-secondary);
    color: var(--text-secondary);
}

/* Override specific button hover states in dark mode */
:root[data-theme="dark"] button.cancel:hover {
    background: var(--color-error) !important;
}

:root[data-theme="dark"] button.cta:hover {
    background: var(--color-success-dark) !important;
}

:root[data-theme="dark"] button.warn:hover {
    background: var(--color-warning) !important;
}

/* Update selection container button hover in dark mode */
:root[data-theme="dark"] .selection-container .nav-items > button:hover {
    background: var(--text-secondary);
    color: var(--theme-primary-dark);
}

:root[data-theme="dark"] .header #open-settings-button:hover {
    background: var(--color-success-dark);
    color: var(--text-primary-dark);
}
