:root {
    --primary: #00c853;
    --primary-dark: #00a043;
    --secondary: #5c6bc0;
    --danger: #f44336;
    --warning: #ff9800;
    --success: #4caf50;
    --info: #2196f3;

    --bg-main: #f5f7fa;
    --bg-white: #ffffff;
    --bg-light: #fafbfc;
    --bg-elevated: #f0f2f5;
    --bg-sidebar: #1a1d29;

    --text-primary: #1a1d29;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --text-white: #ffffff;

    --border-light: #e5e7eb;
    --border-medium: #d1d5db;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
}

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

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

.app-layout {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    color: var(--text-white);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

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

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
}

.sidebar-logo-text {
    font-size: 1.2em;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    padding: 0 20px 8px;
    font-size: 0.7em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.5);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-white);
}

.nav-item.active {
    background: rgba(0, 200, 83, 0.1);
    color: var(--primary);
    border-left-color: var(--primary);
}

.nav-item i {
    width: 20px;
    font-size: 1.1em;
}

.nav-badge {
    margin-left: auto;
    padding: 2px 8px;
    background: var(--danger);
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 700;
}

.logout-btn {
    margin: 12px 20px;
    padding: 12px;
    background: rgba(244, 67, 54, 0.1);
    color: var(--danger);
    border: 1px solid rgba(244, 67, 54, 0.3);
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.9em;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.logout-btn:hover {
    background: rgba(244, 67, 54, 0.2);
    border-color: var(--danger);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

.main-content.expanded {
    margin-left: 0;
}

/* Mobile Toggle */
.mobile-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    z-index: 999;
    font-size: 1.3em;
}

/* Header */
.header {
    background: var(--bg-white);
    padding: 20px 32px;
    border-bottom: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.page-title-section h1 {
    font-size: 1.5em;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.9em;
}

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

.connection-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bg-light);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85em;
}

.pulse-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary);
    animation: pulse 2s ease-in-out infinite;
}

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

/* Content Wrapper */
.content-wrapper {
    flex: 1;
    padding: 24px 32px;
    overflow-y: auto;
}

/* View Sections */
.view-section {
    display: none;
}

.view-section.active {
    display: block;
}

/* Common Styles */
.control-panel {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

label {
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

input, select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.9em;
    transition: all 0.3s;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 200, 83, 0.1);
}

.btn-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-white);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}

.btn-secondary:hover {
    background: var(--bg-light);
}

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

.stat-card {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s;
    box-shadow: var(--shadow-sm);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.stat-icon {
    width: 40px;
    height: 40px;
    background: var(--bg-light);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 1.2em;
}

.stat-label {
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 1.8em;
    font-weight: 700;
    color: var(--text-primary);
}

/* Charts */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.chart-card {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.chart-header {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chart-title {
    font-size: 1.1em;
    font-weight: 700;
}

.chart-container {
    height: 300px;
    position: relative;
}

/* Overstay Table */
.overstay-table-container {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

.overstay-table {
    width: 100%;
    border-collapse: collapse;
}

.overstay-table thead th {
    background: var(--bg-light);
    padding: 12px 16px;
    text-align: left;
    font-size: 0.8em;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-light);
}

.overstay-table tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: background 0.2s;
}

.overstay-table tbody tr:hover {
    background: var(--bg-light);
}

.overstay-table tbody td {
    padding: 16px;
    font-size: 0.9em;
}

.overstay-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
    display: inline-block;
}

.overstay-high {
    background: rgba(244, 67, 54, 0.1);
    color: var(--danger);
}

.overstay-medium {
    background: rgba(255, 152, 0, 0.1);
    color: var(--warning);
}

.overstay-low {
    background: rgba(76, 175, 80, 0.1);
    color: var(--success);
}

/* Station List */
.station-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.station-card {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s;
    box-shadow: var(--shadow-sm);
}

.station-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.station-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
}

.station-icon {
    width: 48px;
    height: 48px;
    background: var(--bg-light);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 1.5em;
}

.station-info h3 {
    font-size: 1.1em;
    font-weight: 700;
    margin-bottom: 4px;
}

.station-status {
    font-size: 0.85em;
    color: var(--text-secondary);
}

.charger-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.charger-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-light);
    border-radius: 8px;
    font-size: 0.9em;
}

.charger-name {
    font-weight: 600;
    color: var(--text-primary);
}

.charger-status {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
}

.charger-status.online {
    background: rgba(76, 175, 80, 0.1);
    color: var(--success);
}

.charger-status.offline {
    background: rgba(158, 158, 158, 0.1);
    color: #9e9e9e;
}

/* Insights Section */
.insights-section {
    margin-bottom: 20px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-title {
    font-size: 1.3em;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-light);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    color: var(--primary);
    font-size: 1.2em;
}

.insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 16px;
}

.insight-card {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s;
    box-shadow: var(--shadow-sm);
}

.insight-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.insight-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.insight-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 1.3em;
}

.insight-icon.warning {
    background: rgba(255, 152, 0, 0.1);
    color: var(--warning);
}

.insight-icon.danger {
    background: rgba(244, 67, 54, 0.1);
    color: var(--danger);
}

.insight-icon.success {
    background: rgba(76, 175, 80, 0.1);
    color: var(--success);
}

.insight-icon.info {
    background: rgba(33, 150, 243, 0.1);
    color: var(--info);
}

.insight-title {
    font-weight: 700;
    font-size: 1.05em;
}

.insight-description {
    color: var(--text-secondary);
    font-size: 0.9em;
    line-height: 1.6;
}

/* Anomaly List */
.anomaly-list, .transaction-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.anomaly-item, .transaction-item {
    background: var(--bg-white);
    border-left: 4px solid var(--danger);
    border-radius: 8px;
    padding: 16px;
    transition: all 0.3s;
    border: 1px solid var(--border-light);
}

.transaction-item {
    border-left-color: var(--primary);
}

.anomaly-item:hover, .transaction-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateX(4px);
}

/* Logs */
.logs-container {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 24px;
    max-height: 600px;
    overflow-y: auto;
    box-shadow: var(--shadow-sm);
}

.log-entry {
    background: var(--bg-light);
    border-left: 3px solid var(--primary);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    font-family: 'Monaco', monospace;
    font-size: 0.85em;
    transition: all 0.3s;
}

.log-entry:hover {
    background: var(--bg-elevated);
    transform: translateX(4px);
}

.log-entry.error {
    border-left-color: var(--danger);
    background: rgba(244, 67, 54, 0.05);
}

.log-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.log-type {
    padding: 4px 10px;
    background: rgba(0, 200, 83, 0.1);
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 700;
    color: var(--primary);
}

.log-time {
    color: var(--text-secondary);
    font-size: 0.9em;
}

.log-content {
    color: var(--text-primary);
    line-height: 1.6;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--primary);
}

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

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

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-elevated);
    transition: 0.4s;
    border-radius: 26px;
    border: 1px solid var(--border-light);
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary);
    border-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(24px);
}

.auto-refresh-control {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--bg-light);
    border: 1px solid var(--border-light);
    border-radius: 8px;
}

.auto-refresh-label {
    font-size: 0.85em;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding: 16px 0;
    border-top: 1px solid var(--border-light);
}

.pagination-info {
    color: var(--text-secondary);
    font-size: 0.9em;
}

.pagination-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.pagination-btn {
    padding: 8px 16px;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--bg-light);
    border-color: var(--primary);
    color: var(--primary);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.page-numbers {
    display: flex;
    gap: 4px;
}

.page-number {
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.page-number:hover:not(.active) {
    background: var(--bg-light);
    border-color: var(--primary);
}

.page-number.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    font-weight: 700;
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .control-grid {
        grid-template-columns: 1fr 1fr;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 15px;
    }

    .content-wrapper {
        padding: 16px;
    }

    .control-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .insights-grid {
        grid-template-columns: 1fr;
    }

    .station-grid {
        grid-template-columns: 1fr;
    }
}
