/* FOL Pipeline Dashboard - Main Styles */
/* Design inspired by ESP32 UI */

:root {
    --primary: #0066cc;
    --primary-dark: #004d99;
    --primary-light: #3399ff;
    --success: #00cc66;
    --warning: #ffaa00;
    --danger: #dc3545;
    --bg-primary: #f8faff;
    --bg-secondary: #ffffff;
    --text-primary: #1a2639;
    --text-secondary: #5a6b8c;
    --border-color: rgba(0,0,0,0.05);
    --shadow: 0 20px 40px -15px rgba(0,50,100,0.1);
    --shadow-hover: 0 30px 60px -20px rgba(0,102,204,0.3);
}

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

body {
    font-family: 'Space Grotesk', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 30%, rgba(0,100,200,0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(50,100,255,0.02) 0%, transparent 50%),
        radial-gradient(circle at 40% 80%, rgba(0,150,255,0.02) 0%, transparent 50%);
    z-index: -1;
    pointer-events: none;
}

/* Dashboard Container */
.dashboard {
    max-width: 1800px;
    margin: 0 auto;
    padding: 24px;
}

/* Navigation */
.nav-menu {
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(10px);
    border-radius: 60px;
    padding: 8px;
    margin-bottom: 32px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
    box-shadow: 0 10px 30px -10px rgba(0,0,0,0.1);
    border: 1px solid var(--border-color);
    position: sticky;
    top: 20px;
    z-index: 100;
}

.nav-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 50px;
    font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.3s;
    white-space: nowrap;
}

.nav-item i {
    color: var(--primary);
    font-size: 1.2rem;
    transition: transform 0.3s;
}

.nav-item:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(0,102,204,0.3);
}

.nav-item:hover i {
    color: white;
    transform: rotate(10deg);
}

.nav-item.active {
    background: var(--primary);
    color: white;
}

.nav-item.active i {
    color: white;
}

/* Header */
.header {
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(20px);
    border-radius: 40px;
    padding: 20px 32px;
    margin-bottom: 32px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    animation: slideDown 0.8s cubic-bezier(0.2,0.9,0.3,1.2);
}

@keyframes slideDown {
    0% { opacity: 0; transform: translateY(-50px); }
    100% { opacity: 1; transform: translateY(0); }
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 20px;
}

.device-logo {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.location-badge {
    background: linear-gradient(145deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 8px 20px;
    border-radius: 50px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 10px 20px -5px rgba(0,102,204,0.3);
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: white;
    border-radius: 30px;
    padding: 24px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    transition: all 0.3s;
    animation: fadeInUp 0.6s backwards;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

@keyframes fadeInUp {
    0% { opacity: 0; transform: translateY(30px); }
    100% { opacity: 1; transform: translateY(0); }
}

.stat-card .icon {
    width: 50px;
    height: 50px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 15px;
}

.stat-card .icon.primary {
    background: linear-gradient(145deg, #e6f0ff, #d9e8ff);
    color: var(--primary);
}

.stat-card .icon.success {
    background: linear-gradient(145deg, #e6fff0, #d9ffe8);
    color: var(--success);
}

.stat-card .icon.warning {
    background: linear-gradient(145deg, #fff5e6, #ffeed9);
    color: var(--warning);
}

.stat-card .icon.danger {
    background: linear-gradient(145deg, #ffe6e6, #ffd9d9);
    color: var(--danger);
}

.stat-card .value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.stat-card .label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* Cards */
.card {
    background: white;
    border-radius: 30px;
    padding: 24px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    transition: all 0.4s cubic-bezier(0.2,0.9,0.3,1.2);
    animation: fadeInUp 0.8s backwards;
    position: relative;
    overflow: hidden;
}

.card::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.7s;
    pointer-events: none;
}

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

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

.card-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.card-header i {
    font-size: 2rem;
    background: linear-gradient(145deg, #f0f5ff, #e6f0ff);
    padding: 12px;
    border-radius: 20px;
    color: var(--primary);
}

.card-header h3 {
    font-size: 1.3rem;
    font-weight: 600;
}

/* Grid Layout */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

@media (max-width: 1200px) {
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* Map Container */
.map-container {
    background: white;
    border-radius: 30px;
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.map-frame {
    width: 100%;
    height: 500px;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid rgba(0,102,204,0.2);
}

#map {
    width: 100%;
    height: 100%;
}

/* Nodes Table */
.nodes-table {
    width: 100%;
    border-collapse: collapse;
}

.nodes-table th {
    text-align: left;
    padding: 15px;
    background: #f0f5ff;
    color: var(--text-primary);
    font-weight: 600;
    border-radius: 10px;
}

.nodes-table td {
    padding: 15px;
    border-bottom: 1px solid #eef2f7;
}

.nodes-table tr:hover {
    background: #f8faff;
}

/* Status Badges */
.badge {
    padding: 6px 14px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.badge.online {
    background: #e6fff0;
    color: var(--success);
}

.badge.offline {
    background: #ffe6e6;
    color: var(--danger);
}

.badge.warning {
    background: #fff5e6;
    color: var(--warning);
}

.badge.primary {
    background: #e6f0ff;
    color: var(--primary);
}

/* Pulse Animation */
.pulse-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    background: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 15px var(--success);
    animation: pulse 2s infinite;
}

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

/* Progress Bar */
.progress-container {
    background: #eef2f7;
    border-radius: 40px;
    height: 12px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 40px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    transition: width 0.5s ease;
}

/* Buttons */
.btn {
    padding: 10px 24px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(145deg, var(--primary), var(--primary-dark));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(0,102,204,0.4);
}

.btn-outline {
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: white;
}

.btn-danger {
    background: linear-gradient(145deg, var(--danger), #c82333);
    color: white;
}

.btn-success {
    background: linear-gradient(145deg, var(--success), #00aa55);
    color: white;
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Incidents List */
.incident-item {
    background: #f8faff;
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 15px;
    border-left: 4px solid var(--warning);
    transition: all 0.3s;
}

.incident-item:hover {
    transform: translateX(5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

.incident-item.critical {
    border-left-color: var(--danger);
}

.incident-item.resolved {
    border-left-color: var(--success);
    opacity: 0.7;
}

/* Clock Display */
.clock-card {
    background: linear-gradient(125deg, #ffffff, #f0f7ff);
    border-radius: 40px;
    padding: 30px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.clock-time {
    font-size: 4rem;
    font-weight: 800;
    font-family: 'Space Grotesk', monospace;
    letter-spacing: 6px;
    color: var(--primary);
    text-shadow: 0 0 20px rgba(0,102,204,0.2);
}

.clock-day {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Connection Status */
.connection-status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 10px 20px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 1000;
    transition: all 0.3s;
}

.connection-status.connected {
    background: var(--success);
    color: white;
}

.connection-status.disconnected {
    background: var(--danger);
    color: white;
}

/* Footer */
.footer {
    text-align: center;
    padding: 30px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
    margin-top: 40px;
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard {
        padding: 12px;
    }
    
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .clock-time {
        font-size: 2.5rem;
        letter-spacing: 3px;
    }
    
    .stat-card .value {
        font-size: 2rem;
    }
    
    .nav-menu {
        position: relative;
        top: 0;
    }
}

/* Loading Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

/* Toast Notifications */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: 15px;
    background: white;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    z-index: 10000;
    animation: slideInRight 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

@keyframes slideInRight {
    0% { transform: translateX(100%); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info { border-left: 4px solid var(--primary); }
