/* ========================================
   INDUSTRIAL DIGITAL TWIN - SCADA THEME
   Professional Dark Mode Design
   ======================================== */

:root {
    /* Color Palette - Industrial */
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-panel: #1a2332;
    --bg-card: #1f2937;
    
    --accent-blue: #3b82f6;
    --accent-cyan: #06b6d4;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-yellow: #f59e0b;
    --accent-orange: #f97316;
    
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --border-color: #334155;
    --glow-blue: rgba(59, 130, 246, 0.5);
    --glow-green: rgba(16, 185, 129, 0.5);
    --glow-red: rgba(239, 68, 68, 0.5);
    
    /* Tank Colors */
    --pigment-color: #dc2626;
    --base-color: #e5e7eb;
    --mixed-color: #fbbf24;
    
    /* Spacing */
    --radius: 8px;
    --radius-lg: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Roboto', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1rem;
}

/* ========================================
   HEADER
   ======================================== */

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-panel);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    font-size: 2rem;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 2px;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
    padding-left: 1rem;
    border-left: 1px solid var(--border-color);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
}

.status-indicator.online {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
    border: 1px solid var(--accent-green);
}

.status-indicator .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

.runtime {
    font-family: 'Consolas', 'Monaco', monospace;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.runtime span:last-child {
    color: var(--accent-cyan);
    font-weight: 600;
}

/* ========================================
   MAIN CONTENT GRID
   ======================================== */

.main-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    grid-template-rows: auto auto;
    gap: 1rem;
}

section {
    background: var(--bg-panel);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

section h2 {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

/* ========================================
   SCADA VISUALIZATION
   ======================================== */

.scada-panel {
    grid-column: 1 / 2;
    grid-row: 1 / 3;
}

.process-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    min-height: 500px;
    position: relative;
}

/* Tanks Row */
.process-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    gap: 1rem;
    justify-items: center;
}

.tank-group {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.tank {
    text-align: center;
}

.tank-label {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--accent-cyan);
    margin-bottom: 0.5rem;
}

.tank-body {
    width: 100px;
    height: 140px;
    background: var(--bg-card);
    border: 3px solid var(--border-color);
    border-radius: 0 0 var(--radius) var(--radius);
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}

.tank-body.large {
    width: 160px;
    height: 180px;
}

.liquid {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    transition: height 0.3s ease;
    border-radius: 0 0 4px 4px;
}

.liquid.pigment {
    background: linear-gradient(180deg, var(--pigment-color), #991b1b);
    height: 100%;
}

.liquid.base {
    background: linear-gradient(180deg, var(--base-color), #d1d5db);
    height: 100%;
}

.liquid.mixed {
    background: linear-gradient(180deg, var(--mixed-color), #d97706);
    height: 0%;
}

.level-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Consolas', monospace;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    text-shadow: 0 0 10px rgba(0,0,0,0.8);
    z-index: 10;
}

.tank-info {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    text-transform: uppercase;
}

/* Valves */
.valve-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 0.5rem;
}

.pipe {
    background: var(--border-color);
    border: 2px solid #475569;
}

.pipe.vertical {
    width: 12px;
    height: 30px;
}

.pipe.vertical.short {
    height: 20px;
}

.pipe.vertical.long {
    height: 60px;
}

.pipe.horizontal {
    width: 60px;
    height: 12px;
}

.pipe.flowing {
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue));
    animation: flow 1s linear infinite;
}

@keyframes flow {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

.valve {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 3px solid var(--accent-red);
    background: var(--bg-card);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px var(--glow-red);
}

.valve.open {
    border-color: var(--accent-green);
    box-shadow: 0 0 15px var(--glow-green);
}

.valve-icon {
    font-size: 1rem;
    color: var(--accent-red);
    transition: color 0.3s;
}

.valve.open .valve-icon {
    color: var(--accent-green);
}

.valve-label {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.valve:hover {
    transform: scale(1.1);
}

/* Pipes Junction */
.pipes-junction {
    grid-column: 1 / 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    height: 80px;
}

/* Mixer Section */
.mixer-section {
    grid-column: 1 / 3;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.tank.mixer {
    margin-top: 1rem;
}

/* Agitator */
.agitator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    z-index: 5;
}

.agitator.running {
    animation: rotate 1s linear infinite;
}

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

.blade {
    position: absolute;
    width: 100%;
    height: 4px;
    background: #475569;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    border-radius: 2px;
}

.blade:nth-child(2) {
    transform: translateY(-50%) rotate(90deg);
}

.agitator-btn {
    margin-top: 1rem;
    padding: 0.5rem 1.5rem;
    background: var(--bg-card);
    border: 2px solid var(--text-muted);
    color: var(--text-secondary);
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s;
}

.agitator-btn.active {
    border-color: var(--accent-green);
    color: var(--accent-green);
    box-shadow: 0 0 10px var(--glow-green);
}

/* ========================================
   CONTROL PANEL
   ======================================== */

.control-panel {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.control-group h3 {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.75rem;
}

.control-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
}

.control-item span:first-child {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.status {
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.status.closed {
    background: rgba(239, 68, 68, 0.2);
    color: var(--accent-red);
}

.status.open {
    background: rgba(16, 185, 129, 0.2);
    color: var(--accent-green);
}

.value {
    font-family: 'Consolas', monospace;
    color: var(--accent-cyan);
    font-weight: 600;
}

/* Action Buttons */
.action-btn {
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: var(--radius);
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 0.5rem;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.action-btn.start {
    background: linear-gradient(135deg, var(--accent-green), #059669);
    color: white;
}

.action-btn.start:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--glow-green);
}

.action-btn.stop {
    background: linear-gradient(135deg, var(--accent-red), #b91c1c);
    color: white;
}

.action-btn.stop:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--glow-red);
}

.action-btn.reset {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.action-btn.reset:hover {
    background: var(--border-color);
}

/* ========================================
   CHARTS PANEL
   ======================================== */

.charts-panel {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
}

.charts-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chart-box {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: var(--radius);
}

.chart-box h3 {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.chart-box canvas {
    max-height: 150px;
}

/* ========================================
   ALARMS BAR
   ======================================== */

.alarms-bar {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 1rem 1.5rem;
    background: var(--bg-panel);
    border-radius: var(--radius-lg);
    margin-top: 1rem;
    border: 1px solid var(--border-color);
}

.alarm-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(16, 185, 129, 0.15);
    border-radius: var(--radius);
    color: var(--accent-green);
    font-weight: 600;
}

.alarm-status.warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-yellow);
}

.alarm-status.critical {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes flow {
    0% { stroke-dashoffset: 20; }
    100% { stroke-dashoffset: 0; }
}



.alarm-icon {
    font-size: 1rem;
}

.alarm-list {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

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

@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .scada-panel {
        grid-column: 1;
        grid-row: 1;
    }
    
    .control-panel {
        grid-column: 1;
        grid-row: 2;
    }
    
    .charts-panel {
        grid-column: 1;
        grid-row: 3;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .header-left {
        flex-direction: column;
    }
    
    .subtitle {
        border-left: none;
        padding-left: 0;
    }
}
