/* =========================================
   1. GLOBAL VARIABLES & RESET
   ========================================= */
:root {
    /* Primary brand colors (Dark Blue) */
    --primary-green: #1A3C5A; 
    --dark-green: #122b40;    /* Darker shade for hover states */
    
    --bg-beige: #F0F2F5;
    --text-dark: #333;
    --text-dark-blue: #1A3C5A; 
    --accent-gray: #4A4A4A;
    --white: #FFFFFF;
    --font-family: 'Roboto', Arial, sans-serif;
}

* {
    box-sizing: border-box; 
}

html {
    background-color: #F0F2F5; /* Matches your beige variable */
    height: 100%;
}

body {
    font-family: var(--font-family);
    margin: 0 auto;
    padding: 0;
    background-color: var(--bg-beige);
    color: var(--text-dark);
    display: flex;
    flex-direction: column;
    min-height: 100vh; 

    max-width: 600px; 
    background-image: none; /* Reset any body backgrounds */
    background: white;      /* The "Phone" background */
    box-shadow: 0 0 50px rgba(0,0,0,0.1); /* Soft shadow */
    position: relative;
}

/* On actual mobile devices, remove the constraints */
@media (max-width: 600px) {
    body {
        max-width: 100%;
        margin: 0;
        box-shadow: none;
        border: none;
    }
}

.clean-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* =========================================
   2. HEADER & NAVIGATION
   ========================================= */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px; 
    background: var(--white);
    color: var(--text-dark-blue);
    position: fixed;
    top: 0;
    width: 100%;
    max-width: 600px; /* Match body width */
    left: 0;
    right: 0;
    margin: 0 auto;   /* Centers it horizontally */

    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    padding: 0 15px;
    box-sizing: border-box;
    gap: 10px; 
}

.logo-link { 
    line-height: 1;
    display: flex;
    align-items: center;
    flex: 0 1 auto;
}

.logo-dark {
    height: auto;
    width: auto;
    max-width: 100%; 
    max-height: 50px; 
    object-fit: contain;
    transition: transform 0.3s;
    vertical-align: middle;
}
.logo-dark:hover { transform: scale(1.05); }

.time-box {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 700;
    color: inherit; 
    line-height: 1.2;
    white-space: nowrap;
    text-align: center; 
}

.header-icons {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
}

.wifi-icon-dark {
    width: 24px;
    height: 24px;
    margin-right: 15px;
    flex-shrink: 0;
    vertical-align: middle;
    transition: fill 0.3s ease;
}
.wifi-icon-dark.connected {
    fill: var(--text-dark-blue); 
    animation: wifi-pulse 2s infinite;
}
.wifi-icon-dark.disconnected {
    fill: #bdc3c7; 
    opacity: 0.5;
}
@keyframes wifi-pulse {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.9); }
    100% { opacity: 1; transform: scale(1); }
}

.menu-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    width: 40px;
    height: 40px;
    position: relative;
    transition: transform 0.3s;
}

.hamburger-dark {
    display: block;
    width: 32px;
    height: 4px;
    background: var(--text-dark-blue);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
.hamburger-dark::before,
.hamburger-dark::after {
    content: '';
    position: absolute;
    width: 32px;
    height: 4px;
    background: var(--text-dark-blue);
    left: 0;
    transition: all 0.3s ease;
}
.hamburger-dark::before { top: -10px; }
.hamburger-dark::after { bottom: -10px; }

.flyout-menu {
    position: absolute;
    top: 60px;
    right: 10px;
    background: var(--accent-gray);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    padding: 10px 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    transform: translateX(120%); 
    transition: transform 0.3s ease-in-out;
    z-index: 999;
    width: 200px;
}
.flyout-menu.active { transform: translateX(0); }

.flyout-menu .btn {
    display: block;
    text-align: left;
    width: 100%;
    box-sizing: border-box;
    padding: 14px 15px;
    color: #E0E0E0;
    background-color: transparent;
    border-radius: 0;
    text-decoration: none;
    font-size: 1rem;
    transition: background-color 0.2s ease, color 0.2s ease;
    position: relative;
    box-shadow: none !important; 
    -webkit-tap-highlight-color: transparent;
}
.flyout-menu .btn:hover {
    background-color: #5A5A5A;
    color: var(--white);
    box-shadow: none !important;
    transform: none; 
}
.flyout-menu .btn:not(:last-child)::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 15px;
    right: 15px;
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
}

/* =========================================
   3. MAIN LAYOUT & CARDS
   ========================================= */
main {
    flex: 1; 
    padding-top: 75px;
    max-width: 800px;
    width: 100%; 
    margin: 0 auto; 
    position: relative;
    z-index: 1;
    padding-bottom: 60px; 
}

.card {
    background: var(--white);
    padding: 1.5rem;
    margin-bottom: 1rem;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08); 
    border: 1px solid rgba(0,0,0,0.05); 
}

.card p { margin-left: 1.5em; }

h2 {
    margin: 0 0 1rem;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--text-dark-blue);
}

/* =========================================
   4. STATUS CARD (At-a-Glance)
   ========================================= */
#status-card {
    transition: background-color 0.5s ease;
    text-align: center;
    padding: 15px 10px;
    margin: 0 10px 20px 10px; 
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    border-radius: 12px;
}
#status-card h2 {
    font-size: 1.8rem;
    margin: 0;
    font-weight: bold;
    letter-spacing: 1px;
    color: var(--white); 
}
#status-icon {
    font-size: 3rem;
    line-height: 1;
}

.status-on {
    background-color: var(--text-dark-blue);
    color: white;
    border: 2px solid #FFEB3B; 
}
.status-off {
    background-color: #f8f9fa !important; 
    color: var(--text-dark) !important; 
}
.status-off h2 {
     color: var(--text-dark) !important;
}

.status-on #status-icon {
    animation: bulb-pulse 1s infinite alternate;
}

@keyframes bulb-pulse {
    0% { text-shadow: 0 0 5px rgba(255, 235, 59, 0.2); }
    100% { text-shadow: 0 0 25px rgba(255, 235, 59, 1); }
}

/* =========================================
   5. CLOCK UI 
   ========================================= */
.clock-container {
    position: relative;
    width: 300px;
    height: 300px;
    margin: 20px auto;
}
.clock-ring {
    width: 100%;
    height: 100%;
}
.clock-labels {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
.label {
    position: absolute;
    font-size: 14px;
    color: #333;
    background: rgba(255, 255, 255, 0.7);
    padding: 2px 4px;
    border-radius: 3px;
}
.noon { top: 65px; left: 50%; transform: translateX(-50%); } 
.midnight { bottom: 65px; left: 50%; transform: translateX(-50%); } 
.six-am { top: 50%; left: 63px; transform: translateY(-50%); } 
.six-pm { top: 50%; right: 63px; transform: translateY(-50%); } 

.marker-icon {
    font-size: 16px; 
    text-anchor: middle;
    dominant-baseline: central;
}
.ring-emoji {
    font-size: 28px;
    text-anchor: middle;
    dominant-baseline: central;
}
#moon-emoji { font-size: 18px; }
#sun-emoji { font-size: 18px; }


#night-arc {
    fill: none;
    stroke: #1d466b; 
    stroke-width: 40px; 
    stroke-linecap: butt; 
}
#day-arc {
    fill: none;
    stroke: #50b9e9; 
    stroke-width: 40px; 
    stroke-linecap: butt; 
}
#light-on-arc {
    fill: none;
    stroke: #FFEB3B; 
    stroke-width: 16px;       /* Full "Tube" Width */
    stroke-linecap: round;
    opacity: 1.0;
    filter: none;             /* No glow yet */
    transition: opacity 0.5s ease, filter 0.5s ease; /* Smooth fill effect */
}

/* 2. ON STATE: "The Lit Neon" */
/* When JS adds this class, the tube fills with light and glows */
.lights-active #light-on-arc {
    opacity: 1.0;             /* Fully Bright */
    
    /* The Neon Glow */
    filter: drop-shadow(0 0 4px rgba(255, 235, 59, 0.6)) 
            drop-shadow(0 0 8px rgba(255, 235, 59, 0.4));
}

#light-on-marker {
    display: none !important;
}

/* The Yellow Legend Dot */
.status-dot {
    display: inline-block;
    width: 16px;
    height: 16px;
    background-color: #FFEB3B; /* Matches the Arc Color */
    border-radius: 50%;        /* Makes it a perfect circle */
    
    /* optional: align it nicely if it looks off-center */
    vertical-align: middle;
    margin-right: 8px;
}

#sunrise-gradient-arc,
#sunset-gradient-arc {
    fill: none;
    stroke: url(#twilight-gradient);
    stroke-width: 40px;
    stroke-linecap: butt;
}
#outer-bevel {
    fill: none;
    stroke: #FFFFFF;
    stroke-width: 6px; 
    opacity: 0.2; 
}
#inner-bevel {
    fill: none;
    stroke: #000000;
    stroke-width: 5px; 
    opacity: 0.2; 
}

.center-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    cursor: pointer;
    width: 110px; 
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 110px; 
    text-decoration: none;
    -webkit-tap-highlight-color: transparent; /* Remove blue highlight on mobile */
}

#center-value {
    display: flex;          
    flex-direction: column; 
    align-items: center;
    width: fit-content;      
    font-size: 32px;        
    font-weight: 600;
    color: #2c3e50;
    line-height: 1.0;       
    margin-bottom: 2px;     
}

.unit {
    font-size: 0.6em;
    font-weight: 400;
    margin-left: 2px;
}

.center-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #7f8c8d;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.card-action-icon {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 1.5rem; /* Nice and touchable */
    text-decoration: none;
    line-height: 1;
    cursor: pointer;
    z-index: 10; /* Ensure it floats above everything else */
    transition: transform 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.card-action-icon:hover {
    transform: scale(1.2); /* Slight pop effect on hover */
}

.radio-group {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    padding: 10px;
    background-color: #f4f4f4;
    border-radius: 8px;
}
.radio-group div {
    display: flex;
    align-items: center;
}
.radio-group label {
    margin-left: 5px;
    font-weight: 500;
}

.loader {
    border: 5px solid #f3f3f3; 
    border-top: 5px solid #3498db; 
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.tick-major {
    stroke: #FFFFFF; 
    stroke-width: 2px;
}
.tick-minor {
    stroke: #FFFFFF; 
    stroke-width: 1px;
}
.svg-time-label {
    font-size: 11px;
    font-family: sans-serif;
    fill: #333;
    text-anchor: middle;
    dominant-baseline: central;
    font-weight: bold;
}

/* =========================================
   6. WIDGETS & FORMS (UPDATED FOR MOBILE)
   ========================================= */
.legend {
    display: flex;
    flex-direction: column; 
    align-items: center;    
    gap: 10px; 
    padding: 10px 0;
}
.legend > div {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px; 
}
.legend-icon {
    display: inline-block;
    width: 20px;
    text-align: center;
    vertical-align: middle;
    font-size: 20px;
    margin-right: 8px;
}

/* --- Buttons with Tactile Feel --- */
.btn {
    padding: 0.6rem 1.5rem; 
    text-decoration: none;
    color: var(--white);
    background-color: var(--primary-green);
    border-radius: 8px; 
    border: none;
    font-size: 1rem;
    font-weight: 600; 
    cursor: pointer;
    
    box-shadow: 0 4px 6px rgba(26, 60, 90, 0.3); 
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;

    -webkit-tap-highlight-color: transparent;
    outline: none; 
}

.btn:hover {
    background-color: var(--dark-green);
    box-shadow: 0 6px 12px rgba(26, 60, 90, 0.4);
    transform: translateY(-2px);
}

.btn:active {
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2); 
    transform: translateY(1px);
}

.btn-unsaved {
    background-color: #50b9e9 !important; /* Daylight Blue */
    color: #fff !important;
    font-weight: 700;
    box-shadow: 0 0 10px rgba(80, 185, 233, 0.6);
    animation: pulse-blue 2s infinite;
}

.btn-unsaved:hover {
    background-color: #3faad9 !important; /* Slightly darker on hover */
}

@keyframes pulse-blue {
    0% { box-shadow: 0 0 0 0 rgba(80, 185, 233, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(80, 185, 233, 0); }
    100% { box-shadow: 0 0 0 0 rgba(80, 185, 233, 0); }
}

/* --- Inputs with Depth --- */
input, select {
    padding: 0.75rem;
    border: 1px solid #ddd; 
    border-radius: 8px;
    width: 100%;       
    max-width: 100%;   
    box-sizing: border-box;
    font-size: 16px;   
    
    background-color: #fafafa; 
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.06);
    transition: all 0.3s ease;
}

input:focus, select:focus {
    background-color: #fff;
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(26, 60, 90, 0.2); 
    outline: none;
}
.input-pair {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    margin-bottom: 15px;
    width: 100%; 
}
.input-pair label {
    margin-bottom: 5px; 
    font-size: 1rem;
    line-height: 1.5;
    font-weight: 500;
}

/* Slider Value Readout */
.slider-value {
    font-size: 2rem;
    font-weight: 700;
    color: #0277bd; /* Brand Blue */
    text-align: center;
    
    /* NEW SPACING */
    margin-top: 10px;    /* Pushes it down from the "Total Light" label */
    margin-bottom: 2px;  /* Pulls it closer to the "8h 16h" labels */
    
    font-variant-numeric: tabular-nums; 
}

/* Container for spacing */
.range-container {
    width: 100%;
    padding: 10px 0;
}

/* RESET Default Browser Styles */

input[type=range] {
    -webkit-appearance: none; 
    width: 100%;
    background: transparent;
    -webkit-tap-highlight-color: transparent; 
}

/* NEW: Enforce Gray Track even while dragging/active */
input[type=range]:active::-webkit-slider-runnable-track, input[type=range]:focus::-webkit-slider-runnable-track {
    background: #e0e0e0; /* Forces it to stay gray */
}

input[type=range]:focus {
    outline: none;
}

/* The Track (The Grey Bar) */
input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 12px;
    cursor: pointer;
    background: #e0e0e0;
    border-radius: 6px;
    border: 1px solid #ccc;
}

/* The Thumb (The Blue Handle) */
input[type=range]::-webkit-slider-thumb {
    height: 28px;
    width: 28px;
    border-radius: 50%;
    background: #0277bd; /* Brand Blue */
    cursor: pointer;
    -webkit-appearance: none;
    margin-top: -9px; /* Centers thumb on the track */
    box-shadow: 0 2px 4px rgba(0,0,0,0.3); /* Adds depth */
}

/* Firefox Styles (Because Firefox handles ranges differently) */
input[type=range]::-moz-range-track {
    width: 100%;
    height: 12px;
    cursor: pointer;
    background: #e0e0e0;
    border-radius: 6px;
}
input[type=range]::-moz-range-thumb {
    height: 28px;
    width: 28px;
    border: none;
    border-radius: 50%;
    background: #0277bd;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Min/Max Labels base style */
.slider-labels {
    display: flex;
    justify-content: space-between;
    color: #888;
    font-size: 0.9rem;
    padding: 0 5px;
}

.slider-labels.top-labels {
    margin-bottom: 2px; /* Small gap above the container */
}

#duration-container, 
#time-container, 
#config-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 10px;
    margin: 0 auto 1rem;
}

@media (min-width: 600px) {
    #duration-container, 
    #time-container, 
    #config-container {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 1rem;
    }
}

.tab-nav {
    display: flex;
    border-bottom: 2px solid #ccc;
}
.tab-btn {
    padding: 0.75rem 1rem;
    border: 1px solid transparent;
    border-bottom: none;
    background-color: #E0E0E0;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--accent-gray);
    border-radius: 5px 5px 0 0;
    margin-right: 5px;
    margin-bottom: -2px; 
    opacity: 0.7;
}
.tab-btn.active {
    background-color: var(--white);
    color: var(--primary-green);
    font-weight: 700;
    border-color: #ccc;
    border-bottom-color: var(--white);
    opacity: 1;
}
.tab-content.hidden { display: none; }


input[type="file"] {
    padding: 10px 0;     
    height: auto;        
    border: none;        
    background: transparent;
    margin-top: 5px;
    
    box-shadow: none !important; 
    border-radius: 0 !important;
    appearance: none;    
    -webkit-appearance: none;
    
    pointer-events: auto;
    cursor: pointer;
    z-index: 10;         
    position: relative;  
    display: block;      
    width: 100%;
}

/* --- Location Tab Layout --- */
.location-split-row {
    display: flex;
    align-items: flex-start; /* Align both items to the TOP, not center */
    gap: 10px;
    margin-bottom: 15px;
    padding-top: 10px; /* Give the row a little headroom */
}

.loc-inputs {
    flex: 1; 
    min-width: 110px;
    margin-top: 20px; /* Push inputs down slightly to center them on the map visually */
}

.map-container-small {
    flex: 2; 
    max-width: 65%; 
    display: flex;
    flex-direction: column; /* <--- CRITICAL: Stacks Map on top of Text */
    justify-content: center;
    align-items: center;
    margin-top: -20px; 
}

/* Ensure the map is allowed to grow */
.map-container-small svg {
    width: 100%;
    height: auto;
    display: block; /* Removes weird spacing inherent to inline SVGs */
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.15)); 
}

.map-caption {
    font-size: 0.75rem;
    color: #888;
    margin-top: 2px; /* Adds a tiny gap between map and text */
    font-style: italic;
    text-align: center;
    width: 100%;
}

/* =========================================
   7. ALERTS & NOTIFICATIONS
   ========================================= */
.warning {
    color: #e74c3c;
    font-style: italic;
    margin: 15px 0;
}
.warning-banner {
    background-color: #fff3cd;
    color: #856404;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ffeeba;
    border-radius: 4px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.warning-banner.hidden { display: none; }

.toast {
    position: fixed;
    top: 10px;
    right: 10px;
    padding: 5px 15px;
    border-radius: 5px;
    color: var(--white);
    z-index: 1000;
    transition: opacity 0.5s;
}
.toast.error { background: #e74c3c; }
.toast.success { background: #2ecc71; }

#toast {
    top: 60px; 
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000; 
    cursor: pointer; 
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    box-sizing: border-box; 
}

.overlay.hidden { display: none; }

.overlay .card {
    text-align: center;
    max-width: 300px;
    width: 100%;
}

.btn-danger {
    background-color: #e74c3c; 
    color: white;
}
.btn-danger:hover {
    background-color: #c0392b; 
}


#lightEventLog {
    padding-left: 0;
    list-style-type: none;
    margin-bottom: 0; 
}

.log-day-header {
    background-color: #f4f4f4;
    padding: 8px 12px;
    margin-top: 10px;
    border-bottom: 1px solid #ddd;
}
.log-day-header h3 {
    margin: 0;
    font-size: 1.0rem;  /* Smaller size */
    white-space: nowrap; /* Forces it to stay on one line */
    overflow: hidden;    /* Safety: clips text if it still runs over */
    text-overflow: ellipsis; /* Adds "..." if it really won't fit */
}
.log-event { padding: 4px 12px; }
#lightEventLog hr {
    border: 0;
    border-top: 1px solid #eee;
    margin: 8px 0;
}

/* =========================================
   8. FOOTER
   ========================================= */
footer {
    background-color: var(--text-dark);
    color: var(--white);
    
    position: fixed;
    bottom: 0;
    width: 100%;
    max-width: 600px; /* Match body width */
    left: 0;
    right: 0;
    margin: 0 auto;   /* Centers it horizontally */
    z-index: 1000;
    
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    
    padding: 10px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
}

footer p { 
    margin: 0; 
    font-size: 0.9rem; 
    opacity: 0.85; 
    text-align: center;
}

.footer-lighter {
    padding-top:0.5em;
    font-size: 0.8rem; 
    opacity: 0.7;     
}

/* =========================================
   9. MOBILE RESPONSIVE
   ========================================= */
@media (max-width: 600px) {
    header { height: 50px; padding: 0 10px; }
    .logo-dark { max-height: 35px; }
    .logo-link { width: 180px; }
    .time-box { font-size: 0.8rem; }
    .menu-btn { width: 35px; height: 35px; }
    .wifi-icon-dark { margin-right: 5px; }
    
    .hamburger-dark, .hamburger-dark::before, .hamburger-dark::after {
        width: 26px;
        height: 3px;
        left: 50%;
        transform: translateX(-50%);
    }
    .hamburger-dark { transform: translate(-50%, -50%); }
    .hamburger-dark::before { top: -8px; }
    .hamburger-dark::after { bottom: -8px; }

    .flyout-menu { top: 50px; width: 180px; }
    
    main { padding-top: 65px; padding-bottom: 60px; }
    .card { padding: 1rem; margin-bottom: 0.8rem; }
    h2 { font-size: 1.4rem; }
    
    #status-card { margin: 0 10px 15px 10px; }
    #status-card h2 { font-size: 1.3rem; }
    #status-icon { font-size: 2rem; }

    .legend > div { gap: 10px; }
    .button-group { gap: 5px; }
    
    #duration-container, 
    #time-container, 
    #config-container { 
        gap: 15px; 
        margin-bottom: 10px; 
    }
}

/* --- Sub-Header Navigation --- */
.sub-header {
    width: 100%;
    max-width: 600px; 
    margin: 0 auto;
    padding: 2px 10px 10px 14px; 
    box-sizing: border-box;
    text-align: left;
}

.sub-header a {
    text-decoration: none;
    color: #444444; 
    font-size: 0.95rem; 
    font-weight: 350;
    display: inline-flex;
    align-items: center;
    transition: opacity 0.2s;
}

.sub-header a:hover { opacity: 0.7; }

/* --- Segmented Control (Toggle Switch) --- */
.segmented-control {
    display: flex;
    background-color: #E0E0E0; 
    border-radius: 25px;       
    padding: 4px;
    margin-bottom: 20px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.segmented-control input[type="radio"] { display: none; }

.segmented-control label {
    flex: 1;
    text-align: center;
    padding: 10px;
    border-radius: 20px; 
    font-size: 0.95rem;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap; 
    
    -webkit-tap-highlight-color: transparent; 
    outline: none;
}

.segmented-control label:hover { background-color: rgba(255,255,255,0.5); }

.segmented-control input:checked + label {
    /* UPDATED: Changed from dark blue to light daytime blue */
    background-color: #50b9e9; 
    color: var(--white);
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transform: scale(1.02); 
}

/* --- Button Groups (Save/Cancel) --- */
.button-group {
    display: flex;
    /* UPDATED: Reverse order so Save is on the right */
    flex-direction: row-reverse;
    justify-content: flex-start; /* Keep them grouped */
    /* UPDATED: Add spacing between buttons */
    gap: 20px; 
    margin-top: 20px;
}

/* Fixed Height Container to prevent button jumping */
.mode-viewport {
    min-height: 224px; /* Adjust this number if your content clips */
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Align content to the top */
    padding-top: 10px;
}

/* =========================================
   10. DARK MODE SUPPORT
   ========================================= */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-beige: #121212;       
        --text-dark: #E0E0E0;      
        --white: #1E1E1E;          
        --accent-gray: #2C2C2C;    
    }

    .card {
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
        border: 1px solid #333;
    }
    
    input, select {
        background-color: #2D2D2D;
        box-shadow: inset 0 2px 4px rgba(0,0,0,0.5); 
        border-color: #444;
    }
    input:focus, select:focus {
        border-color: var(--primary-green);
        background-color: #333;
    }

    .label {
        background: rgba(30, 30, 30, 0.85); 
        color: #FFF;
    }
    .svg-time-label {
        fill: #FFF; 
    }
    
    #center-value {
        color: #E0E0E0; 
    }
    .center-label {
        color: #AAAAAA;
    }

    .segmented-control {
        background-color: #2D2D2D;
        box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
    }
    .segmented-control label {
        color: #AAA;
    }
    .segmented-control input:checked + label {
        color: #FFF; 
    }

    .tab-btn {
        background-color: #2D2D2D;
        color: #AAA;
    }
    .tab-btn.active {
        background-color: var(--white); 
        border-bottom-color: var(--white);
        color: var(--primary-green);
    }

    .log-day-header {
        background-color: #252525;
        border-bottom: 1px solid #444;
    }
    #lightEventLog hr {
        border-top: 1px solid #444;
    }
    
    .warning-banner {
        background-color: #3e2e00; 
        color: #ffdf7e;            
        border-color: #665200;
    }
    
    .status-off {
        background-color: #2D2D2D !important;
        color: #AAA !important;
    }
     .status-off h2 {
         color: #AAA !important;
    }
}

/* =========================================
   11. CHARTS & GRAPHS
   ========================================= */
.chart-container {
    display: flex;
    justify-content: space-evenly;
    align-items: stretch;
    height: 180px;
    padding: 40px 0 20px 0; 
    border-bottom: 1px solid #ccc;
    position: relative;
    margin-bottom: 10px;
}

.bar-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end; 
    width: 100%;
    height: 100%;
    position: relative;
}

.bar-label {
    margin-top: 5px;
    font-size: 0.75rem;
    color: #666;
}

.bar-labels-top {
    position: absolute;
    top: -38px; 
    width: 100%;
    text-align: center;
    z-index: 0;
}

.bar-total {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-dark);
}

.bar-stack {
    width: 24px; 
    height: 100%;
    display: flex;
    flex-direction: column-reverse; 
    align-items: center;
    justify-content: flex-start; 
}

.bar-segment {
    width: 100%;
    transition: height 0.5s ease;
    box-sizing: border-box; 
    position: relative; 
    display: flex;
    justify-content: center; 
}

.bar-segment.artificial {
    background-color: #FFEB3B; 
    border: 1px solid #FBC02D; 
    border-bottom: none;       
    border-radius: 0 0 4px 4px;
}

.bar-segment.natural {
    background-color: #50b9e9; 
    border-radius: 4px 4px 0 0;
    opacity: 1.0; 
}

.bar-text-natural {
    position: absolute;
    top: -14px; 
    color: #50b9e9; 
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1;
    text-shadow: 0px 1px 0px #fff; 
}

.bar-text-added {
    position: absolute;
    bottom: 2px; 
    color: #FFEB3B; 
    font-size: 0.65rem;
    font-weight: 800;
    text-shadow: 0px 1px 2px rgba(0,0,0,0.4); 
    line-height: 1;
    z-index: 1;
}

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 15px;
    font-size: 0.8rem;
    color: #666;
}

.dot-actual { background-color: #50b9e9; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; }
.dot-added { background-color: #FFEB3B; border: 1px solid #FBC02D; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; }

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.chart-header h2 {
    margin: 0;
    font-size: 1.2rem;
}
.chart-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 15px;
    font-weight: 700;
    color: var(--text-dark);
    font-size: 0.9rem;
}

.nav-arrow {
    background: none;
    border: none;
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--primary-green);
    cursor: pointer;
    padding: 5px 10px;
    user-select: none;
}

.nav-arrow:hover {
    color: var(--dark-green);
    transform: scale(1.2);
}

.nav-arrow.disabled {
    color: #ccc;
    cursor: default;
    pointer-events: none;
}


@media (prefers-color-scheme: dark) {
    .chart-container { border-bottom-color: #444; }
    .chart-controls { color: #ccc; }
    .bar-label { color: #aaa; }
    .bar-total { color: #ddd; }
    .bar-text-natural { text-shadow: none; color: #81d4fa; } 
    .bar-segment.artificial, .dot-added { border: none; }
    .nav-arrow.disabled { color: #444; }
}

/* =========================================
   12. LOG REASON TAGS
   ========================================= */
.log-tag {
    display: inline-block;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
    font-weight: 500;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tag-fixed {
    background-color: #e3f2fd;
    color: #1A3C5A; 
    border: 1px solid #bbdefb;
}

.tag-pullet {
    background-color: #f3e5f5;
    color: #7b1fa2; 
    border: 1px solid #e1bee7;
}

.tag-off {
    background-color: #fff3e0;
    color: #ef6c00; 
    border: 1px solid #ffe0b2;
}

.tag-test {
    background-color: #e3f2fd;
    color: #1565c0; 
    border: 1px solid #bbdefb;
}

.tag-system {
    background-color: #ffebee;
    color: #c62828; 
    border: 1px solid #ffcdd2;
}

.tag-working {
    background-color: #fff3e0; /* Pale Orange */
    color: #ef6c00;            /* Dark Orange */
    border: 1px solid #ffe0b2;
}

@media (prefers-color-scheme: dark) {
    .tag-fixed  { background-color: #0d47a1; color: #90caf9; border-color: #1565c0; }
    .tag-pullet { background-color: #4a148c; color: #e1bee7; border-color: #7b1fa2; }
    .tag-off    { background-color: #e65100; color: #ffcc80; border-color: #ef6c00; }
    .tag-test   { background-color: #0d47a1; color: #90caf9; border-color: #1565c0; }
    .tag-system { background-color: #b71c1c; color: #ef9a9a; border-color: #c62828; }
    .tag-working { background-color: #e65100; color: #ffcc80; border-color: #ef6c00; }
}

/* Position the icon on the top LEFT */
.card-action-icon.left {
    right: auto; /* Reset the right property */
    left: 15px;
}

/* Warning List Styling */
.warning-item {
    background-color: #ffebee; /* Light Red background */
    border: 1px solid #ef9a9a;
    color: #c62828;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.warning-icon-large {
    font-size: 1.5rem;
}

.hidden {
    display: none !important;
}

/* --- Diagnostic List View --- */
.diag-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.diag-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 5px;
    border-bottom: 1px solid #eee;
    font-size: 0.95rem;
}
.diag-item:last-child {
    border-bottom: none;
}
.diag-label {
    color: #666;
    font-weight: 500;
}
.diag-value {
    color: var(--text-dark-blue);
    font-weight: 700;
    text-align: right;
}

@media (prefers-color-scheme: dark) {
    .diag-item { border-bottom-color: #333; }
    .diag-label { color: #aaa; }
    .diag-value { color: #fff; }
}

/* =========================================
   SYSTEM HEALTH DASHBOARD
   ========================================= */

/* 1. Health Status Banner */
.status-card-health {
    padding: 0 !important; /* Remove default card padding */
    overflow: hidden;
}

.health-banner {
    display: flex;
    align-items: center;
    padding: 20px;
    background: #e8f5e9; /* Light Green */
    border-left: 6px solid #4CAF50;
}
.health-banner.success .health-icon {
    font-size: 2rem;
    color: #4CAF50;
    margin-right: 15px;
}
.health-text h3 { margin: 0; font-size: 1.2rem; color: #2e7d32; }
.health-text p { margin: 0; font-size: 0.9rem; color: #666; }

/* 2. Warning Items (Injected by JS) */
.warning-container {
    padding: 0;
    margin: 0;
    list-style: none;
}
.warning-item {
    background: #ffebee;
    border-left: 6px solid #e53935; /* Red Border */
    border-radius: 0; /* Flat look */
    margin: 0;
    padding: 15px;
    border-bottom: 1px solid #ffcdd2;
}

/* 3. Vitals Grid */
.vitals-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.vital-item {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #eee;
}

.vital-icon { font-size: 1.5rem; }

.vital-data {
    display: flex;
    flex-direction: column;
}
.vital-label {
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    font-weight: 600;
}
.vital-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-dark-blue);
    word-break: break-word; /* Prevents overflow on long uptime strings */
}

/* Dark Mode Support for new items */
@media (prefers-color-scheme: dark) {
    .health-banner { background: #1b5e20; border-left-color: #66bb6a; }
    .health-banner .health-icon { color: #66bb6a; }
    .health-text h3 { color: #fff; }
    .health-text p { color: #ccc; }
    
    .vital-item { background: #2d2d2d; border-color: #444; }
    .vital-value { color: #fff; }
}

/* =========================================
   USAGE BAR STYLES (Memory / Storage)
   ========================================= */

.usage-display {
    width: 100%;
}

.vital-value {
    /* Ensure the vital-value is a block element so the bar drops below it */
    display: block; 
    margin-bottom: 4px;
}

.usage-bar-container {
    width: 100%;
    height: 6px;
    background-color: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
}

.usage-bar {
    height: 100%;
    width: 0%; /* JS will update this */
    background-color: var(--primary-green);
    transition: width 0.3s ease-out;
}

/* Color indicator for high usage (e.g., Memory is 80% used) */
.usage-bar.warning {
    background-color: #ff9800; /* Amber */
}

/* Color indicator for critical usage (e.g., Memory is 95% used) */
.usage-bar.critical {
    background-color: #e53935; /* Red */
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .usage-bar-container {
        background-color: #444;
    }
}
/* --- Location Tab Layout --- */
.location-split-row {
    display: flex;
    align-items: center; 
    gap: 15px;
    margin-bottom: 15px;
}

.loc-inputs {
    flex: 1; 
}

.map-container-small {
    flex: 1;
    max-width: 50%; 
    display: flex;
    justify-content: center;
    align-items: center;
}

.map-container-small svg {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.15)); /* Slightly stronger shadow for depth */
}
}

/* --- Map Coloring (Brand Style) --- */
.map-path {
    fill: #1A3C5A;       /* Brand Dark Blue */
    stroke: #FFFFFF;     /* White Outline for contrast */
    stroke-width: 1.5;   
    stroke-linejoin: round;
    stroke-linecap: round;
    transition: fill 0.3s ease;
}

/* Optional: Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .map-path {
        fill: #1A3C5A;   /* Stays Dark Blue */
        stroke: #555555; /* Darker border so it doesn't glare */
    }
}

/* Mobile Stack */
@media (max-width: 350px) {
    .location-split-row {
        flex-direction: column-reverse; 
        align-items: stretch;
    }
    .map-container-small {
        max-width: 100%;
        margin-bottom: 15px;
    }
}