:root {
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --accent-color: #27ae60;
    --danger-color: #c0392b;
    --warning-color: #f39c12;
    --text-color: #333;
    --bg-color: #ecf0f1;
    --white: #ffffff;
    --sidebar-width: 250px;
    --header-height: 60px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, rgba(44, 62, 80, 0.95) 0%, rgba(52, 73, 94, 0.95) 100%),
                url('https://images.unsplash.com/photo-1590856029826-c7a73142bbf1?w=1920&q=80') no-repeat center center fixed;
    background-size: cover;
    color: var(--text-color);
    display: flex;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* Animated Gradient Overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, 
        rgba(39, 174, 96, 0.1) 0%, 
        rgba(52, 152, 219, 0.1) 25%,
        rgba(155, 89, 182, 0.1) 50%,
        rgba(52, 152, 219, 0.1) 75%,
        rgba(39, 174, 96, 0.1) 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, rgba(44, 62, 80, 0.98) 0%, rgba(52, 73, 94, 0.98) 100%);
    backdrop-filter: blur(10px);
    color: var(--white);
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 10;
}

.brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    background: linear-gradient(135deg, rgba(52, 73, 94, 0.95) 0%, rgba(44, 62, 80, 0.95) 100%);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    position: relative;
    overflow: hidden;
}

.brand::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(39, 174, 96, 0.1) 0%, transparent 70%);
    animation: brandPulse 3s ease-in-out infinite;
}

@keyframes brandPulse {
    0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.5; }
    50% { transform: translate(10%, 10%) scale(1.1); opacity: 0.8; }
}

.brand i {
    animation: iconBounce 2s ease-in-out infinite;
    display: inline-block;
}

@keyframes iconBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.nav-links {
    list-style: none;
    flex: 1;
    padding-top: 20px;
}

.nav-links li {
    padding: 10px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
    position: relative;
}

.nav-links li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background: linear-gradient(90deg, rgba(39, 174, 96, 0.3) 0%, transparent 100%);
    transition: width 0.3s ease;
}

.nav-links li:hover::before, .nav-links li.active::before {
    width: 100%;
}

.nav-links li:hover, .nav-links li.active {
    background-color: rgba(52, 73, 94, 0.8);
    border-left-color: var(--accent-color);
}

.nav-links li i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 10;
}

.header {
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: 0 2px 15px rgba(0,0,0,0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent 30%, rgba(52, 152, 219, 0.05) 50%, transparent 70%);
    animation: headerShine 3s linear infinite;
}

@keyframes headerShine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    z-index: 1;
}

.content-area {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: linear-gradient(135deg, rgba(236, 240, 241, 0.7) 0%, rgba(189, 195, 199, 0.5) 100%);
    position: relative;
}

/* Floating Particles Animation */
.content-area::before,
.content-area::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    animation: float 20s ease-in-out infinite;
    pointer-events: none;
}

.content-area::before {
    width: 300px;
    height: 300px;
    top: 10%;
    left: 5%;
    animation-delay: 0s;
}

.content-area::after {
    width: 200px;
    height: 200px;
    bottom: 10%;
    right: 10%;
    animation-delay: 5s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.3; }
    33% { transform: translate(30px, -30px) scale(1.1); opacity: 0.5; }
    66% { transform: translate(-20px, 20px) scale(0.9); opacity: 0.4; }
}

/* Dashboard Widgets */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 20px;
    position: relative;
    z-index: 1;
}

.card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    animation: cardSlideIn 0.6s ease-out backwards;
}

.card:nth-child(1) { animation-delay: 0.1s; }
.card:nth-child(2) { animation-delay: 0.2s; }
.card:nth-child(3) { animation-delay: 0.3s; }
.card:nth-child(4) { animation-delay: 0.4s; }

@keyframes cardSlideIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.card:hover::before {
    left: 100%;
}

.card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
    border-color: rgba(39, 174, 96, 0.3);
}

.stat-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, rgba(39, 174, 96, 0.15) 0%, transparent 70%);
    border-radius: 50%;
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 0.8; }
}

.stat-info h3 {
    font-size: 0.9rem;
    color: #7f8c8d;
    margin-bottom: 5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    z-index: 1;
}

.stat-info p {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--primary-color);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    position: relative;
    z-index: 1;
    animation: countUp 1s ease-out;
}

@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stat-icon {
    font-size: 2.5rem;
    color: var(--accent-color);
    opacity: 0.2;
    position: relative;
    z-index: 1;
    animation: iconFloat 3s ease-in-out infinite;
}

@keyframes iconFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-10px) rotate(5deg); }
}

.chart-container-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.chart-card {
    min-height: 300px;
}

.chart-header {
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    font-weight: bold;
    color: var(--primary-color);
}

/* Tables */
.table-container {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.table-container th, .table-container td {
    border: 1px solid #eee;
    padding: 12px;
    text-align: left;
}

.table-container th {
    background-color: #f8f9fa;
    color: var(--primary-color);
}

.status-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    color: white;
}

.status-normal { background-color: var(--accent-color); }
.status-warning { background-color: var(--warning-color); }
.status-danger { background-color: var(--danger-color); }

/* Views */
.view-section {
    display: none;
}
.view-section.active {
    display: block;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Forms */
.form-group {
    margin-bottom: 15px;
}
.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}
.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.9);
    position: relative;
}

.form-control:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
    background: rgba(255, 255, 255, 1);
    transform: translateY(-2px);
}

.form-control:hover {
    border-color: #95a5a6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}
.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 10000;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    body {
        flex-direction: column;
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 70%;
        max-width: 280px;
        height: 100vh;
        z-index: 9999;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .main-content {
        width: 100%;
        margin-left: 0;
    }
    
    .header {
        padding-left: 60px;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .chart-container-row {
        grid-template-columns: 1fr;
    }
    
    .table-container {
        font-size: 0.85rem;
    }
    
    .table-container th, .table-container td {
        padding: 8px 6px;
    }
    
    .modal-box {
        width: 95% !important;
        max-width: 95% !important;
        padding: 20px;
    }
    
    .stat-info p {
        font-size: 1.4rem;
    }
    
    .stat-icon {
        font-size: 2rem;
    }
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 9998;
}

.sidebar-overlay.active {
    display: block;
}

/* Dashboard Card Background Images */
.dashboard-grid .card {
    position: relative;
    overflow: hidden;
}

.dashboard-grid .card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 50%;
    background-size: cover;
    background-position: center;
    opacity: 0.25;
    z-index: 0;
    filter: brightness(1.1) contrast(1.1);
}

.dashboard-grid .card:nth-child(1)::after {
    background-image: url('https://images.unsplash.com/photo-1581094794329-c8112a89af12?w=500&q=90');
}

.dashboard-grid .card:nth-child(2)::after {
    background-image: url('https://images.unsplash.com/photo-1504917595217-d4dc5ebe6122?w=500&q=90');
}

.dashboard-grid .card:nth-child(3)::after {
    background-image: url('https://images.unsplash.com/photo-1541888946425-d81bb19240f5?w=500&q=90');
}

.stat-info, .stat-icon {
    position: relative;
    z-index: 1;
}

/* Brand with icon styling */
.brand {
    background: linear-gradient(135deg, rgba(52, 73, 94, 0.95) 0%, rgba(44, 62, 80, 0.95) 100%);
}

/* Button styling enhancements */
.btn {
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

/* Table enhancements */
.table-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.table-container th {
    background: linear-gradient(135deg, rgba(52, 73, 94, 0.1) 0%, rgba(44, 62, 80, 0.05) 100%);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.table-container tr:hover {
    background-color: rgba(52, 152, 219, 0.05);
}

/* Modal enhancements */
.modal-box {
    animation: modalSlideIn 0.3s ease-out;
    position: relative;
}

.modal-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #27ae60 0%, #3498db 50%, #9b59b6 100%);
    background-size: 200% 100%;
    animation: gradientMove 3s linear infinite;
}

@keyframes gradientMove {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

.modal-overlay {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Chart card with subtle background */
.chart-card {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    animation: cardSlideIn 0.8s ease-out 0.5s backwards;
}

/* Safety Index visualization */
#safety-index-container {
    background: linear-gradient(135deg, rgba(39, 174, 96, 0.05) 0%, rgba(46, 204, 113, 0.02) 100%) !important;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

#safety-index-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(39, 174, 96, 0.1) 0%, transparent 50%);
    animation: rotate 10s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Custom Scrollbar */
.content-area::-webkit-scrollbar {
    width: 10px;
}

.content-area::-webkit-scrollbar-track {
    background: rgba(236, 240, 241, 0.3);
    border-radius: 10px;
}

.content-area::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(39, 174, 96, 0.6) 0%, rgba(52, 152, 219, 0.6) 100%);
    border-radius: 10px;
    transition: background 0.3s;
}

.content-area::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(39, 174, 96, 0.8) 0%, rgba(52, 152, 219, 0.8) 100%);
}

/* Status Badge Animations */
.status-badge, .badge {
    animation: badgePop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}

.status-badge::before, .badge::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.status-badge:hover::before, .badge:hover::before {
    width: 200%;
    height: 200%;
}

@keyframes badgePop {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

/* Loading Spinner for dynamic content */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-spinner {
    border: 3px solid rgba(39, 174, 96, 0.2);
    border-top-color: #27ae60;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

/* Ripple Effect for buttons */
.btn {
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::after {
    width: 300px;
    height: 300px;
}

/* Table row slide in effect */
.table-container tbody tr {
    animation: rowSlideIn 0.5s ease-out backwards;
}

.table-container tbody tr:nth-child(1) { animation-delay: 0.05s; }
.table-container tbody tr:nth-child(2) { animation-delay: 0.1s; }
.table-container tbody tr:nth-child(3) { animation-delay: 0.15s; }
.table-container tbody tr:nth-child(4) { animation-delay: 0.2s; }
.table-container tbody tr:nth-child(5) { animation-delay: 0.25s; }

@keyframes rowSlideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}
