/* Integrated Control Dashboard - Future Ready Styles */

/* System Health Bar */
.system-health-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.health-metric {
    background: white;
    padding: 1.2rem;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.health-metric::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--primary);
}

.health-metric.status-ok::after {
    background: var(--success);
}

.health-metric.status-warn::after {
    background: var(--warning);
}

.health-metric.status-err::after {
    background: var(--danger);
}

.health-metric.status-active::after {
    background: var(--accent);
}

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.metric-info h4 {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.metric-info .value {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
}

/* Facility Grid (Architecture, Fire, Elec, Mech) */
.facility-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.facility-card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 180px;
}

.facility-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
    border-color: rgba(59, 130, 246, 0.3);
}

.btn-toggle {
    padding: 4px 14px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid #e2e8f0;
    background: white;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-toggle.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.2);
}

.facility-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.facility-icon {
    font-size: 1.2rem;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: #f1f5f9;
}

.sensor-status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.75rem;
    margin-top: auto;
    border-top: 1px solid #f1f5f9;
    font-size: 0.85rem;
    color: #64748b;
}

.status-main {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.25rem;
    color: #1e293b;
}

.status-sub {
    font-size: 0.8rem;
    color: #94a3b8;
}

.facility-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    position: relative;
}

.facility-status-dot.normal {
    background: #10b981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}

.facility-status-dot.active {
    background: #10b981;
    animation: blink 2s infinite;
}

.facility-status-dot.warning {
    background: #f59e0b;
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.4);
}

.tech-value {
    font-family: 'Roboto Mono', monospace;
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: -0.5px;
}

.grid-dot {
    width: 100%;
    padding-bottom: 100%;
    /* square ratio */
    background: #e2e8f0;
    border-radius: 2px;
}

.grid-dot.normal {
    background: #dcfce7;
}

.grid-dot.alert {
    background: #fee2e2;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Live Log Stream */
.live-log-container {
    background: #0f172a;
    /* Deeper navy for professional look */
    color: #94a3b8;
    border-radius: 16px;
    padding: 1.5rem;
    height: 100%;
    font-family: 'Inter', 'Pretendard', sans-serif;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.2);
}

.log-list {
    list-style: none;
    padding: 0;
    margin: 0;
    height: calc(100% - 50px);
    overflow-y: auto;
    position: relative;
}

.log-list::-webkit-scrollbar {
    width: 4px;
}

.log-list::-webkit-scrollbar-track {
    background: transparent;
}

.log-list::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 10px;
}

.live-log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #334155;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #ef4444;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.log-list {
    list-style: none;
    padding: 0;
    margin: 0;
    height: 100%;
    overflow-y: hidden;
    /* We'll animate this or just show static top items */
    position: relative;
}

.log-item {
    font-size: 0.85rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #334155;
    display: flex;
    gap: 1rem;
}

.log-time {
    color: #64748b;
    min-width: 60px;
}

.log-type {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    white-space: nowrap;
    text-align: center;
    min-width: 48px;
    display: inline-block;
}

.log-item:last-child {
    border-bottom: none;
}

.log-type.info {
    background: #0f172a;
    color: #3b82f6;
}

.log-type.warn {
    background: #451a03;
    color: #f59e0b;
}

.log-type.crit {
    background: #450a0a;
    color: #ef4444;
}

/* AI Analytics & Log Section */
.ai-log-section-grid {
    display: grid;
    grid-template-columns: 2.2fr 1fr;
    gap: 1.5rem;
    align-items: stretch;
    height: 460px;
    /* 차트 하단 선에 맞춰 높이 최적화 */
}

.ai-log-section-grid>.card,
.ai-log-section-grid>.live-log-container {
    height: 100%;
    margin-bottom: 0;
}

/* Responsive adjustments */
/* Responsive adjustments */
@media (max-width: 1200px) {
    .facility-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 1024px) {
    .ai-log-section-grid {
        grid-template-columns: 1fr;
        height: auto;
        /* Remove fixed height on smaller screens */
        gap: 2rem;
    }

    .ai-log-section-grid>.card,
    .ai-log-section-grid>.live-log-container {
        height: auto;
        min-height: 400px;
        /* Give enough space for charts/logs */
    }
}

@media (max-width: 768px) {
    .facility-grid {
        grid-template-columns: 1fr;
    }

    .system-health-bar {
        grid-template-columns: 1fr;
    }

    .ai-log-section-grid>.card,
    .ai-log-section-grid>.live-log-container {
        min-height: 350px;
    }

    .live-log-container {
        padding: 1rem;
    }
}