/* Dashboard Section Styles */
/* Traffic Analysis Dashboard for Cement Factory */

/* ==========================================
   SECTION BASE STYLES
   ========================================== */

#dashboard-section {
    padding-top: 100px;
    padding-bottom: 100px;
    min-height: 100vh;
}

/* Hide global footer (marquee bar) when dashboard is active */
body.dashboard-active .marquee-bar {
    display: none !important;
}

.dashboard-page {
    
    margin: 0 auto;
   
}

/* ==========================================
   DATE RANGE BUTTONS (in global header)
   ========================================== */

.dashboard-date-range {
    display: flex;
    background: white;
    border-radius: 8px;
    padding: 3px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.date-btn {
    padding: 6px 14px;
    border: none;
    background: transparent;
    font-size: 11px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.date-btn:hover {
    color: #1a1a2e;
    background: rgba(0, 0, 0, 0.03);
}

.date-btn.active {
    background: linear-gradient(135deg, #E85E53 0%, #8E31BB 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(142, 49, 187, 0.3);
}

/* ==========================================
   DASHBOARD GRID
   ========================================== */

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 24px;
    margin-bottom: 32px;
}

/* ==========================================
   PANEL BASE STYLES
   ========================================== */

.dashboard-panel {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.04);
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.dashboard-panel:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

/* Load Analysis panel (left) */
.dashboard-panel-wide {
    grid-column: 1;
    grid-row: 1;
}

/* Loads chart panel (right) - same row as Load Analysis */
.dashboard-grid > .dashboard-panel:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
}

/* Make both panels in first row equal height */
.dashboard-grid > .dashboard-panel-wide,
.dashboard-grid > .dashboard-panel:nth-child(2) {
    min-height: 480px;
}

/* Panel content should fill available space */
.dashboard-panel .panel-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.dashboard-panel-stats {
    grid-column: 1 / 3;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    background: transparent;
    border: none;
    box-shadow: none;
}

.dashboard-panel-stats:hover {
    box-shadow: none;
    transform: none;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 0;
}

.panel-title {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a2e;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-title i {
    font-size: 20px;
    color: #8E31BB;
}

.panel-nav {
    display: flex;
    gap: 8px;
}

.panel-nav-btn {
    width: 32px;
    height: 32px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #6b7280;
    transition: all 0.2s ease;
}

.panel-nav-btn:hover {
    border-color: #E85E53;
    color: #E85E53;
    background: rgba(232, 94, 83, 0.05);
}

.panel-content {
    padding: 20px 24px 24px;
}

/* ==========================================
   PLANT STATS (LOAD ANALYSIS)
   ========================================== */

.plant-stats {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.plant-row {
    display: grid;
    grid-template-columns: 120px 1fr 100px;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    transition: all 0.2s ease;
}

.plant-row:last-child {
    border-bottom: none;
}

.plant-row:hover {
    background: rgba(0, 0, 0, 0.01);
    margin: 0 -16px;
    padding: 12px 16px;
    border-radius: 8px;
}

.plant-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.plant-name {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a2e;
}

.plant-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: fit-content;
}

.plant-badge-primary {
    background: rgba(102, 173, 214, 0.15);
    color: #3a9fd4;
}

.plant-badge-success {
    background: rgba(34, 197, 94, 0.15);
    color: #16a34a;
}

.plant-badge-warning {
    background: rgba(234, 179, 8, 0.15);
    color: #ca8a04;
}

.plant-bar-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.plant-bar {
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.04);
    position: relative;
}

.plant-bar-fill {
    height: 100%;
    width: var(--bar-width, 50%);
    border-radius: 4px;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Bar Colors */
.plant-bar-red .plant-bar-fill {
    background: linear-gradient(90deg, #E85E53 0%, #f87171 100%);
}

.plant-bar-orange .plant-bar-fill {
    background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%);
}

.plant-bar-blue .plant-bar-fill {
    background: linear-gradient(90deg, #3b82f6 0%, #60a5fa 100%);
}

.plant-bar-light-blue .plant-bar-fill {
    background: linear-gradient(90deg, #66ADD6 0%, #93c5fd 100%);
}

.plant-bar-purple .plant-bar-fill {
    background: linear-gradient(90deg, #8E31BB 0%, #a855f7 100%);
}

.plant-bar-green .plant-bar-fill {
    background: linear-gradient(90deg, #22c55e 0%, #4ade80 100%);
}

.plant-bar-amber .plant-bar-fill {
    background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%);
}

.plant-bar-yellow .plant-bar-fill {
    background: linear-gradient(90deg, #eab308 0%, #facc15 100%);
}

.plant-tonnage {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a2e;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.plant-tonnage small {
    font-size: 11px;
    font-weight: 500;
    color: #9ca3af;
    margin-left: 4px;
}

/* ==========================================
   CHART SECTION
   ========================================== */

.chart-wrapper {
    flex: 1;
    min-height: 220px;
    position: relative;
}

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #6b7280;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend-dot-blue {
    background: #3b82f6;
}

.legend-dot-red {
    background: #E85E53;
}

.legend-dot-yellow {
    background: #eab308;
}

/* ==========================================
   STAT CARDS
   ========================================== */

.stat-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.stat-card-gradient-1::before {
    background: linear-gradient(90deg, #E85E53 0%, #f87171 100%);
}

.stat-card-gradient-2::before {
    background: linear-gradient(90deg, #8E31BB 0%, #a855f7 100%);
}

.stat-card-gradient-3::before {
    background: linear-gradient(90deg, #66ADD6 0%, #93c5fd 100%);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-card-gradient-1 .stat-icon {
    background: rgba(232, 94, 83, 0.1);
    color: #E85E53;
}

.stat-card-gradient-2 .stat-icon {
    background: rgba(142, 49, 187, 0.1);
    color: #8E31BB;
}

.stat-card-gradient-3 .stat-icon {
    background: rgba(102, 173, 214, 0.1);
    color: #66ADD6;
}

.stat-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-value {
    font-size: 32px;
    font-weight: 800;
    color: #1a1a2e;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.stat-value small {
    font-size: 16px;
    font-weight: 500;
    color: #9ca3af;
}

.stat-label {
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
}

.stat-trend {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    width: fit-content;
}

.stat-trend-up {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
}

.stat-trend-down {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
}

.stat-trend i {
    font-size: 14px;
}

/* ==========================================
   ANALYSIS HISTORY
   ========================================== */

.dashboard-history {
    margin-top: 8px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.history-title {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a2e;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.history-title i {
    font-size: 22px;
    color: #8E31BB;
}

.history-view-all-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
}

.history-view-all-btn:hover {
    border-color: #8E31BB;
    color: #8E31BB;
    background: rgba(142, 49, 187, 0.05);
}

.history-view-all-btn i {
    font-size: 14px;
    transition: transform 0.2s ease;
}

.history-view-all-btn:hover i {
    transform: translateX(4px);
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

/* ==========================================
   ANALYSIS CARDS
   ========================================== */

.analysis-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.04);
    transition: all 0.3s ease;
}

.analysis-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
}

.analysis-thumbnail {
    position: relative;
    height: 160px;
    background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
    overflow: hidden;
}

.analysis-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.analysis-thumbnail-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 48px;
    color: #9ca3af;
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
}

.analysis-detection-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    height: 50%;
    border: 2px solid #22c55e;
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.3);
    pointer-events: none;
}

.analysis-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 4px 10px;
    background: rgba(34, 197, 94, 0.9);
    color: white;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
}

.analysis-badge-warning {
    background: rgba(234, 179, 8, 0.9);
}

.analysis-details {
    padding: 16px;
}

.analysis-time {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 22px;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 8px;
}

.analysis-time i {
    font-size: 18px;
    color: #9ca3af;
}

.analysis-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 12px;
}

.analysis-plant {
    font-size: 13px;
    color: #6b7280;
}

.analysis-tonnage {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a2e;
}

.analysis-axles {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 10px 12px;
    background: #f8f9fc;
    border-radius: 8px;
}

.axle-dots {
    display: flex;
    gap: 6px;
}

.axle-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.axle-count {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
}

.analysis-video-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #1a1a2e;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
}

.analysis-video-btn i {
    font-size: 14px;
    color: #E85E53;
}

.analysis-video-btn:hover {
    background: linear-gradient(135deg, #E85E53 0%, #8E31BB 100%);
    color: white;
    border-color: transparent;
}

.analysis-video-btn:hover i {
    color: white;
}

/* ==========================================
   ANIMATIONS
   ========================================== */

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

@keyframes dashboardFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes barGrow {
    from {
        width: 0;
    }
    to {
        width: var(--bar-width, 50%);
    }
}

/* Panel animations when section becomes active */
#dashboard-section.active .dashboard-animate {
    animation: dashboardSlideUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    animation-delay: calc(var(--animation-order, 1) * 0.1s);
    opacity: 0;
}

#dashboard-section.active .analysis-card-animate {
    animation: dashboardSlideUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    animation-delay: calc(0.4s + (var(--card-order, 1) * 0.08s));
    opacity: 0;
}

/* Bar fill animation */
#dashboard-section.active .plant-bar-fill {
    animation: barGrow 1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    animation-delay: 0.5s;
    width: 0;
}

/* ==========================================
   RESPONSIVE DESIGN
   ========================================== */

@media (max-width: 1400px) {
    .history-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .history-grid .analysis-card:last-child {
        display: none;
    }
}

@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .dashboard-panel-wide {
        grid-column: 1;
        grid-row: auto;
    }
    
    .dashboard-grid > .dashboard-panel:nth-child(2) {
        grid-column: 1;
        grid-row: auto;
    }
    
    .dashboard-grid > .dashboard-panel-wide,
    .dashboard-grid > .dashboard-panel:nth-child(2) {
        min-height: auto;
    }
    
    .dashboard-panel-stats {
        grid-column: 1;
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {
    .history-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .history-grid .analysis-card:nth-child(3),
    .history-grid .analysis-card:last-child {
        display: block;
    }
    
    .history-grid .analysis-card:last-child {
        display: none;
    }
}

@media (max-width: 768px) {
    #dashboard-section {
        padding-top: 90px;
    }
    
    .dashboard-page {
        padding: 0 16px 40px;
    }
    
    .dashboard-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .dashboard-header-right {
        justify-content: space-between;
    }
    
    .dashboard-title {
        font-size: 26px;
    }
    
    .dashboard-panel-stats {
        grid-template-columns: 1fr;
    }
    
    .plant-row {
        grid-template-columns: 80px 1fr 70px;
        gap: 12px;
    }
    
    .plant-tonnage {
        font-size: 15px;
    }
    
    .history-grid {
        grid-template-columns: 1fr;
    }
    
    .history-grid .analysis-card:nth-child(3),
    .history-grid .analysis-card:last-child {
        display: none;
    }
}

@media (max-width: 480px) {
    .dashboard-date-range {
        width: 100%;
    }
    
    .date-btn {
        flex: 1;
        padding: 8px 10px;
        font-size: 12px;
    }
    
    .plant-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .plant-info {
        flex-direction: row;
        align-items: center;
        gap: 10px;
    }
    
    .plant-tonnage {
        text-align: left;
    }
    
    .stat-value {
        font-size: 26px;
    }
}

/* ==========================================
   DARK MODE SUPPORT (if implemented)
   ========================================== */

body.dark-mode #dashboard-section {
    background: linear-gradient(135deg, #1a1a2e 0%, #16162a 100%);
}

body.dark-mode .dashboard-panel,
body.dark-mode .stat-card,
body.dark-mode .analysis-card {
    background: #252540;
    border-color: rgba(255, 255, 255, 0.06);
}

body.dark-mode .dashboard-title {
    -webkit-text-fill-color: #fff;
    background: none;
}

body.dark-mode .panel-title,
body.dark-mode .plant-name,
body.dark-mode .stat-value,
body.dark-mode .analysis-time,
body.dark-mode .analysis-tonnage,
body.dark-mode .history-title {
    color: #f1f1f1;
}

body.dark-mode .dashboard-subtitle,
body.dark-mode .stat-label,
body.dark-mode .analysis-plant,
body.dark-mode .legend-item,
body.dark-mode .axle-count {
    color: #9ca3af;
}

body.dark-mode .dashboard-date-range,
body.dark-mode .dashboard-refresh-btn,
body.dark-mode .panel-nav-btn,
body.dark-mode .history-view-all-btn,
body.dark-mode .analysis-video-btn {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: #d1d5db;
}

body.dark-mode .date-btn {
    color: #9ca3af;
}

body.dark-mode .date-btn:hover {
    color: #f1f1f1;
    background: rgba(255, 255, 255, 0.1);
}

body.dark-mode .plant-bar {
    background: rgba(255, 255, 255, 0.1);
}

body.dark-mode .analysis-axles {
    background: rgba(0, 0, 0, 0.2);
}

body.dark-mode .analysis-thumbnail-placeholder {
    background: linear-gradient(135deg, #2d2d4a 0%, #1f1f3a 100%);
}

