:root {
    --bg-color: #f9f9f9;
    --panel-bg: #ffffff;
    --text-color: #000000;
    --accent-color: #000000;
    --card-bg: #ebebeb;
}

/* -------------------------------------------------
   GLOBAL RESET
-------------------------------------------------- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden; /* Prevent scrolling */
}

/* -------------------------------------------------
   GRID LAYOUT
-------------------------------------------------- */
.layout-grid {
    display: grid;
    grid-template-columns: 180px 1fr 250px; /* Left / Main / Right */
    grid-template-rows: 100vh;
    height: 100vh;
    width: 100vw;
    gap: 0;
}

/* -------------------------------------------------
   LEFT SIDEBAR
-------------------------------------------------- */
.sidebar-left {
    background-color: #f9f9f9;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-right: 2px solid #ccc; /* vertical separator line */
}

.sidebar-left .sidebar-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-color);
    text-align: center;
    border-bottom: 2px solid #000000; /* horizontal separator line */
}

.sidebar-left .nav-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-left .nav-links a {
    text-decoration: none;
    color: var(--text-color);
    padding: 0.5rem;
    border-radius: 5px;
    transition: background 0.2s;
}

.sidebar-left .nav-links a:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* ----------------------------------------------- */
/* CLICK VISUAL FOR LEFT SIDE PANEL */
/* ---------------------------------------------- */
.sidebar-left .nav-links a.active {
    background-color: #ddd;
    font-weight: bold;
}


/* -------------------------------------------------
   MAIN CONTENT
-------------------------------------------------- */
.main-content {
    background-color: var(--bg-color);
    padding: 1rem;
    display: grid;
    grid-template-rows: auto 1fr auto; /* Top: cards, Middle: twin+chart, Bottom: DSS */
    grid-template-columns: 1fr;
    gap: 1rem;
    overflow-y: hidden; /* Prevent scrolling */
}

/* Top row: sensor cards */
.data-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.data-cards .card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border-radius: 10px;
    background-color: var(--card-bg);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.card h3 {
    font-size: 0.9rem;
    color: #000000;
    margin-bottom: 0.5rem;
}

.card .value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-color);
}

/* Middle row: Digital Twin + Chart */
.threejs-chart-wrapper {
    display: grid;
    grid-template-columns: 2fr 1fr; /* Twin takes more space */
    gap: 1rem;
    height: 390px; /* adjust as needed */
}

.threejs-chart-wrapper .threejs-wrapper,
.threejs-chart-wrapper .chart-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* 3D Model Canvas Wrapper */
.threejs-wrapper {
    position: relative;
    background-color: #ccc;
}

#canvas-container {
    width: 100%;
    height: 100%;
}

#loading-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgb(0, 0, 0);
    font-size: 1.5rem;
    pointer-events: none;
}

/* Bottom row: DSS card */
#dss-card {
    background-color: var(--card-bg);
    padding: 1rem;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
}

#dss-card h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    text-align: left;
}

#dss-content p {
    font-size: 0.9rem;
}

#dss-source {
    font-size: 0.7rem;
    color: #555;
    position: absolute;
    bottom: 8px;
    right: 12px;
    text-align: right;
}

/* SPARKLINE CHART */
.chart-container {
    background-color: var(--card-bg);
    padding: 0.5rem 1rem;
    border-radius: 10px;
    min-height: 80px;
    display: flex;
    align-items: center;
}

/* -------------------------------------------------
   RIGHT SIDEBAR (AI CHAT)
-------------------------------------------------- */
.sidebar-right {
    background-color: var(--panel-bg);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    border-left: 2px solid #ccc; /* vertical separator line */
}

.sidebar-right .chat-header {
    font-weight: bold;
    font-size: 1.2rem;
    text-align: center;
    padding-bottom: 0.5rem;
}

.sidebar-right .chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    border-radius: 10px;
    padding: 0.5rem;
    background-color: #f0f0f0;
}

/* -------------------------------------------------
   ALERT BANNERS
-------------------------------------------------- */
#alert-banner {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: rgb(255, 80, 80);
    color: white;
    padding: 12px 18px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.9rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
    opacity: 0;
    transform: translateY(20px);  
    transition: opacity 0.35s ease, transform 0.35s ease;
    z-index: 99999;
}

#alert-banner.show {
    opacity: 1;
    transform: translateY(0);
}

#alert-banner.hidden {
    opacity: 0;
    transform: translateY(20px);
}

#peak-heat-banner {
    position: fixed;
    top: -60px;
    left: 0;
    width: 100%;
    background-color: #ff8c00;
    color: white;
    padding: 15px;
    text-align: center;
    font-weight: bold;
    font-size: 1rem;
    transition: top 0.6s ease-in-out;
    z-index: 99999;
}

#peak-heat-banner.show { top: 0; }
#peak-heat-banner.hidden { top: -60; }

/* -------------------------------------------------
   RESPONSIVE DESIGN
-------------------------------------------------- */
@media (max-width: 1024px) {
    .layout-grid {
        grid-template-columns: 150px 1fr 200px;
    }
}

@media (max-width: 768px) {
    .layout-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }

    .sidebar-left, .sidebar-right {
        width: 100%;
        height: auto;
    }

    .data-cards {
        grid-template-columns: 1fr;
    }

    .threejs-chart-wrapper {
        grid-template-columns: 1fr; /* stack twin + chart vertically */
        height: auto;
    }
}
