:root {
    --bg-color: #efefef;
    --primary-dark: #152B3D;
    --primary-medium: #295377;
    --accent-color: #D54005;
    --text-light: #ffffff;
    --text-dark: #333333;
}

body {
    font-family: sans-serif;
    background-color: var(--bg-color);
    color: var(--text-dark);
    margin: 0;
    padding: 20px;
}

h1 {
    color: var(--primary-dark);
    text-align: center;
    margin-bottom: 30px;
}

h2 {
    color: var(--primary-medium);
    border-bottom: 1px solid var(--primary-medium);
    padding-bottom: 5px;
    margin-top: 20px;
    margin-bottom: 15px;
}

.container {
    display: flex;
    gap: 30px;
    max-width: 1200px;
    margin: auto;
}

.controls {
    flex: 1;
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.canvas-area {
    flex: 2;
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Limit height and allow scrolling if canvas is too tall */
    max-height: 80vh; /* Updated to 80vh */
    overflow: auto; /* Add scrollbars if content overflows */
}

#imageCanvas {
    border: 1px solid #ccc;
    display: block; /* Ensure it behaves like a block for centering/margins */
    max-width: 100%; /* Prevent exceeding container width */
    max-height: 70%; /* Prevent exceeding container height */
    height: auto; /* Maintain aspect ratio by default */
    margin: auto; /* Center canvas within the area if smaller */
    /* Add cursor style for dragging */
    cursor: grab;
}

#imageCanvas.dragging {
    cursor: grabbing;
}

#badgeSelection img {
    width: 50px;
    height: 50px;
    border: 2px solid transparent;
    margin: 5px;
    cursor: pointer;
    transition: border-color 0.2s;
}

#badgeSelection img.selected {
    border-color: var(--accent-color);
}

#dynamicBadgeOptions {
    margin-top: 10px;
    padding: 10px;
    border: 1px dashed var(--primary-medium);
    border-radius: 4px;
}

#dynamicBadgeOptions label,
#dynamicBadgeOptions input {
    display: block;
    margin-bottom: 5px;
    width: calc(100% - 12px); /* Adjust for padding/border */
}

input[type="file"],
input[type="text"],
select,
button,
a#downloadLink {
    display: block;
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
}

button, a#downloadLink {
    background-color: var(--primary-medium);
    color: var(--text-light);
    border: none;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    font-size: 1em;
    transition: background-color 0.2s;
}

button:hover, a#downloadLink:hover {
    background-color: var(--primary-dark);
}

button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

a#downloadLink {
    background-color: var(--accent-color);
}
a#downloadLink:hover {
    background-color: #a53004; /* Darker accent */
}
label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

input#password {
    width: 100%;
    border-style: solid;
    border-width: 1px;
    box-shadow: none;
    border-color: #ccc;
    margin-bottom: 20px;
    height: 20px;
}


.slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px; /* Match other controls */
}

#rotationSlider {
    flex-grow: 1; /* Allow slider to take available space */
    margin-bottom: 0; /* Remove default margin */
    width: auto; /* Override default block width */
}

#rotationValue {
    font-weight: bold;
    min-width: 3em; /* Ensure space for text like "-45°" */
    text-align: right;
}

.slider-container label {
    min-width: 120px; /* Adjust as needed for label alignment */
    text-align: right;
    flex-shrink: 0; /* Prevent label from shrinking */
}

/* Admin Page Specific */
#loginForm, #badgeManagement {
    max-width: 400px;
    margin: 30px auto;
    padding: 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

#badgeList {
    list-style: none;
    padding: 0;
}

#badgeList li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #eee;
}

#badgeList img {
    width: 40px;
    height: 40px;
    margin-right: 10px;
}

#badgeList button {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    width: auto; /* Override default block width */
}

#badgeList button:hover {
    background-color: #a53004;
}

.error-message {
    color: var(--accent-color);
    font-weight: bold;
    margin-top: 10px;
}

/* Make labels for radio buttons and checkboxes inline */
input[type="radio"] + label,
input[type="checkbox"] + label {
    display: inline-block;
    font-weight: normal;
    margin-bottom: 0;
    margin-left: 5px;
    vertical-align: middle;
}

input[type="radio"],
input[type="checkbox"] {
    vertical-align: middle;
    margin-bottom: 0; /* Reset margin if any was inherited */
    /* Radio buttons and checkboxes are typically small, so width/height are not set to 100% */
    /* Ensure they don't pick up the general input block styling */
    display: inline-block;
    width: auto; 
}
