/* Custom Design System for Furward */
:root {
    --bg-dark: #090a0f;
    --card-bg: rgba(20, 22, 30, 0.75);
    --card-border: rgba(255, 255, 255, 0.06);
    --card-hover: rgba(30, 34, 46, 0.85);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    /* Status Colors */
    --color-healthy: #38bdf8;       /* Electric Sky Blue */
    --color-warning: #f97316;       /* Warning Alert Orange */
    --color-stress: #ef4444;        /* Thermal Heat Red */
    --color-success: #10b981;       /* Active Emerald Green */
    
    /* Gaps & Radius */
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
    --gap-lg: 24px;
    --gap-md: 16px;
    --gap-sm: 8px;
    
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-sans);
    overflow: hidden;
    height: 100vh;
    background-image: 
        radial-gradient(at 10% 20%, rgba(56, 189, 248, 0.05) 0px, transparent 50%),
        radial-gradient(at 90% 80%, rgba(239, 68, 68, 0.03) 0px, transparent 50%);
}

/* Dashboard Wrapper Layout */
.dashboard-wrapper {
    display: grid;
    grid-template-columns: 240px 1fr;
    height: 100vh;
    width: 100vw;
}

/* Sidebar Styling */
.sidebar {
    background: rgba(13, 14, 20, 0.95);
    border-right: 1px solid var(--card-border);
    padding: var(--gap-lg);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 10;
}

.sidebar-header {
    display: flex;
    flex-direction: column;
    gap: var(--gap-sm);
    margin-bottom: 40px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 700;
}

.logo-accent {
    font-size: 1.4rem;
    filter: drop-shadow(0 0 8px var(--color-healthy));
}

.logo-img {
    width: 56px;
    height: 56px;
    object-fit: contain;
}

/* Furward wordmark – matches the furward website brand */
.logo-text {
    color: #ffffff;
    font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
    font-size: 32px;
    font-weight: 100;
    letter-spacing: -2.4px;
    line-height: 1.6;
}

.logo-text .light-text {
    font-weight: 300;
    opacity: 0.8;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.65rem;
    letter-spacing: 1.5px;
    font-weight: 600;
    color: var(--color-success);
}

.pulse-dot {
    width: 6px;
    height: 6px;
    background-color: var(--color-success);
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse 1.6s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--gap-md);
    padding: 12px var(--gap-md);
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.nav-item.active {
    color: var(--text-primary);
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.15);
    box-shadow: 0 4px 15px rgba(56, 189, 248, 0.05);
}

.nav-item svg {
    opacity: 0.8;
}

.farm-meta {
    border-top: 1px solid var(--card-border);
    padding-top: var(--gap-lg);
    margin-top: auto;
}

.meta-label {
    font-size: 0.65rem;
    letter-spacing: 1px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: var(--gap-sm);
}

.meta-stats {
    display: flex;
    gap: var(--gap-md);
}

.meta-stat {
    display: flex;
    flex-direction: column;
}

.meta-val {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.meta-desc {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* Main Content Area */
.main-content {
    display: flex;
    flex-direction: column;
    padding: var(--gap-lg);
    overflow-x: hidden;
    overflow-y: auto;
    height: 100vh;
}

/* Header */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--gap-lg);
}

.header-search {
    position: relative;
    width: 100%;
    max-width: 320px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

#cow-search {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: 30px;
    padding: 10px 16px 10px 42px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    outline: none;
    transition: all 0.3s ease;
}

#cow-search:focus {
    border-color: var(--color-healthy);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.15);
}

.header-profile {
    display: flex;
    align-items: center;
    gap: var(--gap-md);
}

.time-widget {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.lang-switch {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: 30px;
    padding: 3px;
    gap: 2px;
    flex-shrink: 0;
}

.lang-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    padding: 5px 10px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lang-btn:hover {
    color: var(--text-primary);
}

.lang-btn.active {
    background: rgba(255, 255, 255, 0.14);
    color: var(--text-primary);
}

/* Dashboard Grid System */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 310px;
    grid-template-rows: auto auto;
    gap: var(--gap-lg);
    flex-grow: 1;
    flex-shrink: 0;
    min-height: min-content;
}

/* Base Cards with Glassmorphism */
.grid-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    padding: var(--gap-md);
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.grid-card:hover {
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.1);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--gap-md);
    padding-bottom: var(--gap-sm);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.flex-header {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: var(--gap-md);
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.count-badge {
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Left Panel: Cow List Card */
.cow-list-card {
    grid-column: 2;
    grid-row: 1 / 3;
    background: #000000 !important;
    /* Don't let the list's content height stretch the camera/summary rows;
       the card fills the left column's height and the list scrolls inside. */
    contain: size;
    min-height: 0;
}

.filter-bar {
    display: flex;
    gap: 4px;
    margin-bottom: var(--gap-md);
    overflow-x: auto;
    padding-bottom: 4px;
}

.filter-bar::-webkit-scrollbar {
    height: 3px;
}

.filter-btn {
    background: none;
    border: 1px solid transparent;
    color: var(--text-secondary);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.filter-btn.active {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--card-border);
    color: var(--text-primary);
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.blue-dot { background-color: var(--color-healthy); }
.orange-dot { background-color: var(--color-warning); }
.red-dot { background-color: var(--color-stress); }

.cow-list-scroll {
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-right: 2px;
}

/* Cow List Item styling */
.cow-item {
    background: #000000;
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-md);
    padding: 12px var(--gap-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.cow-item:hover {
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateX(2px);
}

.cow-item.active {
    background: #000000 !important;
    border: 3px solid var(--color-healthy) !important;
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.18), inset 0 0 8px rgba(56, 189, 248, 0.05) !important;
}

.cow-item-left {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.cow-id, .cow-name {
    font-size: 0.85rem;
    font-weight: 600;
}

.cow-name {
    color: var(--text-primary);
}

.cow-id {
    color: var(--text-secondary);
}

.cow-item-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cow-temp-pill {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Status Indicator Symbols */
.status-indicator {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: transform 0.2s ease;
}

.cow-item:hover .status-indicator {
    transform: scale(1.1);
}

/* Status variants — scoped to indicator badge only, NOT to cow-item rows */
.status-indicator.status-healthy {
    background: rgba(56, 189, 248, 0.1);
    color: var(--color-healthy);
    border: 1px solid rgba(56, 189, 248, 0.15);
}

.status-indicator.status-warning {
    background: rgba(249, 115, 22, 0.1);
    color: var(--color-warning);
    border: 1px solid rgba(249, 115, 22, 0.15);
    box-shadow: 0 0 10px rgba(249, 115, 22, 0.1);
}

.status-indicator.status-stress {
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-stress);
    border: 1px solid rgba(239, 68, 68, 0.15);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.15);
    animation: stress-pulse 2s infinite;
}

@keyframes stress-pulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Center Panel: Video Camera Card */
.video-card {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    flex-direction: column;
}

.camera-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.camera-lens {
    font-size: 0.65rem;
    letter-spacing: 1px;
    font-weight: 500;
    color: var(--text-muted);
}

.camera-controls {
    display: flex;
    gap: var(--gap-sm);
}

.control-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.control-btn.active {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

.btn-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--text-muted);
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.control-btn.active .btn-indicator {
    background-color: var(--color-healthy);
    box-shadow: 0 0 8px var(--color-healthy);
}

/* Image/Stream container setup */
#video-feed-video {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}

.video-stream-container {
    position: relative;
    flex-grow: 0;
    width: 100%;
    background-color: #030303;
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.video-feed-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: filter 0.5s ease;
}

/* Grayscale/Thermal effect toggle simulation */
.video-feed-image.desaturated {
    filter: grayscale(1) contrast(1.1) brightness(0.7);
}

/* Bounding box layer overlay */
.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.video-overlay.hidden {
    opacity: 0;
}

.bounding-box {
    position: absolute;
    border: 1.5px solid transparent;
    border-radius: 4px;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
    animation: scan-pulse 2s infinite ease-in-out;
}

@keyframes scan-pulse {
    0% { border-color: rgba(255, 255, 255, 0.2); }
    50% { border-color: var(--box-color); }
    100% { border-color: rgba(255, 255, 255, 0.2); }
}

.udder-box {
    --box-color: var(--color-stress);
    border-color: var(--color-stress);
    box-shadow: inset 0 0 12px rgba(239, 68, 68, 0.15);
}

.eye-box {
    --box-color: var(--color-warning);
    border-color: var(--color-warning);
    box-shadow: inset 0 0 8px rgba(249, 115, 22, 0.15);
}

.udder-box.healthy {
    --box-color: var(--color-healthy);
    border-color: var(--color-healthy);
    box-shadow: inset 0 0 12px rgba(56, 189, 248, 0.15);
}

.eye-box.healthy {
    --box-color: var(--color-healthy);
    border-color: var(--color-healthy);
    box-shadow: inset 0 0 8px rgba(56, 189, 248, 0.15);
}

.box-label {
    position: absolute;
    bottom: calc(100% + 4px);
    left: 0;
    background: rgba(0, 0, 0, 0.85);
    color: var(--text-primary);
    font-size: 0.6rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
    border: 1px solid var(--box-color);
    letter-spacing: 0.5px;
}

/* Static effects overlays */
.camera-hud-effects {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.hud-scanline {
    width: 100%;
    height: 100%;
    background: linear-gradient(
        rgba(18, 16, 16, 0) 50%, 
        rgba(0, 0, 0, 0.25) 50%
    ), linear-gradient(
        90deg, 
        rgba(255, 0, 0, 0.03), 
        rgba(0, 255, 0, 0.01), 
        rgba(0, 0, 255, 0.03)
    );
    background-size: 100% 4px, 3px 100%;
    opacity: 0.45;
}

.hud-scanline::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0; left: 0; bottom: 0; right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 0%, rgba(255, 255, 255, 0.05) 10%, rgba(18, 16, 16, 0) 10%);
    animation: scanline-move 8s linear infinite;
}

@keyframes scanline-move {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100%); }
}

.hud-rec-indicator {
    position: absolute;
    top: 16px;
    left: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.6);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.rec-dot {
    width: 6px;
    height: 6px;
    background-color: var(--color-stress);
    border-radius: 50%;
    animation: blink-rec 1s infinite alternate;
}

@keyframes blink-rec {
    0% { opacity: 0.2; }
    100% { opacity: 1; }
}

.hud-grid-crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    opacity: 0.2;
}

.hud-grid-crosshair::before, .hud-grid-crosshair::after {
    content: '';
    position: absolute;
    background-color: #fff;
}

.hud-grid-crosshair::before {
    top: 14px;
    left: 0;
    width: 30px;
    height: 2px;
}

.hud-grid-crosshair::after {
    top: 0;
    left: 14px;
    width: 2px;
    height: 30px;
}

/* Right Panel: Cow Analytics Panel */
.details-card {
    grid-column: 1;
    grid-row: 2;
}

.cow-tag-id {
    font-size: 0.8rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    color: var(--text-primary);
}

.cow-details-grid {
    display: flex;
    flex-direction: column;
    gap: var(--gap-md);
    margin-bottom: var(--gap-lg);
}

.telemetry-gauge-card {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.015);
    padding: var(--gap-md);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.2s ease;
}

.telemetry-gauge-card:hover {
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.05);
}

.gauge-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.gauge-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.gauge-val {
    font-size: 1.15rem;
    font-weight: 700;
}

.progress-bar-container {
    width: 100%;
    height: 5px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.gauge-footer {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Color States */
.text-blue { color: var(--color-healthy); }
.text-orange { color: var(--color-warning); }
.text-red { color: var(--color-stress); }
.text-green { color: var(--color-success); }

.bg-blue { background-color: var(--color-healthy); }
.bg-orange { background-color: var(--color-warning); }
.bg-red { background-color: var(--color-stress); }
.bg-green { background-color: var(--color-success); }

/* Historic sparklines styling */
.historic-charts {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.015);
    border-radius: var(--radius-md);
    padding: var(--gap-md);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.chart-header {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: var(--gap-md);
}

.chart-header h3 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.chart-info {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.svg-chart-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 80px;
}

.sparkline {
    width: 100%;
    height: 90px;
    overflow: visible;
}

.sparkline path {
    transition: d 0.5s ease;
}

.chart-x-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.6rem;
    color: var(--text-muted);
    padding-top: var(--gap-sm);
    border-top: 1px solid rgba(255, 255, 255, 0.02);
}

/* Bottom Panel: Log Card */
.log-card {
    grid-column: 2;
    grid-row: 2;
}

.card-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
}

.header-title-subtitle {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.clear-alerts-btn {
    background: none;
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-alerts-btn:hover {
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-primary);
}

.alerts-feed-wrapper {
    overflow-y: auto;
    flex-grow: 1;
    padding-right: 2px;
}

.alerts-table {
    display: flex;
    flex-direction: column;
    gap: var(--gap-sm);
}

.alert-row {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.015);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    display: grid;
    grid-template-columns: 80px 100px 1fr 100px;
    align-items: center;
    gap: var(--gap-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.alert-row:hover {
    background: var(--card-hover);
    border-color: rgba(255, 255, 255, 0.06);
}

.alert-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
}

.alert-cow-id {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.alert-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.alert-badge {
    justify-self: end;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.badge-red {
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-stress);
    border: 1px solid rgba(239, 68, 68, 0.15);
}

.badge-orange {
    background: rgba(249, 115, 22, 0.1);
    color: var(--color-warning);
    border: 1px solid rgba(249, 115, 22, 0.15);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.01);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Cow head SVG icon styling */
.cow-icon {
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
    color: var(--text-secondary);
    transition: color 0.2s ease, filter 0.2s ease;
    flex-shrink: 0;
}

.cow-item:hover .cow-icon,
.cow-item.active .cow-icon {
    color: var(--color-healthy);
    filter: drop-shadow(0 0 4px rgba(56, 189, 248, 0.4));
}

.cow-tag-id {
    display: inline-flex;
    align-items: center;
}

/* Barn map tracking tags */
.cow-map-tag {
    position: absolute;
    transform: translate(-50%, -50%);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 20px;
    background: rgba(12, 14, 22, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 10;
}

.cow-map-tag:hover {
    transform: translate(-50%, -50%) scale(1.08);
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(18, 21, 32, 0.85);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

.cow-map-tag.active {
    border-color: var(--tag-color);
    background: rgba(12, 14, 22, 0.95);
    box-shadow: 0 0 0 3px var(--tag-color), 0 4px 12px rgba(0, 0, 0, 0.5);
    transform: translate(-50%, -50%) scale(1.06);
    z-index: 20;
}

.cow-map-tag .cow-icon {
    margin-right: 0;
    width: 14px;
    height: 14px;
    color: var(--tag-color);
}

/* Status colors and glow coordinates */
.cow-map-tag.map-status-healthy {
    --tag-color: var(--color-healthy);
    --tag-glow-rgb: 56, 189, 248;
}

.cow-map-tag.map-status-warning {
    --tag-color: var(--color-warning);
    --tag-glow-rgb: 249, 115, 22;
}

.cow-map-tag.map-status-stress {
    --tag-color: var(--color-stress);
    --tag-glow-rgb: 239, 68, 68;
}

/* Analytics Header & Subheader Layout */
.analytics-header {
    align-items: flex-start !important;
    margin-bottom: 24px;
}

.analytics-header .subheader {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 6px;
}

.cow-name-label {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
}

.analytics-header .cow-tag-id {
    font-size: 0.8rem;
    background: rgba(255, 255, 255, 0.04);
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Camera label (single overhead feed) */
.camera-label {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 6px 12px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
}

/* Back link in page headers */
.back-btn,
.back-btn:visited {
    color: #ffffff;
}

.back-btn:hover {
    color: #ffffff;
    opacity: 0.8;
}


/* ============================
   NEW RIGHT PANEL STYLES
   ============================ */

/* Subheader badge row */
.subheader {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.cow-name-badge {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.cow-id-badge {
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

.status-dot-badge {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot-healthy { background: var(--color-healthy); box-shadow: 0 0 6px var(--color-healthy); }
.status-dot-warning { background: var(--color-warning); box-shadow: 0 0 6px var(--color-warning); animation: stress-pulse 2s infinite; }
.status-dot-stress  { background: var(--color-stress);  box-shadow: 0 0 6px var(--color-stress);  animation: stress-pulse 1.5s infinite; }

/* Arc Gauge Card */
.arc-gauge-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0 4px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    margin-bottom: 12px;
}

.arc-gauge-svg {
    width: 160px;
    height: 110px;
    flex-shrink: 0;
    overflow: visible;
}

.gauge-temp-status {
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.3px;
    margin-top: -4px;
    margin-bottom: 4px;
    text-align: center;
}

/* Stat Number Cards Grid */
.stat-nums-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.stat-num-card {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.04);
    border-radius: var(--radius-md);
    padding: 12px 10px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    text-align: center;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.stat-num-card:hover {
    background: rgba(255,255,255,0.035);
    border-color: rgba(255,255,255,0.08);
}

.stat-num-val {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1;
    transition: color 0.4s ease;
}

.stat-num-label {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-top: 2px;
}

.stat-num-status {
    font-size: 0.55rem;
    color: var(--text-muted);
    line-height: 1.3;
    opacity: 0.75;
}

/* Activity Row */
.activity-row {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.04);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.activity-row-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.activity-label {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.activity-val-num {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.activity-bar-track {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
    overflow: hidden;
}

.activity-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1), background 0.4s ease;
}

.activity-status-text {
    font-size: 0.62rem;
    color: var(--text-muted);
}

/* View Full History CTA */
.view-history-btn {
    width: 100%;
    background: linear-gradient(135deg, rgba(56,189,248,0.1), rgba(56,189,248,0.04));
    border: 1px solid rgba(56,189,248,0.2);
    color: var(--color-healthy);
    padding: 11px 16px;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    letter-spacing: 0.3px;
    transition: all 0.25s ease;
    margin-top: auto;
}

.view-history-btn:hover {
    background: linear-gradient(135deg, rgba(56,189,248,0.18), rgba(56,189,248,0.08));
    border-color: rgba(56,189,248,0.4);
    box-shadow: 0 4px 20px rgba(56,189,248,0.15);
    transform: translateY(-1px);
}

.view-history-btn:active {
    transform: translateY(0);
}

.view-history-btn svg {
    flex-shrink: 0;
}

/* Floating AI Chat Assistant CSS */
.ai-chat-container {
    position: fixed;
    bottom: var(--gap-lg);
    right: var(--gap-lg);
    z-index: 1000;
    font-family: var(--font-sans);
}

.ai-chat-toggle {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    border: 1px solid rgba(56, 189, 248, 0.4);
    color: #ffffff;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(2, 132, 199, 0.35);
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-chat-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(2, 132, 199, 0.5);
    background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
}

.ai-chat-window {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 330px;
    height: 420px;
    background: rgba(15, 17, 26, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.85);
    opacity: 0;
    pointer-events: none;
    transform-origin: bottom right;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ai-chat-container.open .ai-chat-window {
    transform: scale(1);
    opacity: 1;
    pointer-events: auto;
}

.ai-chat-container.open .ai-chat-toggle {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

.ai-chat-header {
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding: 14px var(--gap-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-chat-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #ffffff;
}

.ai-chat-dot {
    width: 8px;
    height: 8px;
    background-color: var(--color-success);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--color-success);
}

.ai-chat-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.ai-chat-close:hover {
    color: #ffffff;
}

.ai-chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: var(--gap-md);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-message {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 0.78rem;
    line-height: 1.4;
    max-width: 85%;
}

.ai-message-bot {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    align-self: flex-start;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.ai-message-user {
    background: #0284c7;
    color: #ffffff;
    align-self: flex-end;
}

.ai-chat-input-area {
    padding: var(--gap-sm) var(--gap-md);
    background: rgba(255, 255, 255, 0.01);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 8px;
    align-items: center;
}

.ai-chat-input-area input {
    flex-grow: 1;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    color: #ffffff;
    padding: 8px 12px;
    font-size: 0.78rem;
    font-family: inherit;
}

.ai-chat-input-area input:focus {
    outline: none;
    border-color: rgba(56, 189, 248, 0.5);
    background: rgba(255, 255, 255, 0.06);
}

.ai-chat-input-area button {
    background: #0284c7;
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.ai-chat-input-area button:hover {
    background: #0369a1;
}

/* ==============================
   Analytics Page — GIF Cameras
   ============================== */

.analytics-media-card {
    width: 100%;
}

.gifs-side-by-side {
    display: flex;
    gap: 12px;
    width: 100%;
}

.gif-container {
    position: relative;
    flex: 1 1 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #030303;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.analytics-gif {
    display: block;
    width: 100%;
    height: auto;
    object-fit: cover;
}

/* Title overlaid on the image — no box, centred at the bottom */
.gif-overlay-tag {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.8px;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
    white-space: nowrap;
    pointer-events: none;
    /* no background, no border, no padding box */
}

/* Thermal variant — slightly warmer tint */
.gif-overlay-tag.thermal-tag {
    color: rgba(255, 195, 120, 0.95);
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
}

