/* ============================================================
   DB Insight Visualizer - Main Stylesheet
   Clean schema visualization theme with ER diagram styling
   ============================================================ */

/* ---- CSS Variables ---- */
:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-card-hover: #263548;
    --border-color: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-blue: #60a5fa;
    --accent-green: #4ade80;
    --accent-yellow: #fbbf24;
    --accent-red: #f87171;
    --accent-purple: #a78bfa;
    --accent-cyan: #22d3ee;
    --accent-orange: #fb923c;
    --sidebar-width: 240px;
    --radius: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --transition: all 0.2s ease;
}

/* ---- Reset ---- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    line-height: 1.6;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.logo-icon {
    flex-shrink: 0;
}

.nav-links {
    list-style: none;
    padding: 12px 0;
    flex: 1;
}

.nav-links li {
    padding: 0 12px;
}

.nav-link {
    display: block;
    padding: 10px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius);
    transition: var(--transition);
    font-size: 14px;
    font-weight: 500;
}

.nav-link:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.nav-link.active {
    background: rgba(96, 165, 250, 0.15);
    color: var(--accent-blue);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-muted);
}

/* ---- Main Content ---- */
.content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 24px 32px;
    min-height: 100vh;
}

/* ---- Page Header ---- */
.page-header {
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ---- Cards ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    transition: var(--transition);
}

.card:hover {
    border-color: var(--accent-blue);
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

/* ---- Stats Grid ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}

.stat-card .stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--accent-blue);
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card.green .stat-value { color: var(--accent-green); }
.stat-card.yellow .stat-value { color: var(--accent-yellow); }
.stat-card.red .stat-value { color: var(--accent-red); }
.stat-card.purple .stat-value { color: var(--accent-purple); }
.stat-card.cyan .stat-value { color: var(--accent-cyan); }

/* ---- Health Gauge ---- */
.health-gauge {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 24px;
}

.gauge-circle {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 12px;
    position: relative;
}

.gauge-circle::before {
    content: '';
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    background: var(--bg-card);
}

.gauge-circle span {
    position: relative;
    z-index: 1;
}

.gauge-label {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ---- Tables ---- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table thead th {
    text-align: left;
    padding: 12px 16px;
    border-bottom: 2px solid var(--border-color);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table tbody td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
}

.data-table tbody tr:hover {
    background: var(--bg-card-hover);
}

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-pk {
    background: rgba(96, 165, 250, 0.2);
    color: var(--accent-blue);
}

.badge-fk {
    background: rgba(167, 139, 250, 0.2);
    color: var(--accent-purple);
}

.badge-nullable {
    background: rgba(251, 191, 36, 0.2);
    color: var(--accent-yellow);
}

.badge-indexed {
    background: rgba(74, 222, 128, 0.2);
    color: var(--accent-green);
}

.badge-type {
    background: rgba(34, 211, 238, 0.2);
    color: var(--accent-cyan);
}

/* ---- ER Diagram ---- */
.er-canvas-container {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: auto;
    position: relative;
    min-height: 500px;
}

.er-canvas-container canvas {
    display: block;
}

.er-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.er-legend {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.er-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.er-legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-blue);
}

.btn-primary {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: #000;
}

.btn-primary:hover {
    background: #3b82f6;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

.btn-danger {
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.btn-danger:hover {
    background: rgba(248, 113, 113, 0.15);
}

/* ---- Radar Chart ---- */
.radar-container {
    display: flex;
    justify-content: center;
    padding: 20px;
}

.radar-container canvas {
    max-width: 400px;
    max-height: 400px;
}

/* ---- Health Bars ---- */
.health-bar-container {
    margin-bottom: 12px;
}

.health-bar-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 13px;
}

.health-bar-label span:first-child {
    color: var(--text-secondary);
}

.health-bar-label span:last-child {
    font-weight: 600;
}

.health-bar {
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
}

.health-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* ---- Grid Layouts ---- */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

/* ---- Database List ---- */
.db-list {
    display: grid;
    gap: 12px;
}

.db-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    transition: var(--transition);
}

.db-item:hover {
    border-color: var(--accent-blue);
}

.db-item-info h4 {
    font-size: 15px;
    margin-bottom: 4px;
}

.db-item-info p {
    font-size: 13px;
    color: var(--text-secondary);
}

.db-item-actions {
    display: flex;
    gap: 8px;
}

/* ---- Recommendations ---- */
.recommendation-list {
    list-style: none;
}

.recommendation-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    color: var(--text-secondary);
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.recommendation-list li::before {
    content: '!';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: rgba(251, 191, 36, 0.2);
    color: var(--accent-yellow);
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 2px;
}

/* ---- Loading & Spinner ---- */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: var(--text-secondary);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---- Breadcrumb ---- */
.breadcrumb {
    display: flex;
    gap: 8px;
    font-size: 13px;
    margin-bottom: 16px;
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--accent-blue);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }
    .sidebar-header h1,
    .nav-link span,
    .sidebar-footer {
        display: none;
    }
    .content {
        margin-left: 60px;
        padding: 16px;
    }
    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}
