@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --sidebar-width: 240px;
    --sidebar-bg: #1a1d23;
    --sidebar-hover: #2a2d35;
    --sidebar-active: #3a3d45;
    --sidebar-text: #8b8fa3;
    --sidebar-text-active: #ffffff;
    --body-bg: #f0f2f5;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.08);
    --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.12);
    --accent: #6366f1;
    --accent-light: #818cf8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--body-bg);
    color: #1f2937;
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
}

.sidebar-brand-text {
    color: white;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: -0.3px;
}

.sidebar-brand-sub {
    color: var(--sidebar-text);
    font-size: 11px;
    font-weight: 400;
}

.sidebar-section {
    padding: 16px 12px 8px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(139,143,163,0.5);
}

.sidebar-nav {
    list-style: none;
    padding: 0 8px;
    margin: 0;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
}

.sidebar-nav li a:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
}

.sidebar-nav li a.active {
    background: var(--accent);
    color: white;
}

.sidebar-nav li a .nav-icon {
    width: 20px;
    text-align: center;
    font-size: 15px;
}

.sidebar-nav li a .nav-badge {
    margin-left: auto;
    background: rgba(255,255,255,0.1);
    color: var(--sidebar-text);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.sidebar-nav li a.active .nav-badge {
    background: rgba(255,255,255,0.2);
    color: white;
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--sidebar-text);
    font-size: 13px;
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--sidebar-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.sidebar-user a {
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 11px;
}

.sidebar-user a:hover { color: var(--sidebar-text-active); }

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

.topbar {
    background: white;
    border-bottom: 1px solid #e5e7eb;
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.content {
    padding: 24px 32px;
}

/* Login page: no sidebar */
body.login-page {
    background: var(--body-bg);
}

body.login-page .main {
    margin-left: 0;
}

/* ===== Stat Cards ===== */
.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px 24px;
    box-shadow: var(--card-shadow);
    transition: box-shadow 0.2s;
}

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

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

.stat-card-label {
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
}

.stat-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.stat-card-icon.purple { background: #ede9fe; color: var(--accent); }
.stat-card-icon.green { background: #d1fae5; color: var(--success); }
.stat-card-icon.amber { background: #fef3c7; color: var(--warning); }
.stat-card-icon.red { background: #fee2e2; color: var(--danger); }
.stat-card-icon.blue { background: #dbeafe; color: #3b82f6; }

.stat-card-value {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -1px;
    line-height: 1;
}

.stat-card-sub {
    font-size: 12px;
    margin-top: 6px;
    color: #6b7280;
}

/* ===== Network Cards ===== */
.network-card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    overflow: hidden;
    transition: all 0.2s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.network-card:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-2px);
    color: inherit;
    text-decoration: none;
}

.network-card-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.network-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
}

.network-card-info h5 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.network-card-info span {
    font-size: 12px;
    color: #9ca3af;
}

.network-card-stats {
    display: flex;
    border-top: 1px solid #f3f4f6;
}

.network-card-stat {
    flex: 1;
    padding: 12px 20px;
    text-align: center;
}

.network-card-stat + .network-card-stat {
    border-left: 1px solid #f3f4f6;
}

.network-card-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
}

.network-card-stat-label {
    font-size: 11px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== Data Card ===== */
.data-card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    overflow: hidden;
    margin-bottom: 16px;
}

.data-card-header {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #f3f4f6;
    font-size: 15px;
    font-weight: 600;
}

.data-card-body {
    padding: 24px;
}

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

.data-table th {
    padding: 10px 24px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #9ca3af;
    background: #fafbfc;
    border-bottom: 1px solid #f3f4f6;
}

.data-table td {
    padding: 12px 24px;
    font-size: 13px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafbfc; }

/* ===== Network Badge ===== */
.net-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

/* Keep legacy class working */
.badge-network {
    font-size: 0.8em;
}

/* ===== Status Pills ===== */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.pill-success { background: #d1fae5; color: #065f46; }
.pill-danger { background: #fee2e2; color: #991b1b; }
.pill-warning { background: #fef3c7; color: #92400e; }
.pill-muted { background: #f3f4f6; color: #6b7280; }

/* ===== Status Dot ===== */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.active { background: var(--success); }
.status-dot.inactive { background: #d1d5db; }
.status-dot.error { background: var(--danger); }

/* ===== Action Buttons ===== */
.action-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #9ca3af;
    transition: all 0.15s;
    font-size: 13px;
    padding: 0;
}

.action-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

.action-btn.danger:hover {
    background: #fee2e2;
    color: var(--danger);
}

.action-btn.warning:hover {
    background: #fef3c7;
    color: var(--warning);
}

/* ===== Custom Primary Button ===== */
.btn-primary-custom {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s;
    text-decoration: none;
}

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

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

.section-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

/* ===== Utilities ===== */
.text-truncate-custom {
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
}

.link-subtle {
    color: #374151;
    text-decoration: none;
}

.link-subtle:hover { color: var(--accent); }

.time-ago {
    color: #9ca3af;
    font-size: 12px;
}

/* ===== Toggle Switch ===== */
.toggle-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.toggle-switch input[type="checkbox"] { display: none; }

.toggle-switch .toggle-track {
    position: relative;
    width: 36px;
    height: 20px;
    background: #d1d5db;
    border-radius: 10px;
    transition: background 0.25s ease;
}

.toggle-switch .toggle-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    transition: transform 0.25s cubic-bezier(0.68, -0.30, 0.27, 1.30);
}

.toggle-switch input:checked + .toggle-track {
    background: var(--success);
}

.toggle-switch input:checked + .toggle-track::after {
    transform: translateX(16px);
}

.toggle-switch.toggle-loading .toggle-track { opacity: 0.5; }
.toggle-switch.toggle-loading .toggle-track::after {
    animation: toggle-pulse 0.6s ease-in-out infinite alternate;
}

@keyframes toggle-pulse {
    from { box-shadow: 0 1px 3px rgba(0,0,0,0.15); }
    to { box-shadow: 0 1px 8px rgba(16,185,129,0.5); }
}

/* ===== Table Row States ===== */
.table-row-deleted { opacity: 0.5; }
.table-row-hidden { background-color: #f8f9fa; }

/* ===== Raw Data ===== */
pre.raw-data {
    max-height: 400px;
    overflow-y: auto;
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 0.375rem;
}

/* ===== Detail Tables ===== */
.detail-table {
    width: 100%;
}

.detail-table th {
    padding: 8px 0;
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
    width: 180px;
    vertical-align: top;
}

.detail-table td {
    padding: 8px 0;
    font-size: 13px;
}

/* ===== Breadcrumbs ===== */
.breadcrumb {
    font-size: 13px;
    margin-bottom: 20px;
}

/* ===== Forms ===== */
.btn-group > form { display: contents; }
.d-flex > form { display: contents; }

/* ===== Misc ===== */
code {
    font-size: 12px;
}
