/**
 * ChatterFix CMMS - Enhanced UI Components
 * Modern, responsive design system with dark mode support
 */

/* === ENHANCED THEME VARIABLES === */
:root {
    /* Light theme (default) */
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --accent-gradient: linear-gradient(45deg, #11998e, #38ef7d);
    --danger-gradient: linear-gradient(45deg, #ff6b6b, #ee5a52);
    --warning-gradient: linear-gradient(45deg, #feca57, #ff9ff3);
    
    /* Enhanced shadows */
    --shadow-minimal: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-soft: 0 4px 6px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-strong: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-intense: 0 25px 50px rgba(0, 0, 0, 0.15), 0 10px 20px rgba(0, 0, 0, 0.08);
    
    /* Glass morphism */
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.18);
    --glass-backdrop: blur(20px);
    
    /* Animation curves */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out-circ: cubic-bezier(0.85, 0, 0.15, 1);
    --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    
    /* Component spacing */
    --component-gap: 24px;
    --section-gap: 48px;
    --grid-gap: 20px;
}

/* Dark theme overrides */
[data-theme="dark"] {
    --text-primary: #e2e8f0;
    --text-secondary: #a0aec0;
    --text-tertiary: #718096;
    --text-inverse: #1a202c;
    
    --background: #1a202c;
    --background-dark: #2d3748;
    --surface: #2d3748;
    --surface-hover: #4a5568;
    --border: #4a5568;
    --border-light: #2d3748;
    
    --glass-bg: rgba(45, 55, 72, 0.85);
    --glass-border: rgba(255, 255, 255, 0.1);
    
    --shadow-minimal: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-soft: 0 4px 6px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-strong: 0 10px 15px rgba(0, 0, 0, 0.4), 0 4px 6px rgba(0, 0, 0, 0.2);
}

/* === ENHANCED NAVBAR === */
.navbar {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-backdrop);
    border-bottom: 1px solid var(--glass-border);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-soft);
}

.navbar-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    height: 64px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
    text-decoration: none;
    color: var(--text-primary);
}

.brand-icon {
    font-size: 28px;
    background: var(--primary-gradient);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-version {
    font-size: 12px;
    padding: 2px 8px;
    background: var(--accent-gradient);
    color: white;
    border-radius: 12px;
    font-weight: 600;
}

.navbar-nav {
    display: flex;
    gap: 8px;
    align-items: center;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-secondary);
    border-radius: 12px;
    font-weight: 500;
    font-size: 14px;
    transition: all var(--transition-normal);
    position: relative;
}

.nav-link:hover {
    color: var(--primary);
    background: rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

.nav-link.active {
    color: var(--primary);
    background: rgba(102, 126, 234, 0.15);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 16px;
    right: 16px;
    height: 2px;
    background: var(--primary-gradient);
    border-radius: 1px;
}

.nav-icon {
    font-size: 18px;
}

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

.btn-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.btn-icon:hover {
    background: rgba(102, 126, 234, 0.1);
    color: var(--primary);
    transform: scale(1.05);
}

.notification-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--danger-gradient);
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--primary);
    background: var(--primary-gradient);
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-avatar:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* === ENHANCED DASHBOARD === */
.dashboard-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--component-gap);
    display: flex;
    flex-direction: column;
    gap: var(--section-gap);
}

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--component-gap);
}

.dashboard-title {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.dashboard-icon {
    font-size: 36px;
    background: var(--primary-gradient);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.dashboard-actions {
    display: flex;
    gap: 12px;
}

/* === ENHANCED KPI CARDS === */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--grid-gap);
    margin-bottom: var(--section-gap);
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow-soft);
    transition: all var(--transition-normal);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-gradient);
    transform: scaleX(0);
    transition: transform var(--transition-normal);
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-strong);
}

.kpi-card:hover::before {
    transform: scaleX(1);
}

.kpi-icon {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    background: var(--primary-gradient);
    color: white;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-soft);
}

.kpi-content {
    flex: 1;
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.kpi-label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.kpi-trend {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
}

.trend-icon {
    font-size: 16px;
}

.trend-value {
    color: var(--success-dark);
}

/* === DASHBOARD GRID === */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: var(--grid-gap);
}

.dashboard-section {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--shadow-soft);
    transition: all var(--transition-normal);
}

.dashboard-section:hover {
    box-shadow: var(--shadow-strong);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
}

.section-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* === ACTIVITY LIST === */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    border-radius: 12px;
    transition: all var(--transition-fast);
}

.activity-item:hover {
    background: var(--surface-hover);
    transform: translateX(4px);
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(102, 126, 234, 0.1);
    color: var(--primary);
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.activity-content {
    flex: 1;
}

.activity-title {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.2;
    margin-bottom: 2px;
}

.activity-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.activity-time {
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 500;
}

/* === ENHANCED ASSETS LIST === */
.assets-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.asset-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    border-radius: 12px;
    transition: all var(--transition-fast);
}

.asset-item:hover {
    background: var(--surface-hover);
    transform: translateX(4px);
}

.asset-status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.asset-status.critical { background: var(--danger); }
.asset-status.warning { background: var(--warning); }
.asset-status.ok { background: var(--success); }

.asset-content {
    flex: 1;
}

.asset-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.2;
    margin-bottom: 2px;
}

.asset-location {
    font-size: 12px;
    color: var(--text-secondary);
}

.asset-priority {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.priority-high {
    background: rgba(243, 156, 18, 0.1);
    color: var(--warning-dark);
}

.priority-critical {
    background: rgba(231, 76, 60, 0.1);
    color: var(--danger-dark);
}

/* === ENHANCED CHART CONTAINER === */
.chart-container {
    position: relative;
    height: 200px;
    margin-top: 16px;
}

.chart-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.chart-controls select {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
}

#performance-chart {
    width: 100%;
    height: 100%;
    border-radius: 12px;
}

/* === ENHANCED BUTTONS === */
.btn {
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: var(--primary-gradient);
    border: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

/* === ENHANCED MOBILE RESPONSIVENESS === */
@media (max-width: 768px) {
    .navbar-container {
        padding: 8px 16px;
        height: 56px;
    }
    
    .nav-text {
        display: none;
    }
    
    .navbar-nav {
        gap: 4px;
    }
    
    .nav-link {
        padding: 8px;
        border-radius: 8px;
    }
    
    .dashboard-container {
        padding: 16px;
        gap: 24px;
    }
    
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .dashboard-title {
        font-size: 24px;
    }
    
    .kpi-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .kpi-card {
        padding: 20px;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .dashboard-section {
        padding: 20px;
    }
}

/* === LOADING STATES === */
.loading-skeleton {
    background: linear-gradient(90deg, var(--background) 25%, var(--surface-hover) 50%, var(--background) 75%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

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

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

/* === ACCESSIBILITY ENHANCEMENTS === */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast focus indicators */
.btn:focus-visible,
.nav-link:focus-visible,
.btn-icon:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Screen reader improvements */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}