/* Define CSS custom properties for theming (light mode default) */
:root {
    --background-color: #f2f5f6;
    --container-bg: #ffffff;
    --text-color: #333;
    --heading-color: #00BED6;
    --button-bg: #d3d3d3;
    --button-text-color: #333;
    --button-hover-bg: #c0c0c0;
    --button-border-color: #898A8D;
    --input-border: #898A8D;
    --response-bg: #F2F5F6;
    --response-border: #898A8D;
    --reader-bg: #F2F5F6;
    --reader-text-color: #333;
}

/* Dark mode overrides */
body.dark-mode {
    --background-color: #2F4858;
    --container-bg: #2F4858;
    --text-color: #e0e0e0;
    --heading-color: #00BED6;
    --button-bg: #898A8D;
    --button-text-color: #121212;
    --button-hover-bg: #00BED6;
    --button-border-color: #333;
    --input-border: #898A8D;
    --response-bg: #2F4858;
    --response-border: #898A8D;
    --reader-bg: #2F4858;
    --reader-text-color: #e0e0e0;
}

/* Global box-sizing */
* {
    box-sizing: border-box; /* Ensure padding/borders don’t add to width */
}

/* Base body styling for full-page layout */
body {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background-color: var(--background-color);
    color: var(--text-color);
    font-family: Arial, sans-serif;
    line-height: 1.5;
    width: 100vw;
    overflow-x: hidden; /* Prevent horizontal scrolling */
}

/* Header banner styling */
.header-banner {
    display: flex;
    align-items: center;
    background-color: #1bbbd0;
    color: white;
    padding: 10px;
    width: 100%;
    position: relative;
}

.logo {
    height: 70px;
    width: auto;
    margin-left: 20px;
}

.header-title {
    font-size: 24px;
    font-family: 'Arial', sans-serif;
    margin: 0;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
}

/* Theme switch styling */
.theme-switch-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 12px;
}

.theme-switch {
    position: relative;
    display: inline-block;
    width: 45px;
    height: 20px;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #b9dbe5;
    transition: 0.4s;
    border-radius: 34px;
}

.slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 1px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #666;
}

input:checked + .slider::before {
    transform: translateX(26px);
}

.label-dark, .label-light {
    font-family: 'Arial', sans-serif;
    font-size: 12px;
    font-weight: normal;
    color: #bbb;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Main layout container */
.main-container {
    display: flex;
    flex-direction: row;
    flex-grow: 1;
    padding: 20px;
    gap: 20px;
    width: 100%;
    max-width: 100%; /* Ensure it doesn’t exceed viewport */
    overflow-x: hidden; /* Prevent horizontal overflow */
}

/* Left panel: Reader info box */
#readerInfoBox {
    flex: 0 0 calc(35% - 40px); /* Adjust for padding and gap */
    max-width: calc(35% - 40px);
    background-color: var(--reader-bg);
    color: var(--reader-text-color);
    border: 1px solid var(--input-border);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    height: calc(100vh - 120px);
    overflow-y: auto;
}

/* Middle panel: Reader container */
#readerContainer {
    flex: 0 0 calc(50% - 20px); /* Adjust for gap */
    max-width: calc(50% - 20px);
}

/* Right panel: Reader controls */
.reader-controls {
    flex: 0 0 15%; /* No adjustment needed as it’s the last item */
    max-width: 15%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Reader info table styling */
#readerInfoTable th, #readerInfoTable td {
    padding: 10px;
    text-align: left;
    border: 1px solid #ddd;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 300px;
}

#readerInfoTable th {
    background-color: var(--heading-color);
    color: white;
}

#readerInfoTable tbody tr:hover {
    background-color: #f1f1f1;
}

/* Reader box styling */
.reader-box {
    position: relative;
    border: 2px solid var(--input-border);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    background-color: var(--container-bg);
    margin-bottom: 20px;
    width: 100%;
    max-width: 100%; /* Ensure it fits container */
}

#addReaderButton {
    display: block;
    width: 100%;
    height: 45px;
    padding: 10px;
    background-color: #898A8D;
    color: white;
    font-size: 12px;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease-in-out;
    text-transform: uppercase;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
}

#addReaderButton:hover {
    background-color: #6F94A0;
}

/* Additional UI elements */
.section-title {
    margin-top: 20px;
    font-size: 18px;
    color: var(--heading-color);
}

.radio-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
}

.radio-text {
    font-weight: bold;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 5px;
}

input[type="radio"] {
    margin-right: 5px;
}

select, button, input:not([type="number"]) {
    padding: 10px;
    margin: 10px 0;
    font-size: 16px;
    border: 1px solid var(--input-border);
    border-radius: 5px;
    line-height: 1.5;
}

.delete-button {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 20px;
    height: 20px;
    background-color: white;
    color: #ff4444;
    border: none;
    font-size: 16px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    padding: 0;
}

.delete-button:hover {
    background-color: #cc0000;
}

button {
    background-color: var(--button-bg);
    color: var(--button-text-color);
    cursor: pointer;
    padding: 10px 20px;
    border-radius: 5px;
    border: 2px solid var(--button-border-color);
    margin-left: 10px;
}

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

button:hover:not(:disabled) {
    background-color: var(--button-hover-bg);
}

#response-group {
    margin-top: 20px;
    padding: 15px;
    background-color: var(--response-bg);
    border: 1px solid var(--response-border);
    border-radius: 5px;
}

/* Responsive design */
@media (max-width: 1000px) {
    .main-container {
        flex-direction: column;
        padding: 10px; /* Reduce padding for smaller screens */
    }
    #readerInfoBox, #readerContainer, .reader-controls {
        flex: 0 0 100%;
        max-width: 100%;
    }
    #readerInfoBox {
        height: auto; /* Allow height to adjust */
    }
    .reader-box {
        width: 100%;
    }
}