html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: Arial, sans-serif;
    background-color: #1a1a1a;
    color: white;
    height: 100%;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    padding-top: 60px;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    touch-action: manipulation;
}

.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: #2a2a2a;
    padding: 10px 20px;
    border-bottom: 1px solid #444;
    z-index: 1000;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.user-menu {
    position: relative;
    display: flex;
    align-items: center;
}

.username {
    margin-right: 10px;
    color: #ffffff;
}

.menu-toggle {
    background: none;
    border: none;
    color: #4a90e2;
    font-size: 16px;
    cursor: pointer;
    padding: 5px;
}

.menu-toggle:hover {
    color: #357abd;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background-color: #2a2a2a;
    border: 1px solid #444;
    border-radius: 3px;
    min-width: 150px;
    z-index: 1001;
}

.dropdown-menu.active {
    display: block;
}

.dropdown-menu a {
    display: block;
    padding: 10px;
    color: #4a90e2;
    text-decoration: none;
}

.dropdown-menu a:hover {
    background-color: #333;
    color: #357abd;
}

.container {
    display: flex;
    min-height: calc(100vh - 60px);
    padding: 20px;
}

.index-container {
    display: flex;
    width: 100%;
    padding: 20px;
    flex: 1 0 auto;
}

.left-panel {
    flex: 0 0 250px; /* Fixed width for desktop, narrower than before */
    max-width: 250px; /* Cap the width */
    padding: 20px;
    background-color: #2a2a2a;
    border-right: 1px solid #444;
    overflow-y: auto;
    min-width: 200px; /* Slightly smaller minimum to prevent collapse */
}

.left-panel.minimized {
    display: none;
}

.left-panel-toggle {
    display: none;
    background-color: #4a90e2;
    color: white;
    border: none;
    padding: 8px;
    cursor: pointer;
    width: 100%;
    text-align: center;
    border-radius: 3px;
    margin-bottom: 10px;
}

.left-panel-toggle:hover {
    background-color: #357abd;
}

.right-panel {
    flex: 3; /* Take up more space */
    padding: 20px;
    background-color: #1a1a1a;
    overflow-y: auto;
}

.login-panel, .register-panel, .profile-panel {
    width: 100%;
    max-width: 400px;
    padding: 20px;
    background-color: #2a2a2a;
    border: 1px solid #444;
    border-radius: 5px;
}

h1, h2 {
    color: #ffffff;
}

h1 {
    text-align: center;
}

label {
    display: block;
    margin-top: 10px;
    color: #cccccc;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select,
input[type="range"],
input[type="date"] {
    width: 100%;
    padding: 5px;
    margin-top: 5px;
    background-color: #333;
    border: 1px solid #555;
    color: white;
    border-radius: 3px;
    box-sizing: border-box;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
select:focus,
input[type="range"]:focus,
input[type="date"]:focus {
    outline: none;
    border-color: #4a90e2;
}

input.invalid {
    border-color: #ff4040;
}

button {
    width: 100%;
    margin-top: 15px;
    padding: 10px;
    background-color: #4a90e2;
    border: none;
    color: white;
    border-radius: 3px;
    cursor: pointer;
}

button:hover {
    background-color: #357abd;
}

.delete-btn {
    background-color: #ff4040;
}

.delete-btn:hover {
    background-color: #cc3333;
}

.error {
    color: #ff4040;
    text-align: center;
    margin-top: 10px;
}

.success {
    color: #4a90e2;
    text-align: center;
    margin-top: 10px;
}

.register-link, .login-link {
    text-align: center;
    margin-top: 15px;
}

.register-link a, .login-link a {
    color: #4a90e2;
    text-decoration: none;
}

.register-link a:hover, .login-link a:hover {
    color: #357abd;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

th, td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid #444;
    white-space: nowrap;
}

th {
    background-color: #333;
}

.table-container {
    max-height: 300px;
    min-height: 150px;
    overflow-y: auto;
    margin-top: 10px;
    border: 1px solid #444;
}

.chart-container {
    position: relative;
    width: 100%;
    height: 400px;
    margin-top: 20px;
}

#resultLabel {
    margin-top: 10px;
    font-weight: bold;
}

#select-columns-btn {
    margin-top: 10px;
    padding: 8px 15px;
    background-color: #4a90e2;
    border: none;
    color: white;
    border-radius: 3px;
    cursor: pointer;
}

#select-columns-btn:hover {
    background-color: #357abd;
}

.column-dropdown {
    display: none;
    position: absolute;
    background-color: #333;
    border: 1px solid #555;
    padding: 10px;
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
    min-width: 350px;
}

.column-dropdown.active {
    display: block;
}

.column-dropdown label {
    display: block;
    margin: 5px 0;
    color: white;
}

.column-dropdown input[type="checkbox"] {
    margin-right: 5px;
}

canvas {
    cursor: crosshair;
}

.chart-draggable-point {
    fill: yellow;
    stroke: white;
    stroke-width: 2;
    cursor: move;
}

input[type="radio"] {
    margin: 5px 5px 5px 0;
    vertical-align: middle;
}

input[type="radio"] + label {
    margin-right: 15px;
    vertical-align: middle;
}

footer {
    flex-shrink: 0;
    text-align: center;
    padding: 10px 0;
    background-color: #2a2a2a;
    border-top: 1px solid #444;
}

/* Mobile styles */
@media only screen and (max-width: 768px) {
    body {
        padding-top: 50px;
    }

    .top-bar {
        padding: 8px 15px;
    }

    .index-container {
        flex-direction: column;
        padding: 10px;
        max-width: 100%;
    }

    .left-panel {
        flex: 1; /* Full width on mobile */
        max-width: 100%; /* Override desktop max-width */
        min-width: 0; /* Allow full flexibility */
        border-right: none;
        border-bottom: 1px solid #444;
    }

    .left-panel-toggle {
        display: block;
    }

    .right-panel {
        flex: 1; /* Full width below left panel */
        min-width: 0;
    }

    .user-menu {
        font-size: 14px;
    }

    .menu-toggle {
        font-size: 14px;
    }

    .dropdown-menu {
        min-width: 120px;
    }
}

/* Smaller buttons for optmap.php */
.optmap-page button,
.optmap-page #select-columns-btn {
    width: auto; /* Override full-width buttons */
    padding: 8px 12px; /* Smaller padding for a compact look */
    font-size: 14px; /* Slightly smaller font */
}

/* Ensure buttons in the left panel (e.g., Add Leg, Clear, Calc) are also compact */
.optmap-page .left-panel button {
    width: 100%; /* Keep full-width within the narrower panel */
    padding: 8px; /* Consistent padding */
}

/* Specific styling for select-columns-btn to ensure it looks compact */
.optmap-page #select-columns-btn {
    padding: 6px 10px; /* Even smaller for this button */
}