/* style.css */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow-x: hidden; /* 防止 body 级别出现意外的水平滚动条 */
    box-sizing: border-box; /* 应用到所有元素，简化计算 */
    scroll-behavior: smooth;
}

*, *::before, *::after {
    box-sizing: inherit;
}

body {
    font-family: sans-serif;
    line-height: 1.6;
    position: relative; /* Important for potential absolute children or fixed nav calculations */
}

.app-container {
    display: flex;
    /* Default for PC: row */
    flex-direction: row;
    min-height: calc(100vh - 50px) !important;
    width: 200vw !important;
    overflow: hidden;

}


.settings-panel, .results-panel {
    padding: 20px;
    box-sizing: border-box;
}

.settings-panel {
    background-color: #fff;
    border-right: 1px solid #ddd;
    flex: 1; /* PC: takes 1 part */
    padding: 20px;
    box-sizing: border-box !important;
    overflow-y: auto !important;
    min-height: calc(100vh - 50px) !important;
}

.results-panel {
    background-color: #e9e9e9;
    flex: 2; /* PC: takes 2 parts */
    padding: 20px;
    box-sizing: border-box !important;
    display: flex;
    flex-direction: column;
    overflow-y: auto !important;
    position: relative; /* Needed for absolute positioning of child FAB */
    min-height: calc(100vh - 50px) !important;
}

.results-list-container {
    flex-grow: 0;
    overflow-y: auto;
    overflow-x: auto; /* Allow horizontal scroll for wide tables */
    background-color: #fff;
    border: 1px solid #ccc;
    padding: 10px;
    margin-top: 10px;
}


h2 {
    color: #333;
    border-bottom: 2px solid #007bff;
    padding-bottom: 5px;
    margin-top: 0;
}

.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

input[type="text"],
input[type="number"],
select {
    width: calc(100% - 22px); /* 减去padding和border */
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}
input[type="checkbox"] {
    margin-right: 5px;
    vertical-align: middle;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
}

.checkbox-group label {
    width: 25%; /* 每行4个，考虑间距可以略小 */
    margin-bottom: 8px;
    font-weight: normal; /* 非粗体 */
}
.checkbox-group input[type="checkbox"] {
    margin-right: 5px;
}


.spacer {
    margin: 20px 0;
    border: 0;
    border-top: 1px solid #eee;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 0.9em;
}

th, td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

th {
    background-color: #f0f0f0;
}

button {
    background-color: #007bff;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    margin-top: 10px;
}

button:hover {
    background-color: #0056b3;
}

#reset-item-selections {
    background-color: #ffc107;
    color: #333;
}
#reset-item-selections:hover {
    background-color: #e0a800;
}

#save-results {
    background-color: #28a745;
}
#save-results:hover {
    background-color: #1e7e34;
}


.mobile-nav {
    display: none; /* 默认PC不显示 */
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #333;
    color: white;
    z-index: 1000;
}

.mobile-nav button {
    width: 50%;
    padding: 15px;
    background-color: #555;
    color: white;
    border: none;
    font-size: 1em;
    margin: 0;
    border-radius: 0;
}

.mobile-nav button.active {
    background-color: #007bff;
}

/* Floating Action Button (FAB) Styles */
.fab {
    position: fixed; /* Relative to the viewport */
    width: 56px;
    height: 56px;
    background-color: #02d380;
    border-radius: 50%;
    border: none;
    box-shadow: 0 2px 5px 0 rgba(0,0,0,0.16), 0 2px 10px 0 rgba(0,0,0,0.12);
    display: flex; /* Will be controlled by JS or specific view classes */
    align-items: center;
    justify-content: center;
    text-align: center; /* Add this as a fallback or test */
    cursor: pointer;
    z-index: 1001; /* Higher than mobile-nav (which is 1000) */
    transition: background-color 0.3s ease, opacity 0.3s ease, visibility 0s linear 0.3s; /* Delay visibility change */
    opacity: 0;
    visibility: hidden;
    right: 20px;     /* Default right for PC */
    bottom: 20px;    /* Default bottom for PC */
}

.fab img {
    width: 35;
    height: 35px;
}

.fab:hover {
    background-color: #0bc194;
}
input.invalid-input {
    border-color: red !important; /* Or a more subtle warning color */
    background-color: #fff0f0;
}

.error-message {
    display: block;
    color: red;
    font-size: 0.85em;
    margin-top: 3px;
}

/* Mobile styles */
@media (max-width: 768px), (orientation: portrait) {
    body.mobile-view .app-container { /* Add .mobile-view for specificity */
        /* Override PC styles */
        flex-direction: row !important; /* CRITICAL: Ensure horizontal for sliding */
        width: 200vw !important;         /* CRITICAL: Two screens wide */
        min-height: calc(100vh - 50px); /* Adjust if nav height changes */
        overflow: hidden; /* Hides the part of 200vw that's off-screen */
        /* border-right: none; Remove any borders from PC view */
        /* flex: none; Reset flex sizing from PC view if any */
        position: relative; /* Reset from PC if needed, or ensure it's what you want */
        transition: transform 0.3s ease-in-out;
        /*min-height: auto; /* Or make it fit its tallest child panel */
        min-height: calc(100vh - 50px) !important; /* 50px is mobile-nav height */
        height: auto;
    }

    body.mobile-view .settings-panel,
    body.mobile-view .results-panel { /* Add .mobile-view for specificity */
        /* Override PC styles */
        width: 100vw !important;         /* CRITICAL: Each panel is full viewport width */
        flex: none !important;           /* CRITICAL: Reset PC flex sizing */
        /* min-height: auto; */
        min-height: calc(100vh - 50px) !important; /* Where 50px is the height of .mobile-nav */
        height: auto; /* Allow height to be determined by content */
        border-right: none !important;   /* Remove PC border */
        padding: 15px; /* Mobile specific padding if needed */
        /* Ensure no max-width is inherited or set that conflicts */
        padding-bottom: calc(15px + 50px + 20px) !important; /* 15px original + 50px nav + 20px extra space for FAB visibility */
        overflow-y: auto !important;/* (already defined, should be fine) */
        box-sizing: border-box !important; /* Crucial when using padding and height/min-height */
    }

    /* Sliding mechanism */
    body.mobile-view .app-container.show-results {
        transform: translateX(-100vw) !important; /* CRITICAL */
    }
    body.mobile-view .app-container:not(.show-results) { /* Explicitly set for settings view */
        transform: translateX(0vw) !important;
    }

    /* Show FAB only when results panel is active in mobile view */
    body.mobile-view .app-container.show-results .fab {
        display: flex !important; /* Use flex to center icon, !important if needed */
    }

    /* Adjust FAB position if mobile nav is present */
    body.mobile-view .fab {
        bottom: 75px; /* 50px (nav height) + 15px (margin from nav) + 10px (visual buffer) */
        right: 15px;
    }
    /* Show FAB only when results panel is active in mobile view */
    body.mobile-view.show-results-view .fab { /* New class on body */
        opacity: 1 !important;
        visibility: visible !important;
    }

    .mobile-nav {
        display: flex !important; /* CRITICAL: Show mobile nav */
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background-color: #333;
        color: white;
        z-index: 1000;
        height: 50px !important; /* Define nav height */
    }

    .mobile-nav button {
        width: 50%;
        padding: 15px 0;
        background-color: #555;
        color: white;
        border: none;
        font-size: 1em;
        margin: 0;
        border-radius: 0;
    }

    .mobile-nav button.active {
        background-color: #007bff;
    }

    .checkbox-group label {
        width: 50%;
    }
}
/* PC View */
@media (min-width: 769px) {
    /* On PC, FAB is always visible if app is loaded */
    .fab {
        opacity: 1 !important;
        visibility: visible !important;
        right: 20px;
        bottom: 20px;
    }
}
#loading-indicator, #no-results-indicator {
    text-align: center;
    padding: 20px;
    font-style: italic;
    color: #777;
}