:root {
    --primary-orange: #FF5F05;
    --text-black: #000000;
    --text-white: #FFFFFF;
    --bg-white: #FFFFFF;
    --bg-light: #f8f9fa;
    --font-inter: 'Inter', sans-serif;
    --font-radio: 'Radio Canada Big', sans-serif;
    --transition: all 0.3s ease-in-out;
}

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

body {
    background-color: var(--bg-white);
    font-family: var(--font-inter);
    color: var(--text-black);
    overflow-x: hidden;
}

/* SPA View Management */
.view {
    display: none;
    min-height: 100vh;
    width: 100%;
    animation: fadeIn 0.4s ease-out;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Common Navigation */
.top-nav {
    display: flex;
    align-items: center;
    padding: 20px 40px;
    background: white;
    border-bottom: 1px solid #eee;
    gap: 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.btn-back {
    background: none;
    border: 1px solid #ddd;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-family: var(--font-inter);
    transition: var(--transition);
}

.btn-back:hover {
    background: #f0f0f0;
}

.nav-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-black);
}

/* Home Page Styles */
.intro-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 140px 20px 0px;
    gap: 56px;
    text-align: center;
}

.header-text {
    font-size: 64px;
    font-weight: 700;
    color: var(--primary-orange);
    letter-spacing: -0.025em;
    text-shadow: 0px 4px 4px rgba(0,0,0,0.25);
}

.subtitle {
    font-size: 20px;
    font-weight: 600;
    margin: 20px 0;
    max-width: 800px;
}

.btn-primary {
    background: var(--primary-orange);
    color: white;
    padding: 16px 32px;
    border-radius: 25px;
    border: none;
    font-family: var(--font-radio);
    font-size: 16px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    transform: scale(1.05);
    background: #e55404;
}

.hero-image-container {
    width: 100%;
    display: flex;
    justify-content: center;
}

.hero-image {
    width: 1037px;
    border: 5px solid var(--primary-orange);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
}

.svg-bg {
    width: 100%;
    display: block;
}

/* Hub View */
.hub-container {
    padding: 60px 40px;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.hub-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
}

.option-card {
    background: var(--bg-light);
    border: 2px solid transparent;
    border-radius: 24px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.option-card:hover {
    border-color: var(--primary-orange);
    transform: translateY(-5px);
    background: white;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}

.option-card img {
    width: 100%;
    max-width: 300px;
    height: auto;
    border-radius: 12px;
}

.option-card h3 {
    font-size: 24px;
    color: var(--text-black);
}

.option-card p {
    color: #666;
}

.building-selector {
    background: white;
    padding: 30px;
    border-radius: 24px;
    border: 1px solid #eee;
    text-align: center;
}

.building-selector select {
    padding: 12px 24px;
    font-size: 18px;
    border-radius: 12px;
    border: 1px solid #ddd;
    margin-top: 15px;
    width: 100%;
    max-width: 400px;
}

/* Map View */
.map-layout {
    display: flex;
    height: calc(100vh - 80px);
    background: #eee;
    overflow: hidden;
}

.map-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    min-width: 0;
    background: #e8e4de;
}

.map-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 0 60px rgba(0,0,0,0.06);
}

.map-svg {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}


/* ── Building overlays on map ── */
.map-building-overlay {
    position: absolute;
    transform: translate(-50%, -50%);
    cursor: pointer;
    z-index: 15;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 2px solid rgba(255,255,255,0.6);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.map-building-overlay:hover {
    transform: translate(-50%, -50%) scale(1.2);
    z-index: 20;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    border-color: white;
}

.overlay-label {
    color: white;
    font-size: 9px;
    font-weight: 700;
    text-align: center;
    line-height: 1.2;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    pointer-events: none;
    max-width: 60px;
    word-wrap: break-word;
}

/* ── Map Legend ── */
.map-legend {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(0,0,0,0.75);
    color: white;
    padding: 12px 16px;
    border-radius: 10px;
    z-index: 25;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.15);
    min-width: 110px;
}

.map-legend-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255,255,255,0.7);
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    padding-bottom: 6px;
}

.map-legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 0;
}

.map-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.3);
}

/* ── Map Detail Panel ── */
.map-detail-panel {
    width: 320px;
    flex-shrink: 0;
    background: white;
    border-left: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.map-detail-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    background: var(--bg-light);
}

.map-detail-header h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.map-datetime {
    font-size: 13px;
    color: #888;
    font-weight: 500;
}

.map-semester {
    font-size: 12px;
    color: var(--primary-orange);
    font-weight: 600;
    margin-top: 2px;
}

.map-detail-body {
    flex: 1;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.map-detail-section-title {
    font-size: 13px;
    font-weight: 700;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 8px 0 4px;
}

.map-building-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
}

.map-building-row:hover {
    background: var(--bg-light);
}

.map-building-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid rgba(0,0,0,0.1);
}

.map-building-name {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.map-building-status {
    font-size: 11px;
    font-weight: 600;
    text-align: right;
    flex-shrink: 0;
}

.map-building-percent {
    width: 36px;
    text-align: right;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.map-panel-placeholder {
    padding: 30px 20px;
    text-align: center;
    color: #888;
    font-size: 14px;
}

/* ── Monthly Calendar View ── */

.month-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    padding: 20px 40px;
    background: white;
    border-bottom: 1px solid #eee;
}

.month-arrow {
    background: none;
    border: 1px solid #ddd;
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-family: var(--font-inter);
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-orange);
    transition: var(--transition);
}

.month-arrow:hover {
    background: var(--bg-light);
    border-color: var(--primary-orange);
}

.month-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-black);
    min-width: 200px;
    text-align: center;
}

.month-calendar-wrapper {
    padding: 20px 40px;
    max-width: 900px;
    margin: 0 auto;
}

.month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    background: #eee;
    border: 1px solid #ddd;
    border-radius: 12px;
    overflow: hidden;
}

.month-grid .day-header {
    background: var(--bg-light);
    padding: 12px 8px;
    text-align: center;
    font-weight: 700;
    font-size: 14px;
    color: #555;
    text-transform: uppercase;
    border-bottom: 2px solid var(--primary-orange);
}

.month-grid .day-cell {
    background: white;
    min-height: 80px;
    padding: 6px 8px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    border: 1px solid #f0f0f0;
}

.month-grid .day-cell:hover {
    background: #fff8f0;
    border-color: var(--primary-orange);
}

.month-grid .day-cell.other-month {
    background: #fafafa;
    color: #bbb;
}

.month-grid .day-cell.today {
    background: #fff3e8;
    border-color: var(--primary-orange);
}

.month-grid .day-cell .day-number {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 2px;
}

.month-grid .day-cell .day-demand-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 2px;
}

.month-grid .day-cell .day-demand-preview {
    font-size: 9px;
    color: #888;
    line-height: 1.3;
    margin-top: auto;
}

.month-legend {
    text-align: center;
    padding: 12px;
    color: #888;
    font-size: 14px;
}

/* ── Calendar In (Hourly Detail View) ── */

.cal-in-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 40px;
    background: white;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 80px;
    z-index: 50;
}

.cal-date-display {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-black);
}

.hour-controls-in {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 16px;
    color: var(--primary-orange);
}

.hour-controls-in input[type="range"] {
    width: 200px;
    accent-color: var(--primary-orange);
}

.cal-in-content {
    padding: 30px 40px;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.hourly-chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 250px;
    padding: 20px 16px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    border-bottom: 3px solid var(--primary-orange);
    overflow-x: auto;
}

.hour-bar-container {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    height: 100%;
    justify-content: flex-end;
    width: 32px;
}

.hour-bar {
    width: 24px;
    background: var(--primary-orange);
    border-radius: 4px 4px 0 0;
    transition: height 0.4s ease;
    min-height: 2px;
}

.hour-bar-container .hour-label {
    font-size: 10px;
    color: #888;
    font-weight: 600;
}

.demand-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.building-demand-card {
    background: white;
    padding: 16px 20px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.06);
    border-left: 5px solid var(--primary-orange);
    cursor: pointer;
    transition: var(--transition);
}

.building-demand-card:hover {
    transform: translateX(4px);
    box-shadow: 0 3px 12px rgba(0,0,0,0.1);
}

.building-info {
    flex: 1;
    min-width: 0;
}

.building-info h4 {
    font-size: 16px;
    font-weight: 700;
}

.building-info p {
    font-size: 13px;
    color: #888;
    margin-top: 2px;
}

.demand-bar-bg {
    width: 200px;
    height: 10px;
    background: #eee;
    border-radius: 5px;
    overflow: hidden;
    flex-shrink: 0;
}

.demand-bar-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.3s ease;
}

.demand-value {
    font-weight: 700;
    font-size: 15px;
    width: 44px;
    text-align: right;
    flex-shrink: 0;
}

/* ── Week Selector (shared) ── */
.week-selector select {
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid #ddd;
    font-family: var(--font-inter);
    font-size: 14px;
}

@media (max-width: 768px) {
    .header-text { font-size: 42px; }
    .hub-options { grid-template-columns: 1fr; }
    .hero-image { width: 90vw; }
    .month-nav { gap: 10px; padding: 16px; }
    .month-title { font-size: 22px; min-width: 140px; }
    .month-calendar-wrapper { padding: 10px; }
    .month-grid .day-cell { min-height: 60px; padding: 4px; }
    .month-grid .day-header { font-size: 12px; padding: 8px 4px; }
    .cal-in-header { flex-direction: column; gap: 10px; top: 72px; }
    .demand-bar-bg { width: 100px; }
}