/* ==========================================================================
   CSS SYSTEM DIRECTIVES & DESIGN TOKENS
   ========================================================================== */
:root {
    /* Palettes & Colors */
    --bg-app: #07090e;
    --bg-card: rgba(16, 22, 34, 0.65);
    --border-card: rgba(255, 255, 255, 0.06);
    --text-primary: #f0f4f8;
    --text-secondary: #8e9db0;
    --text-muted: #4e5d6e;
    
    /* Neon Glows */
    --primary-glow: #00f3ff;
    --secondary-glow: #0072ff;
    --success-glow: #00e676;
    --warning-glow: #ffb300;
    --danger-glow: #ff1744;
    
    /* Font Stacks */
    --font-ui: 'Inter', sans-serif;
    --font-digit: 'Rajdhani', sans-serif;
    
    /* Spacings */
    --radius-lg: 12px;
    --radius-md: 8px;
    --radius-sm: 4px;
}

/* ==========================================================================
   RESET & BASICS
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-family: var(--font-ui);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    padding: 20px;
    overflow-x: hidden;
}

/* ==========================================================================
   LAYOUT CONTAINER
   ========================================================================== */
.app-container {
    max-width: 1440px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ==========================================================================
   HEADER STYLE
   ========================================================================== */
.app-header {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-icon {
    background: linear-gradient(135deg, var(--primary-glow), var(--secondary-glow));
    color: #000;
    width: 44px;
    height: 44px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.4);
}

.logo-text h1 {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    font-family: var(--font-digit);
    background: linear-gradient(to right, var(--primary-glow), #ffffff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

.header-status-panel {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.status-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-md);
    padding: 6px 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.status-card .label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.status-card .value {
    font-family: var(--font-digit);
    font-size: 1.25rem;
    font-weight: 700;
    color: #ffffff;
}

.price-card .badge {
    align-self: flex-start;
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    margin-top: 4px;
    color: #000;
    background-color: var(--success-glow);
}

/* ==========================================================================
   APP GRID & SIDEBAR / MAIN PANEL
   ========================================================================== */
.app-grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
}

@media (max-width: 1024px) {
    .app-grid {
        grid-template-columns: 1fr;
    }
}

.grid-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ==========================================================================
   CARDS & CONTAINERS
   ========================================================================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 20px;
    box-shadow: 0 10px 30px 0 rgba(0, 0, 0, 0.3);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 16px;
    border-left: 3px solid var(--primary-glow);
    padding-left: 10px;
    letter-spacing: 0.5px;
}

/* ==========================================================================
   SETTINGS PANEL & CONTROLS
   ========================================================================== */
.setting-item {
    margin-bottom: 15px;
}

.setting-item label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.custom-select {
    width: 100%;
    background: #141923;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}

.custom-select:focus {
    border-color: var(--primary-glow);
}

.setting-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.3;
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-ui);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-glow);
}

.btn-danger {
    background: rgba(255, 23, 68, 0.1);
    color: #ff3366;
    border: 1px solid rgba(255, 23, 68, 0.2);
}

.btn-danger:hover {
    background: rgba(255, 23, 68, 0.2);
    box-shadow: 0 0 10px rgba(255, 23, 68, 0.2);
}

.btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ==========================================================================
   SAVINGS PANEL & RADIAL PROGRESS
   ========================================================================== */
.savings-summary {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.percent-circle-container {
    position: relative;
    width: 120px;
    height: 120px;
}

.progress-ring {
    transform: rotate(-90deg);
}

.progress-ring__circle {
    transition: stroke-dashoffset 0.35s;
    transform-origin: 50% 50%;
    stroke-dasharray: 314.16; /* 2 * PI * r (r=50) */
    stroke-dashoffset: 314.16;
}

.percent-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    display: flex;
    flex-direction: column;
}

.percent-num {
    font-family: var(--font-digit);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary-glow);
    text-shadow: 0 0 10px rgba(0, 243, 255, 0.4);
}

.percent-text {
    font-size: 0.55rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.cash-savings {
    display: flex;
    flex-direction: column;
}

.cash-savings .label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.cash-savings .value {
    font-family: var(--font-digit);
    font-size: 1.6rem;
    font-weight: 700;
    text-shadow: 0 0 15px rgba(0, 230, 118, 0.3);
}

.comparison-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.comp-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    background: rgba(255, 255, 255, 0.01);
}

.comp-row.head-row {
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: transparent;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 0;
}

.text-glow-primary {
    color: var(--primary-glow);
    text-shadow: 0 0 5px rgba(0, 243, 255, 0.2);
}

.text-success {
    color: var(--success-glow);
}

/* ==========================================================================
   SCADA VISUALIZER & DYNAMIC SVGS
   ========================================================================== */
.scada-viewport {
    background: #080c12;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    padding: 10px;
    overflow: hidden;
    position: relative;
}

/* Quy chuẩn máy bơm ly tâm công nghiệp ISA-5.1 & HMI ISA-101 */
.pump-group circle {
    transition: fill 0.3s ease, stroke 0.3s ease;
}

.pump-group polygon {
    transition: fill 0.3s ease, stroke 0.3s ease;
}

/* Trạng thái BƠM CHẠY (Màu xanh lá cây công nghiệp dịu mắt) */
.pump-active circle {
    fill: #064e3b !important;
    stroke: #10b981 !important;
}

.pump-active polygon {
    fill: #10b981 !important;
    stroke: #10b981 !important;
}

/* Trạng thái BƠM DỪNG (Màu xám tối trung tính) */
.pump-group:not(.pump-active) circle {
    fill: #1e293b !important;
    stroke: #475569 !important;
}

.pump-group:not(.pump-active) polygon {
    fill: #334155 !important;
    stroke: #475569 !important;
}

/* Đường ống lưu chất nước sạch chuẩn HMI công nghiệp */
.pipe-flow {
    transition: stroke 0.4s ease, stroke-width 0.4s ease, opacity 0.4s ease;
    opacity: 0.15;
    stroke: #334155 !important;
}

/* Đường ống hoạt động khi có dòng chảy */
.pipe-flow.flow-active {
    opacity: 1.0;
    stroke: #0284c7 !important; /* Màu xanh biển dòng nước chuẩn */
    stroke-width: 3.5px !important;
}

/* Đường ống phân phối ra ngoài đô thị */
#pipe-flow-out.flow-active {
    opacity: 1.0;
    stroke: #f97316 !important; /* Màu cam chỉ thị dòng nước phân phối thương mại */
    stroke-width: 3.5px !important;
}

#water-tank-rect {
    transition: height 0.5s cubic-bezier(0.4, 0, 0.2, 1), y 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   PUMP CONTROLS
   ========================================================================== */
.ai-banner {
    background: rgba(0, 243, 255, 0.05);
    border: 1px solid rgba(0, 243, 255, 0.15);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 0.75rem;
    color: var(--primary-glow);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    line-height: 1.4;
    transition: all 0.3s ease;
}

.ai-banner.hidden {
    display: none;
}

.pump-controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 15px;
}

.pump-ctrl-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.pump-name {
    font-size: 0.85rem;
    font-weight: 600;
}

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

.pump-status-led {
    font-family: var(--font-digit);
    font-weight: 700;
    font-size: 0.85rem;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
}

.pump-ctrl-item.active .pump-status-led {
    background: rgba(0, 243, 255, 0.15);
    color: var(--primary-glow);
    text-shadow: 0 0 5px rgba(0, 243, 255, 0.5);
}

.btn-pump-toggle {
    background: var(--bg-app);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.75rem;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
}

.btn-pump-toggle:hover:not(:disabled) {
    border-color: var(--primary-glow);
    color: var(--primary-glow);
}

.pump-ctrl-item.active .btn-pump-toggle {
    background: rgba(255, 23, 68, 0.1);
    color: #ff3366;
    border-color: rgba(255, 23, 68, 0.3);
}

.pump-ctrl-item.active .btn-pump-toggle:hover:not(:disabled) {
    background: rgba(255, 23, 68, 0.2);
}

/* ==========================================================================
   CHARTS & GRAPHS
   ========================================================================== */
.charts-card {
    display: flex;
    flex-direction: column;
}

.charts-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 1024px) {
    .charts-container {
        grid-template-columns: 1fr;
    }
}

.chart-wrapper {
    background: #080c12;
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-md);
    padding: 15px;
}

.chart-wrapper h3 {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.svg-chart-container {
    width: 100%;
    height: 200px;
    position: relative;
}

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 15px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    display: inline-block;
}

.bg-primary { background-color: var(--primary-glow); }
.bg-gray-dashed { border: 1.5px dashed var(--text-muted); background-color: transparent; }
.bg-green { background-color: var(--success-glow); }
.bg-yellow { background-color: var(--warning-glow); }
.bg-red { background-color: var(--danger-glow); }

/* ==========================================================================
   FORM & SWITCH UI ELEMENT
   ========================================================================== */
.control-mode-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 8px 16px;
    border-radius: 50px;
}

.toggle-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255,255,255,0.1);
    transition: .3s;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-secondary);
    transition: .3s;
}

input:checked + .slider {
    background-color: rgba(0, 243, 255, 0.15);
    border-color: var(--primary-glow);
}

input:checked + .slider:before {
    background-color: var(--primary-glow);
    transform: translateX(20px);
    box-shadow: 0 0 8px var(--primary-glow);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* ==========================================================================
   FOOTER STYLE
   ========================================================================== */
.app-footer {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    font-size: 0.7rem;
    color: var(--text-muted);
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    flex-wrap: wrap;
    gap: 10px;
}

.badge {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 600;
}

.bg-success {
    background: rgba(0, 230, 118, 0.15);
    color: var(--success-glow);
    border: 1px solid rgba(0, 230, 118, 0.3);
}

/* ==========================================================================
   UTILITY CLASSES
   ========================================================================== */
.hidden { display: none !important; }

/* ==========================================================================
   SCADA STANDARD COMPLIANT CUSTOM STYLES
   ========================================================================== */
/* Header EVN Logo */
.tariff-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.evn-logo {
    width: 20px;
    height: auto;
    object-fit: contain;
}

/* SCADA HMI Valves */
.valve-body {
    transition: fill 0.3s ease, stroke 0.3s ease;
}

/* Mặc định Đóng (Màu xám) */
.valve-group .valve-body {
    fill: #334155 !important;
    stroke: #475569 !important;
}

/* Khi van Mở (Màu xanh lá cây công nghiệp dịu) */
.valve-group.valve-open .valve-body {
    fill: #064e3b !important;
    stroke: #10b981 !important;
}

/* Van một chiều Check Valve */
.check-valve-group .valve-body {
    fill: #334155 !important;
    stroke: #475569 !important;
    transition: fill 0.3s ease, stroke 0.3s ease;
}

.check-valve-group.valve-open .valve-body {
    fill: #064e3b !important;
    stroke: #10b981 !important;
}

.check-valve-group .valve-circle {
    fill: #334155 !important;
    stroke: #475569 !important;
    transition: fill 0.3s ease, stroke 0.3s ease;
}

.check-valve-group.valve-open .valve-circle {
    fill: #064e3b !important;
    stroke: #10b981 !important;
}

/* Van điều khiển lưu lượng FCV101 luôn mở nhẹ đại diện phân phối liên tục */
.control-valve-group .valve-body {
    fill: #0c4a6e !important; /* Xanh lam đậm biểu thị mở tiết lưu */
    stroke: #0284c7 !important;
}

