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

:root {
    --bg-primary: #0a0b0d;
    --bg-secondary: #141519;
    --bg-card: #1a1b21;
    --bg-hover: #22232a;
    --border-color: #2a2b33;
    --text-primary: #e4e4e7;
    --text-secondary: #9ca3af;
    --text-dim: #6b7280;
    --accent-primary: #3b82f6;
    --accent-secondary: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --chart-1: #3b82f6;
    --chart-2: #8b5cf6;
    --chart-3: #ec4899;
    --chart-4: #10b981;
    --chart-5: #f59e0b;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.dashboard {
    width: 100%;
    min-height: 100vh;
}

/* Header */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    background: rgba(20, 21, 25, 0.95);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.logo {
    color: var(--accent-primary);
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-stats {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.4rem;
    align-items: center;
    justify-content: center;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

@media (max-width: 980px) {
    .header-content {
        gap: 1rem;
    }

    .header-stats {
        justify-content: center;
    }
}

.stat-badge {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.6rem;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    justify-content: center;
    text-align: center;
}

.stat-icon {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg {
    color: white;
}

.stat-meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    align-items: center;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
}

.status-indicator {
    flex-direction: row;
    gap: 0.5rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

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

/* Main Content */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

.section-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* Overview Cards */
.overview-section {
    margin-bottom: 2rem;
}

.overview-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.overview-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    min-height: 120px;
    display: flex;
    gap: 1rem;
    transition: all 0.3s ease;
}

.overview-card:hover {
    background: var(--bg-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.card-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.card-icon svg {
    color: white;
}

.card-content {
    flex: 1;
}

.card-content h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.card-trend {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.card-trend.positive {
    color: var(--success);
}

.card-trend.negative {
    color: var(--danger);
}

/* Database Section */
.databases-section {
    margin-bottom: 2rem;
}

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

.filter-buttons {
    display: flex;
    gap: 0.5rem;
}

.filter-btn {
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

.database-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.database-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    transition: all 0.3s ease;
}

.database-card:hover {
    background: var(--bg-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.db-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
}

.db-info h3 {
    font-size: 1.125rem;
    margin-bottom: 0.25rem;
}

.db-type {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.db-status {
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
}

.db-status.online {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.db-status.offline {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.db-status.maintenance {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.db-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.db-stat {
    display: flex;
    flex-direction: column;
}

.db-stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.db-stat-value {
    font-size: 1.25rem;
    font-weight: 600;
}

.db-users {
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

.db-users-title {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.user-avatars {
    display: flex;
    gap: 6px;
    width: 100%;
    flex-wrap: nowrap;
    align-items: center;
    overflow: visible;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--bg-card);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.more-users {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.avatar-more {
    position: relative;
}

.avatar-tooltip {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    transform: translateX(-50%);
    background: rgba(26, 27, 33, 0.98);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.6rem;
    color: var(--text-primary);
    font-size: 0.8rem;
    line-height: 1.3;
    white-space: nowrap;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    z-index: 1000;
    display: none;
    max-width: 320px;
    max-height: 200px;
    overflow: auto;
}

.avatar-more:hover .avatar-tooltip,
.avatar-more:focus .avatar-tooltip,
.avatar-more:focus-within .avatar-tooltip {
    display: block;
}

.chart-avatar-tooltip {
    position: fixed;
    padding: 0.6rem 0.75rem;
    background: rgba(17, 24, 39, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.75rem;
    color: var(--text-primary);
    font-size: 0.85rem;
    line-height: 1.2;
    white-space: nowrap;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    z-index: 1000;
    display: none;
    pointer-events: none;
}

/* Charts Section */
.charts-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    height: 330px;
}

.chart-container h3 {
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.chart-container canvas {
    max-height: 250px;
}

.user-actions-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.25rem;
}

.user-actions-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.user-actions-select {
    appearance: none;
    background: rgba(3, 7, 18, 0.55);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.75rem;
    outline: none;
}

.user-actions-select:focus {
    border-color: rgba(59, 130, 246, 0.8);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.visuals-header-controls {
    margin-left: auto;
    margin-right: 1rem;
    display: flex;
    align-items: center;
}

.visuals-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.75rem;
    padding: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-sm);
    background: rgba(3, 7, 18, 0.35);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
}

.visuals-icon-btn:hover {
    color: var(--text-primary);
    border-color: rgba(59, 130, 246, 0.35);
    background: rgba(59, 130, 246, 0.12);
}

.visuals-back-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.45rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-sm);
    background: rgba(3, 7, 18, 0.35);
}

.visuals-back-link:hover {
    color: var(--text-primary);
    border-color: rgba(59, 130, 246, 0.35);
    background: rgba(59, 130, 246, 0.12);
}

.visuals-link {
    display: inline-block;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    padding: 0.55rem 0.9rem;
    border: 1px solid rgba(59, 130, 246, 0.35);
    border-radius: var(--radius-sm);
    background: rgba(59, 130, 246, 0.18);
}

.visuals-link:hover {
    background: rgba(59, 130, 246, 0.25);
}

/* Users Table */
.users-section {
    margin-bottom: 2rem;
}

.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

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

.users-table thead {
    background: var(--bg-secondary);
}

.users-table th {
    padding: 0.75rem;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.users-table td {
    padding: 0.75rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.users-table tbody tr {
    transition: background 0.3s ease;
}

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

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar-table {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
}

.user-details {
    display: flex;
    flex-direction: column;
}

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

.user-email {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
}

.status-badge.active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.status-badge.idle {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.action-btn {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.action-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .logo-section {
        justify-content: center;
    }

    .header-stats {
        width: 100%;
        justify-content: center;
        position: static;
        left: auto;
        transform: none;
        flex-wrap: wrap;
    }

    .overview-cards {
        grid-template-columns: 1fr;
    }

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

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

    .table-container {
        overflow-x: auto;
    }
}
