/* 智慧工地儀表板 - 主樣式 (Restructured) */

/* ==================== Layout Structure ==================== */

.app-layout {
    display: flex;
    height: 100vh;
    background-color: var(--color-bg-primary);
    overflow: hidden;
}

body {
    background-color: var(--color-bg-primary);
    /* Light background for outer area on large screens */
    margin: 0;
    /* Ensure no default margin */
}

.main-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.top-bar {
    height: 64px;
    background-color: var(--color-bg-secondary);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 var(--space-lg);
    flex-shrink: 0;
}

/* ==================== Sidebar Styling ==================== */

.sidebar {
    width: 150px;
    /* Reduced width (approx 50% of original 260px, adjusted for content) */
    background-color: var(--color-sidebar-bg);
    display: flex;
    flex-direction: column;
    border-right: none;
    flex-shrink: 0;
    z-index: 100;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.sidebar-header {
    height: 64px;
    /* Match top bar height */
    padding: 0 var(--space-md);
    /* Reduced padding */
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    border-bottom: 1px solid var(--color-sidebar-border);
}

.brand-info .site-title {
    font-size: 0.9rem;
    /* Smaller font */
    font-weight: bold;
    color: var(--color-sidebar-text-hover);
    margin: 0;
}

.brand-info .site-subtitle {
    font-size: 0.75rem;
    color: var(--color-sidebar-text);
    margin: 0;
}

.sidebar-nav {
    flex-grow: 1;
    padding: var(--space-md) 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    /* Reduced gap */
    padding: var(--space-sm) var(--space-md);
    /* Reduced padding */
    color: var(--color-sidebar-text);
    text-decoration: none;
    transition: all 2s;
    border-left: 3px solid transparent;
    font-size: 0.85rem;
    /* Increased to ~85% (120% of previous) */
}

.nav-item:hover {
    background-color: var(--color-bg-hover);
    color: var(--color-sidebar-text-hover);
}

.nav-item.active {
    background-color: var(--color-sidebar-active-bg);
    color: var(--color-primary);
    border-left-color: var(--color-primary);
}

.nav-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sidebar-footer {
    padding: var(--space-md);
    border-top: 1px solid var(--color-sidebar-border);
    background-color: rgba(0, 0, 0, 0.05);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-top: var(--space-md);
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: white;
}

.user-info .user-name {
    font-size: 0.9rem;
    color: var(--color-sidebar-text-hover);
    font-weight: 500;
}

.user-info .user-role {
    font-size: 0.75rem;
    color: var(--color-sidebar-text);
}

.theme-toggle-btn-sidebar {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    background: transparent;
    border: 1px solid var(--color-sidebar-border);
    border-radius: var(--radius-md);
    color: var(--color-sidebar-text);
    cursor: pointer;
    transition: all 0.2s;
}

.theme-toggle-btn-sidebar:hover {
    background: var(--color-bg-hover);
    color: var(--color-sidebar-text-hover);
    border-color: var(--color-sidebar-text);
}

/* ==================== Top Bar Styling ==================== */

.page-title {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--color-text-primary);
    margin: 0;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.dashboard-title-group {
    display: flex;
    align-items: center;
}

.dashboard-main-title {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--color-text-primary);
    line-height: 1.2;
}

.powered-by {
    font-size: 0.8rem;
    color: var(--color-text-tertiary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.powered-by .brand {
    font-weight: bold;
    color: var(--color-text-secondary);
}

/* ==================== Content Grid Layout ==================== */

.content-grid {
    flex-grow: 1;
    padding: var(--space-lg);
    overflow-y: auto;
    display: grid;
    grid-template-columns: 4fr 6fr;
    /* Adjusted to 40% / 60% */
    grid-template-rows: auto auto auto;
    gap: var(--space-lg);
    grid-template-areas:
        "announcements camera"
        "people-stats people-chart"
        "env-data env-chart";
}

.grid-item {
    min-width: 0;
}


.area-announcements {
    grid-area: announcements;
}

.area-camera {
    grid-area: camera;
}

.area-people-stats {
    grid-area: people-stats;
}

.area-people-chart {
    grid-area: people-chart;
}

.area-env-data {
    grid-area: env-data;
}

.area-env-chart {
    grid-area: env-chart;
}

/* ==================== Component Styling ==================== */

/* Card Base Styles for Full Height */
.card.full-height {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

/* Card Header */
.card-header {
    padding: var(--space-md);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.02);
    flex-shrink: 0;
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

/* Card Body */
.card-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: var(--space-md);
}

/* Section Labels */
.section-label {
    font-size: 1rem;
    font-weight: bold;
    color: var(--color-text-primary);
    margin-bottom: var(--space-md);
    padding-left: var(--space-xs);
    border-left: 3px solid var(--color-primary);
    line-height: 1.2;
}

/* Announcements */
/* Announcements */
.announcement-item {
    background-color: var(--color-bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
    border-left: 4px solid var(--color-primary);
    /* Default border color */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-md);
}

.announcement-item {
    background-color: var(--color-bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
    border-left: 4px solid var(--color-primary);
    /* Default border color */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.notice-card {
    background-color: var(--color-bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-sm);
    border-left: 4px solid var(--color-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.notice-title {
    font-weight: bold;
    color: var(--color-text-primary);
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.notice-content-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

.notice-content {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    line-height: 1.4;
    flex: 1;
}

.notice-date {
    font-size: 0.75rem;
    color: var(--color-text-tertiary);
    white-space: nowrap;
}

/* Camera Grid - Responsive */
/* Camera Large View */
.camera-large-view {
    width: 100%;
    aspect-ratio: 16/9;
    background-color: black;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 1.2rem;
    border: 1px solid var(--color-border);
    position: relative;
    overflow: hidden;
}

.camera-large-view::after {
    content: "LIVE";
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(255, 0, 0, 0.7);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
}

/* Stats Grid - Responsive */
.stats-grid-compact {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    /* Adaptive columns */
    gap: var(--space-md);
}

.stat-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 100px;
}

.stat-card.highlight {
    background: linear-gradient(135deg, rgba(43, 90, 166, 0.2) 0%, rgba(43, 90, 166, 0.1) 100%);
    border-color: var(--color-primary);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--color-text-primary);
    margin-bottom: var(--space-xs);
}

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

/* Environmental Grid - Fully Responsive */
.env-grid {
    display: grid;
    /* Auto-fill columns based on available width, min 140px per card */
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--space-md);
}

.env-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: var(--space-sm);
    min-height: 100px;
}

.env-top {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
}

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

.env-info {
    display: flex;
    flex-direction: column;
}

.env-label {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    white-space: nowrap;
    /* Prevent label wrapping */
}

.env-value {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--color-text-primary);
}

/* Env Status Pill */
.env-status-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    width: 100%;
    margin-top: auto;
    /* Push to bottom */
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* Status Colors */
.status-normal .status-dot {
    background-color: #66BB6A;
}

.status-normal {
    background-color: rgba(102, 187, 106, 0.2);
    color: #66BB6A;
}

.status-warning .status-dot {
    background-color: #FFA726;
}

.status-warning {
    background-color: rgba(255, 167, 38, 0.2);
    color: #FFA726;
}

.status-danger .status-dot {
    background-color: #EF5350;
}

.status-danger {
    background-color: rgba(239, 83, 80, 0.2);
    color: #EF5350;
}

/* Responsive Layout Adjustments */
@media (max-width: 1200px) {
    .content-grid {
        grid-template-columns: 1fr;
        /* Stack everything in one column */
        grid-template-areas:
            "announcements"
            "camera"
            "people-stats"
            "people-chart"
            "env-data"
            "env-chart";
    }

    .env-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        /* Smaller cards on mobile */
    }
}

@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
        height: auto;
        overflow: auto;
    }

    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
    }

    .sidebar-nav {
        display: none;
        /* Hide nav on mobile for now or use hamburger */
    }

    .content-grid {
        padding: var(--space-md);
    }
}

/* Utilities */
.text-muted {
    color: var(--color-text-tertiary);
}

.select-compact {
    padding: 4px 8px;
    border-radius: 4px;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    color: var(--color-text-primary);
}

/* Liquid Glass Status Indicator */
.status-indicator {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 500;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: all 0.3s ease;
    overflow: hidden;
}

/* Glass Effect Layer */
.status-indicator::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 999px;
    padding: 1px;
    background: linear-gradient(180deg,
            rgba(255, 255, 255, 0.2) 0%,
            rgba(255, 255, 255, 0.05) 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

/* Status: Normal (Green) */
.status-indicator.status-normal {
    background: linear-gradient(180deg,
            rgba(74, 222, 128, 0.15) 0%,
            rgba(74, 222, 128, 0.05) 100%);
    color: #86efac;
    /* Light green text */
    box-shadow:
        0 4px 12px rgba(74, 222, 128, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Green Dot */
.status-indicator.status-normal::after {
    content: '';
    width: 8px;
    height: 8px;
    background-color: #4ade80;
    border-radius: 50%;
    box-shadow: 0 0 8px #4ade80;
    order: -1;
    /* Place before text */
}

/* Status: Warning (Orange) */
.status-indicator.status-warning {
    background: linear-gradient(180deg,
            rgba(251, 146, 60, 0.15) 0%,
            rgba(251, 146, 60, 0.05) 100%);
    color: #fdba74;
    box-shadow:
        0 4px 12px rgba(251, 146, 60, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.status-indicator.status-warning::after {
    content: '';
    width: 8px;
    height: 8px;
    background-color: #fb923c;
    border-radius: 50%;
    box-shadow: 0 0 8px #fb923c;
    order: -1;
}

/* Status: Danger (Red) */
.status-indicator.status-danger {
    background: linear-gradient(180deg,
            rgba(248, 113, 113, 0.15) 0%,
            rgba(248, 113, 113, 0.05) 100%);
    color: #fca5a5;
    box-shadow:
        0 4px 12px rgba(248, 113, 113, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.status-indicator.status-danger::after {
    content: '';
    width: 8px;
    height: 8px;
    background-color: #f87171;
    border-radius: 50%;
    box-shadow: 0 0 8px #f87171;
    order: -1;
}

/* ==================== Marquee Widget ==================== */

.marquee-widget {
    display: flex;
    align-items: center;
    background: #FEF2F2;
    /* Light red background */
    border: 1px solid #FECACA;
    border-radius: var(--radius-lg);
    padding: 0 var(--space-md);
    height: 100%;
    overflow: hidden;
    color: #DC2626;
    /* Red text */
}

.marquee-content {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    position: relative;
    mask-image: linear-gradient(to right, transparent, black 2%, black 98%, transparent);
    -webkit-mask-image: linear-gradient(to right, transparent, black 2%, black 98%, transparent);
}

.marquee-text {
    display: inline-block;
    padding-left: 100%;
    animation: marquee-scroll 30s linear infinite;
    font-weight: bold;
    font-size: 0.9rem;
    /* Reduced font size */
    line-height: 1;
    /* Ensure vertical centering */
}

@keyframes marquee-scroll {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-100%);
    }
}

/* Dark theme support */
[data-theme="dark"] .marquee-widget {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #FCA5A5;
}