/* General Styles */
* {
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #e9ecef;
    margin: 0;
    padding: 20px;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Headings */
h1 {
    text-align: center;
    color: #343a40;
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    margin-bottom: 30px;
}

h2 {
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    font-weight: 600;
    color: #333;
    margin-top: 30px;
    margin-bottom: 20px;
    text-align: center;
    font-family: 'Arial', sans-serif;
    border-bottom: 2px solid #007BFF;
    padding-bottom: 10px;
}

h4 {
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    margin: 0;
}

.small-italic {
    font-size: clamp(0.7rem, 2vw, 0.9rem);
    font-style: italic;
    color: #555;
    display: block;
    text-align: center;
    margin-top: 5px;
}

/* Location Section */
.location-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

/* Form Styles */
form {
    display: block;
    width: 100%;
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
    position: relative;
}

/* Room/Area container specific styles */
#roomsContainer > div {
    border: 1px solid #ccc;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 5px;
    background-color: #f8f9fa;
}

/* Room/Area form group container */
#roomsContainer > div > div:not(:first-child) {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

#roomsContainer .form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
    width: 100% !important;
    margin-right: 0 !important;
}

/* Room/Area header with remove button */
#roomsContainer > div > div:first-child {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

#roomsContainer button {
    padding: 5px 10px;
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
}

#roomsContainer button:hover {
    background-color: #c82333;
}

/* Labels */
label {
    margin-bottom: 8px;
    font-weight: bold;
    color: #495057;
    font-size: clamp(0.9rem, 2vw, 1rem);
}

/* Input fields */
select, input[type="text"], input[type="number"] {
    padding: 12px;
    border: 1px solid #ced4da;
    border-radius: 5px;
    width: 100%;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
    font-size: clamp(0.9rem, 2vw, 1rem);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

select:focus, input[type="text"]:focus, input[type="number"]:focus {
    border-color: #80bdff;
    outline: none;
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
}

/* Button Styles */
.button-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-top: 30px;
}

button {
    padding: 15px 25px;
    border: none;
    border-radius: 5px;
    background-color: #007bff;
    color: white;
    cursor: pointer;
    font-size: clamp(0.9rem, 2vw, 1rem);
    transition: background-color 0.3s ease;
    min-width: 200px;
}

button:hover {
    background-color: #0056b3;
}

/* Add Room/Area Button */
button[onclick="addRoom()"] {
    background-color: #28a745;
    margin-bottom: 20px;
    min-width: auto;
    padding: 10px 20px;
}

button[onclick="addRoom()"]:hover {
    background-color: #218838;
}

/* Fieldset Styles */
fieldset {
    width: 100%;
    border: 1px solid #ced4da;
    border-radius: 5px;
    padding: 20px;
    margin-bottom: 20px;
}

fieldset legend {
    font-weight: bold;
    color: #495057;
    padding: 0 10px;
    font-size: clamp(0.9rem, 2vw, 1rem);
}

fieldset label {
    display: flex;
    align-items: flex-start;
    margin-bottom: 10px;
    cursor: pointer;
    font-weight: normal;
    line-height: 1.5;
}

fieldset input[type="radio"],
fieldset input[type="checkbox"] {
    margin-right: 10px;
    margin-top: 2px;
    flex-shrink: 0;
    width: auto;
}

/* Tooltip Styling */
.tooltip {
    position: relative;
    display: block;
    cursor: pointer;
    width: 100%;
}

.tooltip .tooltip-text {
    visibility: hidden;
    width: 280px;
    max-width: 90vw;
    background-color: #555;
    color: #fff;
    text-align: center;
    border-radius: 5px;
    padding: 8px;
    position: absolute;
    z-index: 1000;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.9rem;
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Suggestions Box Styles */
.autocomplete {
    position: relative;
}

.suggestions-container {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ccc;
    border-top: none;
    background-color: white;
    z-index: 1000;
    display: none;
}

.suggestion-item {
    padding: 12px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    font-size: clamp(0.9rem, 2vw, 1rem);
}

.suggestion-item:hover {
    background-color: #f0f0f0;
}

.suggestion-item:last-child {
    border-bottom: none;
}

/* Responsive Breakpoints */

/* Large tablets and small desktops */
@media (max-width: 1024px) {
    .container {
        padding: 25px;
    }
    
    body {
        padding: 15px;
    }
}

/* Tablets */
@media (max-width: 768px) {
    .location-group {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* Force room/area details to stack vertically on tablets */
    #roomsContainer > div > div:not(:first-child) {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .container {
        padding: 20px;
    }
    
    fieldset {
        padding: 15px;
    }
    
    h2 {
        margin-top: 25px;
    }
}

/* Mobile phones */
@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 15px;
    }
    
    h1 {
        margin-bottom: 20px;
    }
    
    h2 {
        margin-top: 20px;
        margin-bottom: 15px;
    }
    
    .form-group {
        margin-bottom: 15px;
    }
    
    /* Ensure room/area details are single column on mobile */
    #roomsContainer > div > div:not(:first-child) {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    #roomsContainer > div {
        padding: 15px;
    }
    
    fieldset {
        padding: 12px;
        margin-bottom: 15px;
    }
    
    button {
        padding: 12px 20px;
        min-width: 150px;
    }
    
    .tooltip .tooltip-text {
        width: 250px;
        font-size: 0.8rem;
    }
    
    select, input[type="text"], input[type="number"] {
        padding: 10px;
    }
}

/* Extra small screens */
@media (max-width: 320px) {
    .container {
        padding: 10px;
    }
    
    button {
        min-width: 120px;
        padding: 10px 15px;
    }
    
    .tooltip .tooltip-text {
        width: 200px;
        font-size: 0.75rem;
    }
    
    fieldset {
        padding: 10px;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .location-group {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
    
    #roomsContainer .form-group {
        width: calc(50% - 10px);
        margin-right: 20px;
    }
    
    #roomsContainer .form-group:nth-child(2n) {
        margin-right: 0;
    }
    
    #roomsContainer .form-group:nth-child(3n) {
        width: 100%;
        margin-right: 0;
    }
}

/* Print styles */
@media print {
    body {
        background-color: white;
        padding: 0;
    }
    
    .container {
        box-shadow: none;
        max-width: 100%;
    }
    
    button {
        display: none;
    }
    
    .tooltip .tooltip-text {
        display: none;
    }
}

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    select, input[type="text"], input[type="number"] {
        border-width: 0.5px;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #e0e0e0;
    }
    
    .container {
        background-color: #2d2d2d;
        color: #e0e0e0;
    }
    
    h1, h2, h4 {
        color: #ffffff;
    }
    
    label {
        color: #e0e0e0;
    }
    
    select, input[type="text"], input[type="number"] {
        background-color: #3a3a3a;
        border-color: #555;
        color: #e0e0e0;
    }
    
    fieldset {
        border-color: #555;
    }
    
    .suggestion-item {
        background-color: #3a3a3a;
        color: #e0e0e0;
        border-color: #555;
    }
    
    .suggestion-item:hover {
        background-color: #4a4a4a;
    }
    
    #roomsContainer > div {
        background-color: #353535;
        border-color: #555;
    }
}