:root {
    --bg-color: #fdf6e3;
    --text-color: #5c4d4d;
    --roof-color: #ffa1a1;
    --room-upper-front: #fff5ba;
    --room-upper-back: #bdf2d5;
    --room-lower-front: #c4d7ff;
    --room-lower-back: #ffd4e5;
    --border-color: #8c7a7a;
    --shadow-color: rgba(140, 122, 122, 0.15);
    
    --status-online: #52c41a;
    --status-offline: #ff4d4f;
    --status-loading: #faad14;
    --text-muted: rgba(0, 0, 0, 0.3);

    /* Sky Colors */
    --day-sky: #87ceeb;
    --night-sky: #1a1b26;
    --sun-color: #ffce54;
    --moon-color: #f6f1d5;
}

body.night-mode {
    --bg-color: #1a1b26;
    --text-color: #c0caf5;
    --roof-color: #414868;
    --room-upper-front: #24283b;
    --room-upper-back: #1f2335;
    --room-lower-front: #24283b;
    --room-lower-back: #1f2335;
    --border-color: #414868;
    --shadow-color: rgba(0, 0, 0, 0.4);
    --text-muted: rgba(255, 255, 255, 0.4);
    
    background-image: linear-gradient(180deg, #24283b 0%, #1a1b26 70%, #161925 100%);
}

body.night-mode .house-grid,
body.night-mode .gate-status-text {
    background-color: #24283b;
}

body.night-mode .data-group {
    background-color: rgba(65, 72, 104, 0.4);
}

body.night-mode #last-update-time {
    color: #7aa2f7;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Nunito', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 3rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 900;
    color: #ff7b9c;
    text-shadow: 2px 2px 0px rgba(255, 123, 156, 0.2);
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.1rem;
    font-weight: 700;
    color: #8fa1b3;
}

#last-update-time {
    color: #5abcb9;
}

.property-container {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    justify-content: center;
    gap: 3rem;
    width: 100%;
    max-width: 1000px;
}

.house-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

/* The Roof */
.roof {
    width: 0;
    height: 0;
    border-left: 420px solid transparent;
    border-right: 420px solid transparent;
    border-bottom: 150px solid var(--roof-color);
    margin-bottom: -10px; /* Slight overlap */
    position: relative;
    z-index: 10;
    /* Soft border effect */
    filter: drop-shadow(0 -5px 15px var(--shadow-color));
}

/* The House Grid */
.house-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 1.5rem;
    background-color: white;
    padding: 2rem;
    border-radius: 20px;
    border: 4px solid var(--border-color);
    box-shadow: 10px 10px 0px var(--shadow-color);
    width: 100%;
}

/* Individual Rooms */
.room {
    border-radius: 15px;
    padding: 1.5rem;
    border: 3px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 200px;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
}

.room:hover {
    transform: translateY(-5px);
    box-shadow: 5px 5px 0px var(--shadow-color);
}

.upper-front { background-color: var(--room-upper-front); }
.upper-back { background-color: var(--room-upper-back); }
.lower-front { background-color: var(--room-lower-front); }
.lower-back { background-color: var(--room-lower-back); }

.room-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 2px dashed rgba(0,0,0,0.1);
    padding-bottom: 0.5rem;
}

h2 {
    font-size: 1.3rem;
    font-weight: 800;
}

.status-indicator {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--status-loading);
    border: 2px solid var(--border-color);
    box-shadow: 0 0 5px rgba(0,0,0,0.1);
    transition: background-color 0.3s ease;
}

.status-indicator.online {
    background-color: var(--status-online);
    box-shadow: 0 0 10px var(--status-online);
}

.status-indicator.offline {
    background-color: var(--status-offline);
}

.sensor-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1rem;
}

.sensor-info.empty {
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-muted);
    text-align: center;
}

.data-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.5);
    padding: 0.8rem 1rem;
    border-radius: 10px;
    font-weight: 700;
}

.label {
    font-size: 1rem;
    color: var(--text-color);
}

.value {
    font-size: 1.4rem;
    font-weight: 900;
}

/* Specific colors for values to make them pop */
#temp-rajawali, #temp-rajawaliving, #temp-rajawali25 { color: #ff6b6b; }
#hum-rajawali, #hum-rajawaliving, #hum-rajawali25 { color: #4dabf7; }

/* The Front Gate */
.gate-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    margin-bottom: 2rem; /* align with bottom of house */
}

.gate-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--border-color);
    margin-bottom: 1rem;
}

.gate-structure {
    width: 160px;
    height: 140px;
    border: 8px solid var(--border-color);
    border-bottom: none;
    border-radius: 20px 20px 0 0;
    display: flex;
    position: relative;
    background-color: rgba(255,255,255,0.3);
    box-shadow: 10px 10px 0px var(--shadow-color);
    /* subtle perspective */
    perspective: 500px;
}

.gate-door {
    width: 50%;
    height: 100%;
    border: 4px solid var(--border-color);
    background: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 15px,
        var(--border-color) 15px,
        var(--border-color) 22px
    );
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.gate-door.left-door {
    transform-origin: left;
    border-right: 2px solid var(--border-color);
}

.gate-door.right-door {
    transform-origin: right;
    border-left: 2px solid var(--border-color);
}

/* Open State */
.gate-structure.open .left-door {
    transform: rotateY(-80deg);
}
.gate-structure.open .right-door {
    transform: rotateY(80deg);
}

.gate-status-text {
    margin-top: 1.5rem;
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--text-color);
    background-color: white;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    border: 3px solid var(--border-color);
    box-shadow: 5px 5px 0px var(--shadow-color);
}

/* The Compound Area */
.compound-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    margin-bottom: 2rem;
    padding: 0 1rem;
    min-width: 150px;
}

.significance-banner {
    background-color: #ffd4e5;
    color: #c92a2a;
    padding: 0.8rem 1.2rem;
    border-radius: 10px;
    font-weight: 800;
    margin-bottom: 1.5rem;
    border: 3px solid #ff87b3;
    text-align: center;
    box-shadow: 3px 3px 0px var(--shadow-color);
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.compound-items {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.vehicles-container {
    display: flex;
    gap: 1rem;
    font-size: 3.5rem;
}

.vehicle {
    transition: transform 0.3s;
    filter: drop-shadow(2px 2px 0px var(--shadow-color));
}

.vehicle:hover {
    transform: scale(1.1) rotate(-5deg);
}

.package-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: #fff5ba;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 3px dashed #e6c822;
    font-weight: 800;
    color: #8c7a7a;
    box-shadow: 2px 2px 0px var(--shadow-color);
}

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

.hidden {
    display: none !important;
}

.gate-time {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    font-weight: 700;
    color: #8fa1b3;
}

/* Responsive Adjustments */
@media (max-width: 900px) {
    .property-container {
        flex-direction: column;
        align-items: center;
    }
    
    .roof {
        border-left: 200px solid transparent;
        border-right: 200px solid transparent;
        border-bottom: 100px solid var(--roof-color);
    }
    
    .house-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }
    
    .gate-container {
        margin-top: 2rem;
    }
}

/* Sky Indicator Styles */
.sky-container {
    position: fixed;
    top: 2rem;
    right: 2rem;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    pointer-events: none;
    transition: transform 0.5s ease;
}

.sky-body {
    font-size: 3.5rem;
    filter: drop-shadow(0 0 10px rgba(0,0,0,0.1));
    animation: slow-float 4s ease-in-out infinite;
}

.night-mode .sky-body {
    filter: drop-shadow(0 0 20px rgba(246, 241, 213, 0.4));
    text-shadow: 0 0 15px rgba(246, 241, 213, 0.5);
}

.moon-phase-text {
    position: absolute;
    bottom: -1.5rem;
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--text-color);
    white-space: nowrap;
    opacity: 0.8;
}

@keyframes slow-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Outdoor Road Styles */
.road-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background-color: rgba(255, 255, 255, 0.4);
    border-radius: 20px;
    border: 4px solid var(--border-color);
    box-shadow: 10px 10px 0px var(--shadow-color);
    width: 250px;
}

body.night-mode .road-container {
    background-color: rgba(36, 40, 59, 0.6);
}

.road-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--border-color);
    margin-bottom: 1rem;
}

.road-metrics {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.road-metrics .data-group {
    background-color: rgba(255, 255, 255, 0.8);
}

body.night-mode .road-metrics .data-group {
    background-color: rgba(65, 72, 104, 0.8);
}

.road-metrics .value {
    font-size: 1.1rem;
}

.car-outside-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: #ffd4e5;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 3px dashed #ff87b3;
    font-weight: 800;
    color: #c92a2a;
    box-shadow: 2px 2px 0px var(--shadow-color);
    margin-bottom: 1rem;
    width: 100%;
    justify-content: center;
}

body.night-mode .car-outside-container {
    background-color: #414868;
    border-color: #7aa2f7;
    color: #c0caf5;
}

.road-time {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    font-weight: 700;
    color: #8fa1b3;
}


@media (max-width: 900px) {
    .sky-container {
        position: relative;
        top: 0;
        right: 0;
        margin-bottom: 2rem;
    }
}

/* Rain Overlay Effect */
.rain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 90;
    background-image: 
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 400'%3E%3Cpath d='M100,0 L95,40 M300,50 L295,90 M200,150 L195,190 M50,250 L45,290 M350,300 L345,340' stroke='%23a4d4f5' stroke-width='2' stroke-linecap='round' fill='none' opacity='0.7'/%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 300 300'%3E%3Cpath d='M150,0 L148,30 M50,100 L48,130 M250,200 L248,230 M100,250 L98,280' stroke='%237bbbf0' stroke-width='1.5' stroke-linecap='round' fill='none' opacity='0.5'/%3E%3C/svg%3E");
    background-size: 400px 400px, 300px 300px;
    animation: rain-fall-1 0.8s linear infinite, rain-fall-2 1.2s linear infinite;
}

body.night-mode .rain-overlay {
    background-image: 
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 400'%3E%3Cpath d='M100,0 L95,40 M300,50 L295,90 M200,150 L195,190 M50,250 L45,290 M350,300 L345,340' stroke='%23414868' stroke-width='2' stroke-linecap='round' fill='none' opacity='0.9'/%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 300 300'%3E%3Cpath d='M150,0 L148,30 M50,100 L48,130 M250,200 L248,230 M100,250 L98,280' stroke='%237aa2f7' stroke-width='1.5' stroke-linecap='round' fill='none' opacity='0.6'/%3E%3C/svg%3E");
}

@keyframes rain-fall-1 {
    from { background-position: 0 0, 0 0; }
    to { background-position: -40px 400px, 0 0; }
}

@keyframes rain-fall-2 {
    from { background-position: 0 0, 0 0; }
    to { background-position: 0 0, -30px 300px; }
}

/* Weather Alert */
.weather-alert {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: #dbeafe;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 3px dashed #60a5fa;
    font-weight: 800;
    color: #1e3a8a;
    box-shadow: 2px 2px 0px var(--shadow-color);
}

body.night-mode .weather-alert {
    background-color: #1e3a8a;
    border-color: #3b82f6;
    color: #bfdbfe;
}

.weather-icon {
    font-size: 1.5rem;
    animation: slow-float 2s ease-in-out infinite;
}
