/* 
   AQuasar UK Ltd - Secure Gas Telemetry Dashboard Stylesheet
   Theme: Clean Industrial, Corporate Premium
*/

/* Layout Structure */
.dash-body {
    background: var(--bg-gradient-dark);
    font-family: var(--font-body);
    color: var(--color-text-main);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

.dash-layout {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* Sidebar Navigation */
.dash-sidebar {
    width: 280px;
    background: rgba(5, 12, 22, 0.95);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: all var(--transition-smooth);
    backdrop-filter: var(--backdrop-blur);
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 var(--spacing-lg);
    border-bottom: 1px solid var(--glass-border);
}

.sidebar-menu-container {
    flex-grow: 1;
    padding: var(--spacing-lg) 0;
    overflow-y: auto;
}

.sidebar-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 16px;
}

.sidebar-item a {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    color: var(--color-text-muted);
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.sidebar-item a i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.sidebar-item a:hover,
.sidebar-item.active a {
    color: var(--color-white);
    background: rgba(37, 99, 235, 0.08);
    box-shadow: inset 3px 0 0 var(--color-accent);
}

.sidebar-item.active a i {
    color: var(--color-accent);
}

.sidebar-footer {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--glass-border);
    background: rgba(3, 8, 17, 0.5);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-accent);
    border: 1px solid rgba(0, 229, 255, 0.2);
    font-weight: bold;
}

.user-info {
    flex-grow: 1;
    overflow: hidden;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-white);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.user-role {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.btn-logout {
    color: var(--color-text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-logout:hover {
    color: #FF5252;
}

/* Main Dashboard Area */
.dash-main-content {
    margin-left: 280px;
    flex-grow: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: calc(100% - 280px);
    transition: all var(--transition-smooth);
}

/* Header */
.dash-header {
    height: var(--header-height);
    background: rgba(5, 12, 22, 0.8);
    backdrop-filter: var(--backdrop-blur);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-lg);
    position: sticky;
    top: 0;
    z-index: 90;
}

.dash-header-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

.sidebar-toggle-btn {
    display: none;
    font-size: 1.5rem;
    color: var(--color-white);
    cursor: pointer;
    background: transparent;
    border: none;
}

.dash-header-title h2 {
    font-size: 1.4rem;
    margin-bottom: 0;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.dash-header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.site-selector {
    background: var(--color-primary);
    border: 1px solid var(--color-border);
    color: var(--color-text-main);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
    transition: var(--transition-fast);
}

.site-selector:focus {
    border-color: var(--color-accent);
}

.sync-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: #4CAF50;
    background: rgba(76, 175, 80, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(76, 175, 80, 0.2);
}

.sync-dot {
    width: 8px;
    height: 8px;
    background-color: #4CAF50;
    border-radius: 50%;
    box-shadow: 0 0 8px #4CAF50;
    animation: pulseGlow 1.5s infinite;
}

.sync-indicator.offline {
    color: #FFA000;
    background: rgba(255, 160, 0, 0.1);
    border-color: rgba(255, 160, 0, 0.2);
}

.sync-indicator.offline .sync-dot {
    background-color: #FFA000;
    box-shadow: 0 0 8px #FFA000;
}

/* Page Containers */
.dash-content {
    padding: var(--spacing-lg);
    flex-grow: 1;
    overflow-y: auto;
}

.dash-module {
    display: none;
    animation: fadeInModule var(--transition-fast) ease-out forwards;
}

.dash-module.active {
    display: block;
}

/* Dashboard Grid & Cards */
.dash-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.metric-card {
    background: rgba(30, 42, 56, 0.4);
    border: 1px solid var(--glass-border);
    padding: var(--spacing-lg);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all var(--transition-smooth);
}

.metric-card:hover {
    border-color: rgba(37, 99, 235, 0.3);
    background: rgba(30, 42, 56, 0.6);
    transform: translateY(-2px);
}

.metric-data {
    display: flex;
    flex-direction: column;
}

.metric-label {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.metric-value {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--color-white);
    font-family: var(--font-heading);
    line-height: 1.1;
}

.metric-icon {
    font-size: 2rem;
    color: rgba(255, 255, 255, 0.1);
    transition: color var(--transition-fast);
}

.metric-card:hover .metric-icon {
    color: var(--color-accent);
}

.metric-status {
    font-size: 0.75rem;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.metric-status.status-safe { color: #4CAF50; }
.metric-status.status-warning { color: #FFA000; }
.metric-status.status-danger { color: #FF5252; }

/* Large Layout Grid */
.layout-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.layout-row.full-width {
    grid-template-columns: 1fr;
}

.panel-card {
    background: rgba(30, 42, 56, 0.4);
    border: 1px solid var(--glass-border);
    padding: var(--spacing-lg);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-lg);
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.panel-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0;
    color: var(--color-white);
    font-family: var(--font-heading);
}

.panel-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* High-Density Data Tables */
.table-container {
    overflow-x: auto;
    width: 100%;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

.data-table th {
    background: rgba(5, 12, 22, 0.5);
    padding: 14px 16px;
    color: var(--color-white);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--glass-border);
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--color-text-main);
    vertical-align: middle;
}

.data-table tr {
    transition: background var(--transition-fast);
}

.data-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.data-table tr.critical-row {
    background: rgba(255, 82, 82, 0.05);
}

.data-table tr.critical-row:hover {
    background: rgba(255, 82, 82, 0.08);
}

/* Status Badges */
.badge-status {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid transparent;
}

.badge-safe {
    background: #14532D;
    color: #86EFAC;
    border-color: #166534;
}

.badge-warning {
    background: #78350F;
    color: #FDE047;
    border-color: #92400E;
}

.badge-danger {
    background: #7F1D1D;
    color: #FCA5A5;
    border-color: #991B1B;
    animation: flashCritical 3s infinite;
}

.badge-offline {
    background: #334155;
    color: #94A3B8;
    border-color: #475569;
}

/* Dashboard Forms & Controls */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    background: var(--color-primary);
    border: 1px solid var(--color-border);
    color: var(--color-text-main);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition-fast);
}

.form-control:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
}

.btn-dash {
    background: var(--color-primary);
    border: 1px solid var(--color-accent);
    color: var(--color-accent);
    padding: 10px 24px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all var(--transition-smooth);
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-dash:hover {
    background: var(--color-accent);
    color: var(--color-white);
    box-shadow: none;
}

.btn-dash-danger {
    border-color: #FF5252;
    color: #FF5252;
}

.btn-dash-danger:hover {
    background: #FF5252;
    color: var(--color-white);
    box-shadow: 0 0 15px rgba(255, 82, 82, 0.4);
}

/* Incidents Alarms Layout */
.alarms-banner {
    background: rgba(255, 82, 82, 0.08);
    border: 1px solid rgba(255, 82, 82, 0.2);
    border-left: 4px solid #FF5252;
    padding: var(--spacing-md) var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: flashCriticalBanner 3s infinite;
}

.alarms-banner-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.alarms-banner-icon {
    font-size: 1.5rem;
    color: #FF5252;
}

.alarms-banner-text {
    font-weight: 600;
    font-size: 0.95rem;
}

/* Charts / Canvas Panel */
.chart-wrapper {
    height: 350px;
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Monospace Log Outputs */
.log-display {
    background: #030811;
    border: 1px solid var(--color-border);
    padding: var(--spacing-md);
    border-radius: var(--radius-sm);
    height: 300px;
    overflow-y: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    color: #A5D6A7;
    line-height: 1.5;
}

.log-entry {
    margin-bottom: 8px;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.03);
    padding-bottom: 4px;
}

.log-time {
    color: var(--color-accent);
}

.log-action {
    color: var(--color-white);
    font-weight: bold;
}

/* Keyframe Animations */
@keyframes pulseGlow {
    0%, 100% {
        opacity: 0.6;
        box-shadow: 0 0 4px currentColor;
    }
    50% {
        opacity: 1;
        box-shadow: 0 0 12px currentColor;
    }
}

@keyframes flashCritical {
    0%, 100% {
        opacity: 0.85;
        border-color: rgba(255, 82, 82, 0.3);
    }
    50% {
        opacity: 1;
        border-color: rgba(255, 82, 82, 1);
    }
}

@keyframes flashCriticalBanner {
    0%, 100% {
        background: rgba(255, 82, 82, 0.05);
    }
    50% {
        background: rgba(255, 82, 82, 0.12);
    }
}

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

/* Map Simulation */
.map-simulation {
    background-color: #030811;
    border: 1px solid var(--color-border);
    height: 350px;
    border-radius: var(--radius-sm);
    position: relative;
    overflow: hidden;
}

.map-node {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: pointer;
}

.map-node::after {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 1px solid currentColor;
    animation: rotateClockwise 3s linear infinite;
}

.map-node.safe {
    background-color: #4CAF50;
    color: rgba(76, 175, 80, 0.4);
}

.map-node.alarm {
    background-color: #FF5252;
    color: rgba(255, 82, 82, 0.4);
    animation: flashCritical 1.5s infinite;
}

.map-tooltip {
    position: absolute;
    background: rgba(5, 12, 22, 0.95);
    border: 1px solid var(--color-accent);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    z-index: 10;
    display: none;
    box-shadow: 0 4px 20px rgba(0, 229, 255, 0.25);
    pointer-events: none;
}

/* Site Hierarchy Grid */
.site-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--spacing-lg);
}

.site-card {
    background: rgba(30, 42, 56, 0.4);
    border: 1px solid var(--glass-border);
    padding: var(--spacing-lg);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.site-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 8px;
}

.site-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    font-family: var(--font-heading);
}

.site-card-meta {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.site-card-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
}

.site-stat {
    display: flex;
    flex-direction: column;
}

.site-stat-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
}

.site-stat-val {
    font-weight: bold;
    color: var(--color-white);
}

/* Responsive Overrides */
@media (max-width: 1200px) {
    .dash-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 992px) {
    .dash-sidebar {
        transform: translateX(-100%);
    }
    
    .dash-sidebar.active {
        transform: translateX(0);
    }
    
    .dash-main-content {
        margin-left: 0;
        width: 100%;
    }
    
    .sidebar-toggle-btn {
        display: block;
    }
    
    .layout-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 576px) {
    .dash-grid {
        grid-template-columns: 1fr;
    }
    
    .dash-header-right {
        gap: 10px;
    }
    
    .sync-indicator span {
        display: none;
    }
    
    .site-selector {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
}
