/**
 * Pure CSS Base Styles - Dashboard Core
 * ====================================
 * Complete styling system with modern design
 */

/* CSS Variables - Design System */
:root {
    /* Primary Color Palette */
    --primary-gray: #4B5563;
    --light-gray: #F3F4F6;
    --dark-gray: #1F2937;
    --medium-gray: #6B7280;
    --accent-gray: #9CA3AF;
    --border-gray: #D1D5DB;
    --text-gray: #374151;
    
    /* Status Colors */
    --success-green: #10B981;
    --warning-orange: #F59E0B;
    --danger-red: #EF4444;
    --info-blue: #3B82F6;
    
    /* Typography */
    --font-family-primary: 'Inter', sans-serif;
    --font-family-heading: 'Poppins', sans-serif;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 0.75rem;
    --spacing-lg: 1rem;
    --spacing-xl: 1.5rem;
    --spacing-2xl: 2rem;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    
    /* Transitions */
    --transition-fast: 0.15s ease-in-out;
    --transition-normal: 0.3s ease-in-out;
    --transition-slow: 0.5s ease-in-out;
}

/* Reset and Base Styles */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family-primary);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-gray);
    background-color: var(--light-gray);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-family-heading);
    font-weight: 600;
    margin: 0 0 var(--spacing-lg) 0;
    color: var(--dark-gray);
}

h1 { font-size: 2.25rem; line-height: 1.2; }
h2 { font-size: 1.875rem; line-height: 1.3; }
h3 { font-size: 1.5rem; line-height: 1.4; }
h4 { font-size: 1.25rem; line-height: 1.4; }
h5 { font-size: 1.125rem; line-height: 1.5; }
h6 { font-size: 1rem; line-height: 1.5; }

/* Section Titles */
.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--dark-gray);
    margin-bottom: var(--spacing-xl);
    padding-bottom: var(--spacing-sm);
    position: relative;
    text-align: center;
    font-family: var(--font-family-heading);
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, var(--primary-gray), var(--medium-gray));
    border-radius: 1px;
}

/* RedLine Title with Red Underline */
.section-title.redline-title::after {
    background: linear-gradient(90deg, var(--danger-red), #dc2626);
    height: 3px;
    width: 80px;
}

/* Dashboard Section */
.dashboard-section {
    margin-bottom: var(--spacing-2xl);
    padding: var(--spacing-xl);
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.dashboard-section:first-child {
    margin-top: var(--spacing-sm); /* Reduced from var(--spacing-xl) to minimize gap */
}

/* Pure CSS Navbar */
.pure-navbar {
    background: linear-gradient(135deg, var(--dark-gray) 0%, var(--primary-gray) 100%);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1000;
    min-height: 64px;
    display: flex;
    align-items: center;
}

.pure-navbar-dark {
    background: linear-gradient(135deg, var(--dark-gray) 0%, var(--primary-gray) 100%);
}

.pure-navbar .pure-container-fluid {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: var(--spacing-lg) var(--spacing-xl);
}

.navbar-left,
.navbar-center,
.navbar-right {
    display: flex;
    align-items: center;
}

.navbar-center {
    flex: 1;
    justify-content: center;
}

.pure-navbar-brand {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 1.25rem;
    font-weight: 600;
    color: white;
    text-decoration: none;
    font-family: var(--font-family-heading);
    transition: var(--transition-fast);
}

.pure-navbar-brand:hover {
    color: #e5e7eb;
    text-decoration: none;
}

.pure-navbar-brand i {
    font-size: 1.5rem;
}

.navbar-text {
    color: #d1d5db;
    font-size: 0.875rem;
    margin: 0 var(--spacing-sm);
}

.company-name-display {
    text-align: center;
}

.company-name-display span {
    font-size: 1.125rem;
    font-weight: 600;
    color: white;
}

.company-id-display {
    font-size: 0.75rem;
    opacity: 0.8;
}

.refresh-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-right: var(--spacing-lg);
}

/* Pure CSS Buttons */
.pure-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
    user-select: none;
    white-space: nowrap;
}

.pure-btn:focus {
    outline: 2px solid var(--info-blue);
    outline-offset: 2px;
}

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

/* Button Variants */
.pure-btn-primary {
    background-color: var(--primary-gray);
    border-color: var(--primary-gray);
    color: white;
}

.pure-btn-primary:hover:not(:disabled) {
    background-color: var(--dark-gray);
    border-color: var(--dark-gray);
    color: white;
    text-decoration: none;
}

.pure-btn-secondary {
    background-color: var(--medium-gray);
    border-color: var(--medium-gray);
    color: white;
}

.pure-btn-secondary:hover:not(:disabled) {
    background-color: var(--primary-gray);
    border-color: var(--primary-gray);
    color: white;
    text-decoration: none;
}

.pure-btn-link {
    background-color: transparent;
    border-color: transparent;
    color: var(--info-blue);
    text-decoration: none;
}

.pure-btn-link:hover:not(:disabled) {
    color: var(--primary-gray);
    text-decoration: underline;
}

.pure-btn-link.pure-text-light {
    color: white;
}

.pure-btn-link.pure-text-light:hover:not(:disabled) {
    color: #e5e7eb;
}

/* Pure CSS Form Controls */
.pure-form-control {
    display: block;
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-gray);
    background-color: white;
    background-clip: padding-box;
    border: 1px solid var(--border-gray);
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.pure-form-control:focus {
    border-color: var(--primary-gray);
    outline: 0;
    box-shadow: 0 0 0 2px rgba(75, 85, 99, 0.25);
}

.pure-form-control::placeholder {
    color: var(--accent-gray);
    opacity: 1;
}

.pure-form-control:disabled {
    background-color: var(--light-gray);
    opacity: 1;
}

/* Pure CSS Cards */
.pure-card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    word-wrap: break-word;
    background-color: white;
    background-clip: border-box;
    border: 1px solid var(--border-gray);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: var(--transition-normal);
}

.pure-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.pure-card-header {
    padding: var(--spacing-lg) var(--spacing-xl);
    margin-bottom: 0;
    background-color: var(--light-gray);
    border-bottom: 1px solid var(--border-gray);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.pure-card-header h6 {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--dark-gray);
}

.pure-card-body {
    flex: 1 1 auto;
    padding: var(--spacing-xl);
}

/* Metric Cards - Modern Minimalist Design */
.metric-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 2rem 1.5rem;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02), 0 1px 6px rgba(0, 0, 0, 0.03);
    transition: all 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
    border-top: 3px solid #f8fafc;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6 0%, #1d4ed8 50%, #1e40af 100%);
}

.metric-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.05);
    transform: translateY(-2px);
}

/* Compact Metric Cards for better space efficiency */
.metric-card-compact {
    padding: 1.5rem 1.25rem;
    border-radius: 10px;
    min-height: 120px;
    border-top: 2px solid #f1f5f9;
}

.metric-card-compact::before {
    height: 2px;
    background: linear-gradient(90deg, #6366f1 0%, #4f46e5 50%, #4338ca 100%);
}

.metric-card-compact:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1), 0 3px 10px rgba(0, 0, 0, 0.06);
    transform: translateY(-3px);
}

/* Mini Metric Cards for ultra-compact 8-card layout */
.metric-card-mini {
    padding: 1rem 0.75rem;
    min-height: 100px;
    border-radius: 8px;
}

/* Custom 8-column grid for metric cards */
@media (min-width: 1400px) {
    .pure-col-xl-15 {
        flex: 0 0 12.5%;
        max-width: 12.5%;
    }
}

@media (max-width: 1399px) and (min-width: 1200px) {
    .pure-col-xl-15 {
        flex: 0 0 25%;
        max-width: 25%;
    }
}

@media (max-width: 1199px) and (min-width: 992px) {
    .pure-col-xl-15 {
        flex: 0 0 25%;
        max-width: 25%;
    }
}

.metric-card-mini .metric-title {
    font-size: 0.65rem;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.metric-card-mini .metric-value {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
    font-weight: 700;
}

.metric-card-mini .metric-description {
    font-size: 0.6rem;
    line-height: 1.1;
    opacity: 0.9;
}

.metric-card-compact .metric-title {
    font-size: 0.75rem;
    margin-bottom: 0.75rem;
    line-height: 1.3;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-card-compact .metric-value {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    line-height: 1;
    font-weight: 800;
}

.metric-card-compact .metric-description {
    font-size: 0.7rem;
    line-height: 1.2;
    opacity: 0.8;
    font-weight: 500;
}

/* Remove colored variants - keep it clean */
.metric-card-max,
.metric-card-mean {
    border: 1px solid #e2e8f0;
    background: white;
}

.metric-card-max:hover,
.metric-card-mean:hover {
    border-color: #cbd5e1;
    background: white;
}

.metric-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    line-height: 1.4;
}

.metric-card-max .metric-title,
.metric-card-mean .metric-title {
    color: #475569;
}

.metric-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: #1e293b;
    margin-bottom: 0.75rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1;
}

.metric-card-max .metric-value,
.metric-card-mean .metric-value {
    color: #1e293b;
}

.metric-description {
    font-size: 0.75rem;
    color: #64748b;
    margin: 0;
    line-height: 1.3;
    font-weight: 500;
    opacity: 0.9;
}

/* Chart Containers */
.chart-container {
    position: relative;
    width: 100%;
    min-height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* FRESH GRID SYSTEMS FOR KEY METRICS - FORCE 2 ROWS */
/* 6-Column Grid for System & Alarm Metrics (Row 1) */
.key-metrics-six-column-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
    width: 100%;
    min-height: 140px;
}

.metric-card-column {
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevent overflow */
    width: 100%;
}

.metric-card-column .metric-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* 8-Column Grid for Unit-based Metrics (Row 2) */
.key-metrics-eight-column-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 1rem;
    width: 100%;
    min-height: 120px;
}

.unit-metric-card-column {
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevent overflow */
    width: 100%;
}

/* Unit-based Metrics (Row 2) - SUBTLE DESIGN */
.unit-metric-card-column .metric-card {
    height: 84px; /* Reduced by 30% from standard 120px */
    display: flex;
    flex-direction: column;
    justify-content: center;
    
    /* DIFFERENT STYLE for second row - more subtle */
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-radius: 8px; /* Smaller radius */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); /* Lighter shadow */
    padding: 0.5rem; /* Reduced padding to maintain proportions */
    transition: all 0.2s ease;
    border-top: 2px solid #94a3b8; /* Subtle gray top border */
}

.unit-metric-card-column .metric-card:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
    border-top-color: #64748b;
}

/* Different typography for unit metrics */
.unit-metric-card-column .metric-title {
    font-size: 0.75rem; /* Smaller font */
    font-weight: 500; /* Less bold */
    color: #64748b; /* More muted color */
    margin-bottom: 0.25rem;
    line-height: 1.2;
}

.unit-metric-card-column .metric-value {
    font-size: 1.25rem; /* Smaller value */
    font-weight: 600; /* Less bold */
    color: #475569; /* More muted color */
    margin-bottom: 0.25rem;
}

.unit-metric-card-column .metric-description {
    font-size: 0.7rem; /* Smaller description */
    color: #94a3b8; /* More muted color */
    font-weight: 400;
}

/* Responsive behavior for Key Metrics grids */
@media (max-width: 1400px) {
    .key-metrics-six-column-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.75rem;
    }
    
    .key-metrics-eight-column-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.75rem;
    }
}

@media (max-width: 992px) {
    .key-metrics-six-column-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .key-metrics-eight-column-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
}

@media (max-width: 768px) {
    .key-metrics-six-column-grid,
    .key-metrics-eight-column-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
}

/* Large screen optimization for Key Metrics */
@media (min-width: 1600px) {
    .key-metrics-six-column-grid,
    .key-metrics-eight-column-grid {
        gap: 1.5rem;
    }
}

/* FRESH 4-COLUMN GRID FOR STATUS OVERVIEW */
.status-overview-four-column-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    width: 100%;
    min-height: 320px;
}

.status-chart-column {
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevent overflow */
    width: 100%;
}

.status-chart-column .pure-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.status-chart-column .pure-card-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-chart-column .chart-container {
    width: 100%;
    height: 280px;
    min-height: 280px;
    max-height: 320px;
}

/* Responsive behavior for 4-column grid */
@media (max-width: 1200px) {
    .status-overview-four-column-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
}

@media (max-width: 768px) {
    .status-overview-four-column-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .status-chart-column .chart-container {
        height: 250px;
        min-height: 250px;
    }
}

/* Ensure grid doesn't break on very large screens */
@media (min-width: 1400px) {
    .status-overview-four-column-grid {
        gap: 1.5rem;
    }
    
    .status-chart-column .chart-container {
        height: 320px;
        min-height: 320px;
        max-height: 360px;
    }
}

/* FRESH 3-COLUMN GRID FOR ALARMS ANALYSIS */
.alarms-analysis-three-column-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    width: 100%;
    min-height: 300px;
}

.alarm-chart-column {
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevent overflow */
    width: 100%;
}

.alarm-chart-column .pure-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.alarm-chart-column .pure-card-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.alarm-chart-column .chart-container {
    width: 100%;
    height: 260px;
    min-height: 260px;
    max-height: 300px;
}

/* Responsive behavior for 3-column alarms grid */
@media (max-width: 1200px) {
    .alarms-analysis-three-column-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
}

@media (max-width: 768px) {
    .alarms-analysis-three-column-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .alarm-chart-column .chart-container {
        height: 240px;
        min-height: 240px;
    }
}

/* Large screen optimization for alarms */
@media (min-width: 1400px) {
    .alarms-analysis-three-column-grid {
        gap: 1.5rem;
    }
    
    .alarm-chart-column .chart-container {
        height: 280px;
        min-height: 280px;
        max-height: 320px;
    }
}

/* Loading States */
.loading-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-content {
    text-align: center;
    padding: var(--spacing-2xl);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--light-gray);
    border-top: 3px solid var(--primary-gray);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto var(--spacing-lg);
}

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

/* Utility Classes Override */
.pure-text-light {
    color: #f9fafb !important;
}

.pure-text-white {
    color: #ffffff !important;
}

/* Focus States */
.pure-btn:focus,
.pure-form-control:focus {
    box-shadow: 0 0 0 2px rgba(75, 85, 99, 0.25);
}

/* Print Styles */
@media print {
    .pure-navbar,
    .loading-container {
        display: none !important;
    }
    
    .dashboard-section {
        box-shadow: none;
        border: 1px solid var(--border-gray);
        break-inside: avoid;
    }
} 

/* Responsive Design - Essential Rules Only */
@media (max-width: 768px) {
    .pure-container-fluid {
        padding: 0 var(--spacing-md);
    }
    
    .dashboard-section {
        margin: var(--spacing-lg) 0;
        padding: var(--spacing-lg);
    }
    
    .pure-navbar .pure-container-fluid {
        padding: var(--spacing-md);
    }
    
    .navbar-center {
        display: none;
    }
    
    .metric-value {
        font-size: 1.5rem;
    }
    
    .section-title {
        font-size: 1.125rem;
    }
}

@media (max-width: 576px) {
    .metric-card {
        padding: var(--spacing-lg);
    }
    
    .pure-card-header,
    .pure-card-body {
        padding: var(--spacing-lg);
    }
}

/* Responsive adjustments */
@media (max-width: 991px) {
    .metric-card {
        padding: 1.5rem 1rem;
    }
    
    .metric-value {
        font-size: 1.875rem;
    }
}

@media (max-width: 767px) {
    .metric-card {
        padding: 1.25rem 0.875rem;
        margin-bottom: 1rem;
    }
    
    .metric-value {
        font-size: 1.625rem;
    }
    
    .metric-title {
        font-size: 0.7rem;
    }
} 