/* ==========================================================================
   Design Tokens & Variables
   ========================================================================== */
   :root {
    /* Colors - Light Theme */
    --clr-bg-light: #f3f4f6;
    --clr-surface-light: rgba(255, 255, 255, 0.7);
    --clr-border-light: rgba(255, 255, 255, 0.5);
    --clr-text-light: #1f2937;
    --clr-text-muted-light: #6b7280;

    /* Colors - Dark Theme (Default) */
    --clr-bg-dark: #0f172a;
    --clr-surface-dark: rgba(30, 41, 59, 0.7);
    --clr-border-dark: rgba(255, 255, 255, 0.1);
    --clr-text-dark: #f8fafc;
    --clr-text-muted-dark: #94a3b8;

    /* Brand Colors */
    --clr-primary: #3b82f6;
    --clr-primary-hover: #2563eb;
    --clr-accent: #8b5cf6;
    --clr-success: #10b981;
    --clr-danger: #ef4444;
    --clr-warning: #f59e0b;

    /* Effects */
    --glass-blur: blur(12px);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    
    /* Transitions */
    --trans-fast: 0.15s ease;
    --trans-normal: 0.3s ease;

    /* Spacing */
    --sidebar-width: 260px;
}

/* Apply Dark Theme by default */
body.dark-theme {
    --bg-color: var(--clr-bg-dark);
    --surface-color: var(--clr-surface-dark);
    --border-color: var(--clr-border-dark);
    --text-color: var(--clr-text-dark);
    --text-muted: var(--clr-text-muted-dark);
}

body.light-theme {
    --bg-color: var(--clr-bg-light);
    --surface-color: var(--clr-surface-light);
    --border-color: var(--clr-border-light);
    --text-color: var(--clr-text-light);
    --text-muted: var(--clr-text-muted-light);
}

/* ==========================================================================
   Reset & Base Styles
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    transition: background-color var(--trans-normal), color var(--trans-normal);
    min-height: 100vh;
    overflow-x: hidden;
    /* Animated Gradient Background */
    background: radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.15), transparent 25%),
                radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.15), transparent 25%);
    background-color: var(--bg-color);
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
}

ul {
    list-style: none;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ==========================================================================
   Utility Classes & Components
   ========================================================================== */
.glass-panel {
    background: var(--surface-color);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-glass);
    border-radius: 16px;
    transition: var(--trans-normal);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
    transition: all var(--trans-fast);
    font-family: inherit;
}

.btn:active {
    transform: scale(0.95);
}

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

.btn-primary:hover {
    background-color: var(--clr-primary-hover);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.btn-danger {
    background-color: var(--clr-danger);
    color: white;
}

.btn-icon {
    padding: 0.5rem;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    color: var(--text-color);
}

.btn-icon:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   Layout
   ========================================================================== */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    margin: 1rem;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.brand-icon {
    font-size: 1.75rem;
    color: var(--clr-primary);
    filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.6));
}

.brand-text {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    background: linear-gradient(to right, var(--clr-primary), var(--clr-accent));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 1rem;
    overflow-y: auto;
}

.nav-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--trans-fast);
    font-weight: 500;
}

.nav-item:hover {
    color: var(--text-color);
    background-color: rgba(255, 255, 255, 0.05);
    transform: translateX(4px);
}

.nav-item.active {
    color: var(--clr-primary);
    background-color: rgba(59, 130, 246, 0.1);
}

.nav-item i {
    font-size: 1.25rem;
}

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

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

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--clr-primary), var(--clr-accent));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

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

.user-name {
    font-size: 0.875rem;
    font-weight: 600;
}

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

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 1rem 1rem 1rem 0;
    overflow: hidden;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.topbar-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    width: 300px;
}

.topbar-search input {
    background: transparent;
    border: none;
    color: var(--text-color);
    outline: none;
    width: 100%;
    font-family: inherit;
}

.topbar-search i {
    color: var(--text-muted);
}

.topbar-actions {
    display: flex;
    gap: 0.75rem;
}

.view-container {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
    /* Custom Scrollbar */
    &::-webkit-scrollbar {
        width: 6px;
    }
    &::-webkit-scrollbar-track {
        background: transparent;
    }
    &::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.2);
        border-radius: 10px;
    }
}

/* ==========================================================================
   Views Styles
   ========================================================================== */
.view-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 2rem;
    animation: fadeInDown 0.5s ease forwards;
}

.view-header h2 {
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Dashboard View */
.active-router-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
}

.active-router-selector select {
    background: transparent;
    border: none;
    color: var(--text-color);
    outline: none;
    font-family: inherit;
    font-size: 0.875rem;
    cursor: pointer;
}

.active-router-selector select option {
    background-color: var(--bg-color);
    color: var(--text-color);
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    animation: fadeInUp 0.5s ease forwards;
    opacity: 0;
}

.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.2s; }
.stat-card:nth-child(3) { animation-delay: 0.3s; }
.stat-card:nth-child(4) { animation-delay: 0.4s; }

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    background: rgba(59, 130, 246, 0.1);
    color: var(--clr-primary);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
}

.empty-state {
    grid-column: 1 / -1;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted);
    padding: 3rem;
}

.interface-checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid var(--border-color);
    transition: all var(--trans-fast);
}

.interface-checkbox-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.interface-checkbox-item input {
    cursor: pointer;
}

/* Custom Dropdown Multi-Select */
.custom-dropdown {
    position: relative;
    width: 100%;
    max-width: 400px;
}
.dropdown-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
}
.dropdown-list {
    display: none;
    position: absolute;
    top: 110%;
    left: 0;
    width: 100%;
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    border: 1px solid var(--border-color);
    padding: 0.5rem;
}
.dropdown-list.show {
    display: block;
}
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}
.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.1);
}
.dropdown-item input {
    cursor: pointer;
}

.dashboard-charts {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    animation: fadeInUp 0.5s ease forwards;
    animation-delay: 0.5s;
    opacity: 0;
}

.chart-container {
    padding: 1.5rem;
}

.chart-container h3 {
    font-size: 1rem;
    margin-bottom: 1.5rem;
    color: var(--text-muted);
}

/* Demo Charts styling */
.chart-placeholder {
    height: 200px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding-top: 20px;
    border-bottom: 1px solid var(--border-color);
}

.chart-placeholder .bar {
    flex: 1;
    background: linear-gradient(to top, rgba(59, 130, 246, 0.2), rgba(59, 130, 246, 0.8));
    border-radius: 4px 4px 0 0;
    transition: height 1s ease;
}

.circle-charts {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 200px;
}

.circle-chart {
    text-align: center;
}

.circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: conic-gradient(var(--clr-primary) var(--perc), var(--border-color) 0);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
    position: relative;
}

.circle::before {
    content: '';
    position: absolute;
    inset: 8px;
    background-color: var(--surface-color);
    border-radius: 50%;
}

.circle span {
    position: relative;
    font-weight: 600;
    font-size: 0.875rem;
}

/* Router Manager View */
.router-list-container {
    padding: 1rem;
    animation: fadeInUp 0.5s ease forwards;
}

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

.router-table th, .router-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.router-table th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.875rem;
}

.router-table tbody tr {
    transition: background-color var(--trans-fast);
}

.router-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.router-table tbody tr:last-child td {
    border-bottom: none;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-badge.offline {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--clr-danger);
}

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

.action-btns {
    display: flex;
    gap: 0.5rem;
}

.btn-icon-small {
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
    transition: all var(--trans-fast);
}

.btn-icon-small:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
}

.btn-icon-small.delete:hover {
    background: rgba(239, 68, 68, 0.2);
    color: var(--clr-danger);
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 1;
    transition: opacity var(--trans-normal);
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    width: 100%;
    max-width: 500px;
    padding: 2rem;
    transform: scale(1);
    transition: transform var(--trans-normal);
}

.modal-overlay.hidden .modal-content {
    transform: scale(0.95);
}

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

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.25rem;
    transition: color var(--trans-fast);
}

.btn-close:hover {
    color: var(--text-color);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-family: inherit;
    outline: none;
    transition: border-color var(--trans-fast);
}

.form-group input:focus {
    border-color: var(--clr-primary);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

/* Settings View */
.settings-container {
    padding: 2rem;
    animation: fadeInUp 0.5s ease forwards;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.setting-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.setting-info h4 {
    margin-bottom: 0.25rem;
}

.setting-info p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

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

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* SpeedMeter Styles */
.speedmeters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    width: 100%;
    margin-top: 1rem;
}
.speedmeter {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--surface-light);
    border-radius: 12px;
    padding: 1.5rem 1rem;
    position: relative;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.speedmeter h4 {
    margin: 0 0 1rem 0;
    font-size: 0.95rem;
    color: var(--text-color);
    text-align: center;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.speedmeter-svg-container {
    position: relative;
    width: 100%;
    max-width: 180px;
    aspect-ratio: 2/1;
}
.speedmeter-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}
.speedmeter-bg {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 10;
    stroke-linecap: round;
}
.speedmeter-val {
    fill: none;
    stroke: var(--clr-primary);
    stroke-width: 10;
    stroke-linecap: round;
    stroke-dasharray: 125.66;
    stroke-dashoffset: 125.66;
    transition: stroke-dashoffset 0.8s ease-out, stroke 0.3s;
}
.speedmeter-text {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    text-align: center;
}
.speedmeter-speed {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-color);
}
.speedmeter-unit {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.speedmeter-details {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-top: 1.5rem;
    font-size: 0.8rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}
.speedmeter-tx { color: var(--clr-secondary); font-weight: 600;}
.speedmeter-rx { color: var(--clr-primary); font-weight: 600;}

