/* Enhanced Background */
body { 
    background: linear-gradient(135deg, #0a0a1a 0%, #1a1a2e 50%, #16213e 100%);
    overflow-x: hidden; 
    position: relative; 
    min-height: 100vh; 
    color: #d1d5db; 
}

#lightning-canvas { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    z-index: -1; 
    opacity: 0.8;
}

.content-wrapper { 
    position: relative; 
    z-index: 1; 
    background: linear-gradient(to bottom, rgba(17, 24, 39, 0.85), rgba(17, 24, 39, 0.95)); 
    padding: 1rem; 
    min-height: 100vh; 
}

.dashboard-card { 
    background: linear-gradient(135deg, rgba(31, 41, 55, 0.9) 0%, rgba(55, 65, 81, 0.8) 100%);
    backdrop-filter: blur(12px); 
    border: 1px solid rgba(103, 232, 249, 0.3); 
    border-radius: 0.75rem; 
    padding: 1rem; 
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), 0 0 20px rgba(103, 232, 249, 0.1); 
    transition: all 0.3s ease-in-out;
    position: relative;
    overflow: hidden;
}

.dashboard-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(103, 232, 249, 0.1), transparent);
    transition: left 0.5s;
}

.dashboard-card:hover::before {
    left: 100%;
}

.dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), 0 0 30px rgba(103, 232, 249, 0.2);
}

.dashboard-card-header { 
    color: #67e8f9; 
    font-size: 0.875rem; 
    font-weight: 600; 
    margin-bottom: 0.75rem; 
    text-transform: uppercase; 
    letter-spacing: 0.05em; 
    border-bottom: 1px solid rgba(103, 232, 249, 0.3); 
    padding-bottom: 0.5rem;
    text-shadow: 0 0 10px rgba(103, 232, 249, 0.5);
}

.kpi-value { 
    font-family: 'Orbitron', sans-serif; 
    color: #67e8f9; 
    text-shadow: 0 0 15px rgba(103, 232, 249, 0.8); 
    font-size: 1.875rem; 
    line-height: 2.25rem; 
    font-weight: 700; 
    text-align: center; 
    word-break: break-all; 
}

.comparison-value { 
    font-family: 'Orbitron', sans-serif; 
    font-size: 1.5rem; 
    font-weight: 600; 
    text-align: center; 
}

.positive-change { color: #4ade80; text-shadow: 0 0 10px rgba(74, 222, 128, 0.5); } 
.negative-change { color: #f87171; text-shadow: 0 0 10px rgba(248, 113, 113, 0.5); } 
.neutral-change { color: #d1d5db; }

.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.status-complete { background-color: #4ade80; box-shadow: 0 0 10px rgba(74, 222, 128, 0.5); }
.status-partial { background-color: #fbbf24; box-shadow: 0 0 10px rgba(251, 191, 36, 0.5); }
.status-empty { background-color: #f87171; box-shadow: 0 0 10px rgba(248, 113, 113, 0.5); }

.loader { 
    border: 4px solid rgba(243, 244, 246, 0.3); 
    border-top: 4px solid #67e8f9; 
    border-radius: 50%; 
    width: 40px; 
    height: 40px; 
    animation: spin 1s linear infinite; 
    position: absolute; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%); 
    z-index: 10;
    display: none;
}

@keyframes spin { 
    0% { transform: translate(-50%, -50%) rotate(0deg); } 
    100% { transform: translate(-50%, -50%) rotate(360deg); } 
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: linear-gradient(135deg, rgba(17, 24, 39, 0.5) 0%, rgba(31, 41, 55, 0.3) 100%);
    border-radius: 0.5rem;
    border: 1px solid rgba(103, 232, 249, 0.2);
}

/* Enhanced scrollbar */
::-webkit-scrollbar { width: 8px; } 
::-webkit-scrollbar-track { background: rgba(31, 41, 55, 0.5); } 
::-webkit-scrollbar-thumb { background: #67e8f9; border-radius: 4px; } 
::-webkit-scrollbar-thumb:hover { background: #22d3ee; }

/* Sticky table header with blur */
thead.sticky-top {
    backdrop-filter: blur(10px);
}

/* Sticky control panel */
.control-panel-sticky {
    position: sticky;
    top: 56px; /* Adjust based on header height */
    z-index: 1010;
    backdrop-filter: blur(15px);
    transition: all 0.3s ease;
    margin-bottom: 1.5rem !important;
}

/* Add shadow when stuck */
.control-panel-sticky.stuck {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* Adjust control panel responsiveness */
@media (max-width: 768px) {
    .control-panel-sticky {
        overflow-x: auto;
        padding: 0.75rem !important;
    }
    .control-panel-sticky .row {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.5rem;
    }
}

/* Pulse animation for loading states */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.pulse { animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }

/* 排序指示器樣式 */
.sort-indicator {
    display: inline-block;
    margin-left: 0.25rem;
    transition: transform 0.2s ease;
}
.sort-indicator::after {
    content: '⇅';
    opacity: 0.3;
    font-size: 0.75rem;
}
.sort-asc .sort-indicator::after {
    content: '↑';
    opacity: 1;
    color: #67e8f9;
}
.sort-desc .sort-indicator::after {
    content: '↓';
    opacity: 1;
    color: #67e8f9;
}

.loading { opacity: 0.7; }
.hidden { display: none; }

/* 趨勢範圍按鈕樣式 */
.trend-range-btn {
    color: #d1d5db;
    background: transparent;
    cursor: pointer;
    position: relative;
    z-index: 10;
    user-select: none;
    border: none;
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 0.25rem;
    transition: all 0.2s;
}
.trend-range-btn:hover {
    background: rgba(55, 65, 81, 0.5);
    color: #e5e7eb;
}
.trend-range-btn.active {
    background: #67e8f9;
    color: #111827;
    font-weight: 600;
}

/* Bootstrap overrides for dark theme */
.form-select, .form-control {
    background-color: #374151;
    border-color: #4b5563;
    color: #fff;
}

.form-select:focus, .form-control:focus {
    background-color: #374151;
    border-color: #67e8f9;
    color: #fff;
    box-shadow: 0 0 0 0.25rem rgba(103, 232, 249, 0.25);
}

.form-select option {
    background: #1a1a2e;
}

/* Checkbox 樣式 */
.form-check-input {
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.form-check-input:checked {
    background-color: #67e8f9;
    border-color: #67e8f9;
}

.form-check-input:focus {
    border-color: #67e8f9;
    box-shadow: 0 0 0 0.25rem rgba(103, 232, 249, 0.25);
}

.form-check-label {
    color: #ffffff !important;
}

.btn-cyan {
    background-color: #0891b2;
    color: white;
}

.btn-cyan:hover {
    background-color: #0e7490;
    color: white;
}

.table-dark {
    --bs-table-bg: transparent;
}

/* Responsive utilities */
@media (max-width: 768px) {
    .kpi-value {
        font-size: 1.5rem;
    }
    
    .chart-container {
        height: 250px;
    }
}

/* Override Bootstrap's text-muted for better visibility on dark background */
.text-muted {
    color: #d1d5db !important; /* Light gray color */
    opacity: 1 !important;
}

/* Extra light version for less important text */
.text-muted.opacity-75 {
    opacity: 0.75 !important;
}

/* Peak analysis view buttons */
.peak-view-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #d1d5db;
    padding: 0.25rem 0.75rem;
    transition: all 0.2s;
    font-size: 0.875rem;
    cursor: pointer;
    position: relative;
    z-index: 10;
}

.peak-view-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #d1d5db;
    border-color: rgba(255, 255, 255, 0.3);
}

.peak-view-btn.active {
    background: rgba(103, 232, 249, 0.2);
    color: #67e8f9;
    border-color: #67e8f9;
}

.peak-view {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.peak-view.hidden {
    opacity: 0;
    pointer-events: none;
}

.peak-view-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(103, 232, 249, 0.5);
}

/* Peak analysis text visibility fixes */
.card-body span:not([class*="text-"]) {
    color: #d1d5db;
}

.card-body .small:not([class*="text-"]) {
    color: #d1d5db;
}

/* Ensure card titles are visible */
.card-title {
    color: #67e8f9 !important;
}

/* Fix for overview cards */
.card.bg-dark .card-body {
    color: #d1d5db;
}

/* 電號欄位樣式 */
.meter-number {
    font-family: 'Courier New', Courier, monospace;
}

/* 自定義文字顏色 - 替代 Bootstrap 的暗色文字 */
.text-light-muted {
    color: #d1d5db !important; /* 淺灰色 */
}

.text-light-secondary {
    color: #a5f3fc !important; /* 淺青色 */
}

/* 覆蓋 Bootstrap 預設的暗色文字 */
.text-muted {
    color: #9ca3af !important; /* 提高亮度 */
}

.text-secondary {
    color: #a5f3fc !important; /* 使用淺青色替代 */
}

/* 響應式設計 - 1024px 以下使用平板風格 */
@media (max-width: 1024px) {
    .col-lg-6 {
        width: 100%;
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* 手機版樣式 (768px 以下) */
@media (max-width: 768px) {
    /* 隱藏手機版分隔符號 */
    .mobile-separator {
        display: none;
    }
    
    /* 時段用電統計 - 手機版垂直排列 */
    #peak-chart-view .col-6 {
        width: 100%;
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* 統計卡片手機版樣式 */
    #peak-chart-view .bg-dark {
        padding: 1rem !important;
        min-height: auto !important;
    }
    
    /* 調整數值顯示為垂直排列 */
    #peak-chart-view .d-flex.align-items-center {
        flex-direction: column !important;
        gap: 0.25rem;
    }
    
    #peak-chart-view .d-flex.align-items-center span {
        display: block;
        margin: 0 !important;
    }
    
    /* 隱藏分隔符號 */
    .mobile-separator {
        display: none;
    }
    
    /* 調整字體大小 */
    #peak-chart-view .fw-bold {
        font-size: 1.25rem;
    }
    
    #peak-chart-view .small {
        font-size: 0.875rem;
    }
    
    /* 添加分隔線 */
    #peak-chart-view .d-flex.align-items-center::after {
        content: "";
        display: block;
        width: 80%;
        height: 1px;
        background: rgba(255, 255, 255, 0.1);
        margin: 0.5rem auto;
    }
    
    /* 區域詳細比較 - 添加橫向滾動容器 */
    .area-comparison-wrapper {
        position: relative;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
    }
    
    /* 固定表格最小寬度 */
    .area-comparison-wrapper table {
        min-width: 700px;
    }
    
    
    /* 調整 KPI 卡片間距 */
    .row.g-3 {
        --bs-gutter-x: 0.5rem;
        --bs-gutter-y: 0.5rem;
    }
    
    /* 調整儀表板卡片內距 */
    .dashboard-card {
        padding: 0.75rem;
    }
    
    /* 調整表格字體大小 */
    .table-sm {
        font-size: 0.75rem;
    }
    
    /* 各電號詳細資料表格優化 */
    .table-responsive {
        font-size: 0.75rem;
    }
    
    /* 修正尖峰用電統計卡片高度 */
    #peak-chart-view > div > div {
        height: auto !important;
    }
    
    /* 移除時段用電統計的固定高度 */
    #peak-chart-view .d-flex.align-items-stretch {
        height: auto !important;
    }
    
    /* 確保所有統計項目都能顯示 */
    #peak-chart-view .row {
        margin-bottom: 0;
    }
    
    /* 調整統計卡片間距 */
    #peak-chart-view .col-6 {
        margin-bottom: 0.5rem;
    }
    
    /* 最後一行的卡片不需要底部間距 */
    #peak-chart-view .col-6:nth-last-child(-n+2) {
        margin-bottom: 0;
    }
}