:root {
    --bg-dark: #0a0b0f;
    --bg-light: #14151a;
    --accent: #00f5d4;
    --border: #2a2b30;
    --text-primary: #e4e4e6;
    --text-secondary: #8c8d93;
    --ping-fast: #00f5d4;
    --ping-med: #f5a623;
    --ping-slow: #f52366;
    --font-main: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-mono: 'Consolas', 'Courier New', monospace;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-main);
    margin: 0;
    padding: 0;
    height: 100vh;
    display: flex;
    overflow: hidden;
    user-select: none;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-light); 
}
::-webkit-scrollbar-thumb {
    background: var(--border); 
}
::-webkit-scrollbar-thumb:hover {
    background: #444; 
}

/* Layout */
#app {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar */
#sidebar {
    width: 280px;
    background-color: var(--bg-light);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
    flex-shrink: 0;
}

#logo-container {
    display: flex;
    justify-content: center;
    margin-bottom: 5px;
}

#logo-img {
    width: 80px;
    height: 80px;
    object-fit: contain;
}

#flag-display {
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 5px;
}
#flag-img {
    height: 60px;
    width: auto;
}

/* Custom Select */
.custom-select-wrapper {
    position: relative;
    user-select: none;
    margin-bottom: 20px;
}
.custom-select {
    position: relative;
    display: flex;
    flex-direction: column;
}
.custom-select__trigger {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    height: 30px;
    line-height: 30px;
    background: var(--border); /* Python button_color matches border variable sort of */
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}
.custom-select__trigger:hover {
    background: var(--accent);
    color: #000;
}
.custom-options {
    position: absolute;
    display: block;
    top: 100%;
    left: 0;
    right: 0;
    border: 1px solid var(--border);
    border-top: 0;
    background: var(--bg-light);
    transition: all 0.2s;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 2;
    max-height: 200px;
    overflow-y: auto;
}
.custom-select.open .custom-options {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}
.custom-option {
    position: relative;
    display: block;
    padding: 0 15px;
    font-size: 14px;
    font-weight: 300;
    color: var(--text-primary);
    line-height: 30px;
    cursor: pointer;
    transition: all 0.2s;
}
.custom-option:hover {
    background: var(--accent);
    color: #000;
}

/* Settings Section */
.section-title {
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: bold;
    margin-top: 20px;
    margin-bottom: 10px;
    padding-left: 5px;
}

/* Toggle Switch */
.switch-container {
    display: flex;
    align-items: center;
    justify-content: space-between; /* Python uses anchor="w", but web usually has label left, switch right? Python code: switch widget with text. */
    margin-bottom: 10px;
    padding-left: 5px;
    cursor: pointer;
}
.switch-label {
    font-size: 14px;
    margin-right: 10px;
}
.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}
.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #444;
    transition: .4s;
    border-radius: 20px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
input:checked + .slider {
    background-color: var(--accent);
}
input:checked + .slider:before {
    transform: translateX(16px);
}

/* Segmented Button */
.segmented-control {
    display: flex;
    width: 100%;
    background: var(--bg-dark); /* or similar */
    padding: 3px;
    border-radius: 4px;
    margin-top: 10px;
}
.segmented-option {
    flex: 1;
    text-align: center;
    padding: 5px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-primary);
    border-radius: 3px;
    transition: 0.2s;
}
.segmented-option.selected {
    background-color: var(--accent);
    color: #000;
    font-weight: bold;
}

/* Status Bar */
#status-bar {
    margin-top: auto;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
}

/* Main View */
#main-view {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Welcome Screen */
#welcome-screen {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    background-color: var(--bg-dark); /* overlay */
}
#welcome-screen.hidden {
    display: none;
}
.welcome-title {
    font-size: 36px;
    font-weight: bold;
    color: var(--accent);
    margin-bottom: 10px;
}
.welcome-subtitle {
    color: var(--text-secondary);
}

/* Workspace */
#workspace {
    display: flex;
    flex-direction: column;
    height: 100%;
}
#workspace.hidden {
    display: none;
}

/* Header */
.ws-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    height: 32px;
}
#total-label {
    font-size: 16px;
    font-weight: bold;
}
.btn {
    background-color: var(--accent);
    color: #000;
    border: none;
    padding: 5px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
}
.btn:hover {
    filter: brightness(0.9);
}

/* List Box */
#list-box {
    flex: 1;
    background-color: var(--bg-light);
    border: 1px solid var(--border);
    overflow-y: auto;
    padding: 5px;
}

/* List Item */
.list-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid transparent;
}
.list-item:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.item-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid #555;
    margin-right: 15px;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.item-checkbox.checked {
    background-color: var(--accent);
    border-color: var(--accent);
}
.item-checkbox.checked::after {
    content: '✔';
    font-size: 12px;
    color: #000;
}

.item-dot {
    color: #444;
    font-size: 18px;
    margin-right: 10px;
}
.item-ip {
    font-family: var(--font-mono);
    font-size: 13px;
    width: 300px;
    cursor: pointer;
}
.item-ip:hover {
    text-decoration: underline;
}
.item-latency {
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 60px;
}

/* Selection Bar */
#selection-bar {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 60px;
    background-color: var(--bg-light);
    border: 1px solid var(--accent);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    box-sizing: border-box;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    z-index: 5;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
#selection-bar.visible {
    opacity: 1;
    pointer-events: all;
}
#sel-label {
    color: var(--accent);
    font-weight: bold;
}

/* Inspector Modal */
#modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
#modal-overlay.visible {
    opacity: 1;
    pointer-events: all;
}
.modal {
    background: var(--bg-light);
    width: 400px;
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}
.modal-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 20px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
    display: flex;
    justify-content: space-between;
}
.close-btn {
    cursor: pointer;
    font-size: 20px;
    line-height: 20px;
}
.detail-row {
    margin-bottom: 15px;
}
.detail-label {
    font-size: 10px;
    font-weight: bold;
    color: gray;
    margin-bottom: 2px;
}
.detail-value {
    font-size: 14px;
}


.text-green { color: var(--ping-fast); }
.text-orange { color: var(--ping-med); }
.text-red { color: var(--ping-slow); }
.text-gray { color: #444; }

/* Footer */
#footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 20px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.footer-text {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.footer-link {
    color: var(--accent);
    text-decoration: none;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.footer-link:hover {
    transform: scale(1.1);
}

.footer-link svg {
    fill: var(--accent);
}

/* Modal Copy Button */
.modal-copy-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--accent);
    margin-left: 10px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-copy-btn:hover {
    color: #fff;
}

.modal-header-content {
    display: flex;
    align-items: center;
}
