:root {
    --sidebar-width: 260px;
    --ice-primary: #00f2ff;
    --ice-secondary: #0099ff;
    --alert-danger: #ff4d4d;
    --alert-warning: #ffb700;
    --success-green: #00ff88;

    /* Dark Theme Defaults */
    --bg-body: #0f1115;
    --bg-sidebar: linear-gradient(180deg, #13161c 0%, #0f1115 100%);
    --bg-card: #1a1d24;
    --text-main: #e0e6ed;
    --text-muted: #8b949e;
    --border-color: rgba(255, 255, 255, 0.05);
    --hover-bg: rgba(255, 255, 255, 0.03);
    --active-bg: rgba(0, 242, 255, 0.1);
}

[data-bs-theme="light"] {
    --bg-body: #f3f4f6;
    --bg-sidebar: linear-gradient(180deg, #ffffff 0%, #f3f4f6 100%);
    --bg-card: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border-color: rgba(0, 0, 0, 0.05);
    --hover-bg: rgba(0, 0, 0, 0.03);
    --active-bg: rgba(0, 153, 255, 0.1);

    /* Adjust ice colors for visibility on light bg if needed */
    --ice-primary: #0099ff;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    overflow-x: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    z-index: 1000;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease-in-out;
    transform: none;
    /* Ensure sidebar is visible on left */
    overflow-y: auto;
}

/* Collapsed state for mobile */
.sidebar.collapsed {
    transform: translateX(-100%);
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-main);
    margin-bottom: 2.5rem;
}

.brand-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--ice-primary), var(--ice-secondary));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bg-body);
}

.nav-link {
    color: var(--text-muted);
    padding: 0.8rem 1rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.nav-link:hover {
    color: var(--text-main);
    background: var(--hover-bg);
}

.nav-link.active {
    color: var(--text-main);
    background: var(--active-bg);
    border-left: 3px solid var(--ice-primary);
}

.nav-link i {
    width: 24px;
    margin-right: 8px;
}

/* Main Content */
header {
    margin-left: var(--sidebar-width);
    padding-top: 1rem;
}

.main-content {
    width: calc(100% - var(--sidebar-width));
    margin-left: var(--sidebar-width);
    padding: 2rem;
    transition: margin-left 0.3s ease-in-out;
}

.main-content.collapsed {
    margin-left: 0;
}

/* Stats Cards */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    height: 100%;
    transition: transform 0.2s, background-color 0.3s, border-color 0.3s;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--text-muted);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-trend {
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
}

.trend-up {
    color: var(--alert-warning);
}

/* Depending on context, higher temp might be bad */
.trend-down {
    color: var(--success-green);
}

.trend-neutral {
    color: var(--text-muted);
}

.glow-icon {
    position: absolute;
    right: 1.5rem;
    top: 1.5rem;
    font-size: 1.5rem;
    opacity: 0.2;
    filter: drop-shadow(0 0 10px currentColor);
}

/* Rink Visualization */
.rink-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 20px;
    height: 400px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image:
        radial-gradient(circle at 20% 50%, rgba(0, 242, 255, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 80% 50%, rgba(0, 242, 255, 0.05) 0%, transparent 40%);
}

.rink-mockup {
    width: 80%;
    height: 70%;
    border: 2px solid var(--border-color);
    border-radius: 60px;
    position: relative;
    background: var(--hover-bg);
    box-shadow: 0 0 30px rgba(0, 242, 255, 0.02);
}

.center-line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(255, 0, 0, 0.5);
    transform: translateX(-50%);
}

.blue-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(0, 60, 255, 0.5);
}

.bl-left {
    left: 33%;
}

.bl-right {
    right: 33%;
}

.heat-point {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    filter: blur(10px);
    animation: pulse 3s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }

    50% {
        transform: scale(1.5);
        opacity: 0.8;
    }

    100% {
        transform: scale(1);
        opacity: 0.5;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-body);
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-main);
}

/* Chart Containers */
.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    height: 350px;
}

.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(0, 255, 136, 0.1);
    color: var(--success-green);
    border: 1px solid rgba(0, 255, 136, 0.2);
}

.status-badge.warning {
    background: rgba(255, 183, 0, 0.1);
    color: var(--alert-warning);
    border-color: rgba(255, 183, 0, 0.2);
}

/* Camera Feed Responsive Wrapper */
.responsive-feed {
    width: 100%;
    aspect-ratio: 16/9;
    height: auto;
    display: block;
    position: relative;
    max-height: 70vh;
    /* Prevent it from becoming too large on wide screens */
    max-height: 70vh;
    /* Prevent it from becoming too large on wide screens */
}

.secondary-feed {
    width: 100%;
    aspect-ratio: 16/9;
    height: auto !important;
    position: relative;
    cursor: pointer;
    display: block;
}

/* Responsive Sidebar and Mobile Adjustments */
@media (max-width: 991.98px) {

    /* Mobile Overlay Drawer */
    .sidebar {
        transform: translateX(-100%);
        /* Hidden by default */
        box-shadow: none;
    }

    /* When NOT collapsed, it is visible (expanded) on mobile */
    .sidebar:not(.collapsed) {
        transform: translateX(0);
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.5);
    }

    /* Ensure sidebar is full width on mobile for readability */
    :root {
        --sidebar-width: 260px;
    }

    /* Main content takes full width on mobile always */
    .main-content {
        margin-left: 0 !important;
        width: 100%;
    }

    /* Responsive Camera Feed */
    .responsive-feed {
        height: auto !important;
        aspect-ratio: 16/9;
    }

    .brand-logo {
        margin-bottom: 2rem;
    }

    /* Nav links align left on mobile open drawer */
    .nav-link {
        justify-content: flex-start;
        padding: 0.8rem 1rem;
        text-align: left;
    }

    .nav-link i {
        margin-right: 8px;
        font-size: 1rem;
    }

    /* Hamburger Button Fixed Styling */
    #menuToggle {
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 2000;
        background: rgba(15, 17, 21, 0.8);
        border: 1px solid var(--border-color);
        backdrop-filter: blur(10px);
        width: 40px;
        height: 40px;
        display: flex;
        /* Ensure it overrides any other display if needed (though d-lg-none handles desktop) */
        align-items: center;
        justify-content: center;
        padding: 0;
        border-radius: 8px;
    }
}