/* EMS - Energy Management System Styles */

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #06b6d4;
    
    --sidebar-bg: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    
    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
}

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

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--body-bg);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--body-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-primary);
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    z-index: 1000;
    transition: var(--transition-normal);
    overflow-x: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    font-size: 24px;
    font-weight: 700;
}

.logo i {
    font-size: 32px;
    color: var(--warning-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.sidebar.collapsed .logo span {
    display: none;
}

.sidebar-nav {
    padding: 20px 0;
    height: calc(100vh - 80px);
    overflow-y: auto;
}

.sidebar-nav .nav-item {
    margin: 2px 10px;
}

.sidebar-nav .nav-section {
    padding: 15px 20px 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
}

.sidebar.collapsed .nav-section {
    display: none;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: rgba(255, 255, 255, 0.7);
    border-radius: 8px;
    transition: var(--transition-fast);
    text-decoration: none;
}

.sidebar-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.sidebar-nav .nav-link i {
    font-size: 20px;
    width: 24px;
    text-align: center;
}

.sidebar.collapsed .nav-link span {
    display: none;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: var(--transition-normal);
}

.sidebar.collapsed + .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* Top Navbar */
.top-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.sidebar-toggle {
    font-size: 24px;
    color: var(--text-secondary);
    padding: 5px 10px;
}

.sidebar-toggle:hover {
    color: var(--primary-color);
}

.breadcrumb {
    background: none;
    margin-bottom: 0;
    font-size: 13px;
}

.breadcrumb-item a {
    color: var(--primary-color);
    text-decoration: none;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.datetime-display {
    color: var(--text-secondary);
    font-size: 13px;
}

.datetime-display i {
    margin-right: 5px;
}

.user-dropdown {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    text-decoration: none;
}

.user-avatar i {
    font-size: 28px;
    color: var(--primary-color);
}

.user-name {
    font-weight: 500;
}

/* Content Wrapper */
.content-wrapper {
    padding: 25px;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.page-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 5px;
}

/* Cards */
.card {
    background: var(--card-bg);
    border: none;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    transition: var(--transition-normal);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 15px 20px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* Stats Cards */
.stats-card {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    padding: 20px;
    color: #fff;
    min-height: 140px;
}

.stats-card.primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
}

.stats-card.success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.stats-card.warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.stats-card.danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.stats-card.info {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
}

.stats-card.purple {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

.stats-card .stats-icon {
    position: absolute;
    right: 15px;
    top: 15px;
    font-size: 48px;
    opacity: 0.3;
}

.stats-card .stats-label {
    font-size: 13px;
    opacity: 0.9;
    margin-bottom: 5px;
}

.stats-card .stats-value {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 5px;
}

.stats-card .stats-change {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.stats-card .stats-change.up {
    color: rgba(255, 255, 255, 0.9);
}

.stats-card .stats-change.down {
    color: rgba(255, 255, 255, 0.9);
}

/* Meter Cards */
.meter-card {
    transition: var(--transition-normal);
    cursor: pointer;
}

.meter-card:hover {
    transform: translateY(-5px);
}

.meter-card .meter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.meter-card .meter-name {
    font-weight: 600;
    font-size: 16px;
}

.meter-card .meter-id {
    color: var(--text-muted);
    font-size: 12px;
}

.meter-card .meter-location {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 15px;
}

.meter-card .meter-location i {
    margin-right: 5px;
}

.meter-card .meter-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.meter-card .stat-item {
    text-align: center;
    padding: 10px;
    background: var(--body-bg);
    border-radius: 8px;
}

.meter-card .stat-item .stat-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
}

.meter-card .stat-item .stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: var(--body-bg);
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
}

.data-table td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: rgba(37, 99, 235, 0.05);
}

.data-table .table-actions {
    display: flex;
    gap: 8px;
}

.data-table .table-actions .btn {
    padding: 5px 10px;
    font-size: 13px;
}

/* Live Data Display */
.live-value {
    font-family: 'Poppins', monospace;
    font-size: 24px;
    font-weight: 600;
}

.live-value.voltage {
    color: var(--warning-color);
}

.live-value.current {
    color: var(--info-color);
}

.live-value.power {
    color: var(--success-color);
}

.live-value.pf {
    color: var(--purple-color);
}

.phase-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    margin-right: 8px;
}

.phase-r { background: #ef4444; }
.phase-y { background: #eab308; }
.phase-b { background: #3b82f6; }

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

.chart-container.small {
    height: 200px;
}

.chart-container.large {
    height: 400px;
}

/* Gauge */
.gauge-container {
    position: relative;
    width: 150px;
    height: 150px;
    margin: 0 auto;
}

/* Forms */
.form-control, .form-select {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 15px;
    font-size: 14px;
    transition: var(--transition-fast);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-label {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* Buttons */
.btn {
    font-weight: 500;
    padding: 10px 20px;
    border-radius: 8px;
    transition: var(--transition-fast);
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

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

.btn-light {
    background: var(--body-bg);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.btn-light:hover {
    background: #e2e8f0;
}

/* Badges */
.badge {
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 6px;
}

/* Alerts */
.alert {
    border: none;
    border-radius: 10px;
    padding: 15px 20px;
}

/* Modal */
.modal-content {
    border: none;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 20px;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 15px 20px;
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    padding: 20px;
}

.login-card {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: #fff;
    padding: 30px;
    text-align: center;
}

.login-header .logo {
    justify-content: center;
    margin-bottom: 10px;
}

.login-header h1 {
    font-size: 24px;
    margin-bottom: 5px;
}

.login-header p {
    opacity: 0.9;
    font-size: 14px;
}

.login-body {
    padding: 30px;
}

.login-body .form-control {
    padding: 12px 15px;
}

.login-body .btn-primary {
    width: 100%;
    padding: 12px;
    font-size: 16px;
}

/* Group Cards */
.group-card {
    border-left: 4px solid var(--primary-color);
}

.group-card .group-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
}

/* Filter Section */
.filter-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.filter-section .row {
    align-items: end;
}

/* Responsive */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
}

@media (max-width: 767px) {
    .stats-card .stats-value {
        font-size: 22px;
    }
    
    .page-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .content-wrapper {
        padding: 15px;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

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

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Custom Scrollbar for Tables */
.table-responsive::-webkit-scrollbar {
    height: 6px;
}

.table-responsive::-webkit-scrollbar-track {
    background: var(--body-bg);
}

.table-responsive::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 3px;
}

/* Tooltip */
.tooltip-inner {
    background: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
}

/* Print Styles */
@media print {
    .sidebar, .top-navbar, .btn, .filter-section {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}

