:root {
    --bg-primary: #060913;
    --bg-surface: rgba(15, 20, 35, 0.65);
    --bg-sidebar: rgba(8, 10, 18, 0.9);
    --border-color: rgba(255, 255, 255, 0.08);
    
    --glow-cyan: rgba(0, 210, 255, 0.4);
    --glow-purple: rgba(179, 136, 255, 0.4);
    
    --color-cyan: #00d2ff;
    --color-purple: #b388ff;
    --color-green: #00ff88;
    --color-red: #ff4d4d;
    --color-text: #e6edf3;
    --color-text-muted: #8b949e;
    
    --font-main: 'Inter', sans-serif;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-primary);
    color: var(--color-text);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    position: relative;
    display: flex;
}

/* Background floating orbs */
.background-orbs {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
    top: 0;
    left: 0;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.35;
    animation: float 25s infinite ease-in-out alternate;
}

.orb-1 {
    width: 500px;
    height: 500px;
    background: var(--color-cyan);
    top: -150px;
    left: -100px;
}

.orb-2 {
    width: 600px;
    height: 600px;
    background: #4facfe;
    bottom: -200px;
    right: -100px;
    animation-delay: -12s;
}

.orb-3 {
    width: 450px;
    height: 450px;
    background: var(--color-purple);
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-duration: 35s;
    animation-delay: -5s;
    opacity: 0.15;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(60px, 80px) scale(1.15); }
    100% { transform: translate(-30px, -40px) scale(0.9); }
}

/* Layout container */
.glass-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    background: rgba(10, 13, 24, 0.45);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
}

/* Sidebar layout */
.sidebar {
    width: 350px;
    min-width: 350px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 30px 24px;
    height: 100%;
    overflow-y: auto;
}

.sidebar-header {
    margin-bottom: 30px;
}

.sidebar-header h1 {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(90deg, var(--color-cyan), var(--color-purple));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px rgba(0, 210, 255, 0.15);
}

.sidebar-header p {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    margin-top: 6px;
    font-weight: 500;
}

/* Brain selector widget */
.brain-selector-section {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
}

.brain-selector-section label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    display: block;
}

.select-wrapper {
    position: relative;
    width: 100%;
}

select {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    appearance: none;
    outline: none;
    cursor: pointer;
    transition: all 0.3s;
}

select:focus {
    border-color: var(--color-cyan);
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.2);
}

.select-wrapper::after {
    content: "▼";
    font-size: 0.75rem;
    color: var(--color-text-muted);
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

/* Registered Brains List */
.brains-list-container {
    margin-bottom: 30px;
    flex: 1;
}

.brains-list-container h3 {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 6px;
}

#brains-status-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 4px;
}

#brains-status-list li {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.25s ease;
}

#brains-status-list li:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateX(3px);
}

#brains-status-list li.active {
    background: rgba(0, 210, 255, 0.08);
    border-color: rgba(0, 210, 255, 0.25);
}

.brain-list-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brain-list-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.brain-list-port {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.brain-list-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot, .indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.online, .indicator.online {
    background: var(--color-green);
    box-shadow: 0 0 10px var(--color-green);
    animation: pulse-green 2s infinite;
}

.status-dot.offline, .indicator.offline {
    background: var(--color-red);
    box-shadow: 0 0 10px var(--color-red);
    animation: pulse-red 2s infinite;
}

@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.6); }
    70% { box-shadow: 0 0 0 8px rgba(0, 255, 136, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 255, 136, 0); }
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(255, 77, 77, 0.6); }
    70% { box-shadow: 0 0 0 8px rgba(255, 77, 77, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 77, 77, 0); }
}

/* Tabs Vertical Navigation */
.tabs-vertical {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 20px;
}

.tabs-vertical .tab-btn {
    text-align: left;
    background: none;
    border: 1px solid transparent;
    color: var(--color-text-muted);
    padding: 12px 18px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.tabs-vertical .tab-btn:hover {
    color: var(--color-text);
    background: rgba(255, 255, 255, 0.04);
}

.tabs-vertical .tab-btn.active {
    color: #fff;
    background: linear-gradient(90deg, rgba(0, 210, 255, 0.15), rgba(179, 136, 255, 0.05));
    border-color: rgba(0, 210, 255, 0.2);
    box-shadow: inset 0 0 10px rgba(0, 210, 255, 0.05);
}

/* Workspace main container */
.workspace {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.tab-content {
    display: none;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.tab-content.active {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

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

.workspace-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.workspace-header h2 {
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff;
}

.workspace-header p {
    color: var(--color-text-muted);
    margin: 5px 0 0 0;
    font-size: 0.9rem;
}

.bridge-status-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Card components */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.card:hover {
    border-color: rgba(0, 210, 255, 0.15);
    box-shadow: 0 15px 40px rgba(0, 210, 255, 0.05);
}

.card h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card p {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 16px;
}

/* Form controls & Buttons */
.btn-group {
    display: flex;
    gap: 12px;
}

.btn {
    padding: 12px 24px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn.primary {
    background: linear-gradient(135deg, var(--color-cyan) 0%, #1e88e5 100%);
    color: #fff;
}
.btn.primary:hover:not(:disabled) {
    box-shadow: 0 0 20px var(--glow-cyan);
    transform: translateY(-2px);
}

.btn.secondary {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
    color: #fff;
}
.btn.secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
}

.btn.danger {
    background: rgba(248, 81, 73, 0.15);
    color: var(--color-red);
    border: 1px solid rgba(248, 81, 73, 0.35);
}
.btn.danger:hover:not(:disabled) {
    background: rgba(248, 81, 73, 0.3);
    box-shadow: 0 0 15px rgba(248, 81, 73, 0.2);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.8rem;
    border-radius: 6px;
}

.w-full {
    width: 100%;
}

.mt-1 { margin-top: 15px; }

/* Textareas & Inputs */
textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px;
    color: var(--color-cyan);
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    outline: none;
    transition: border-color 0.3s;
}

textarea:focus {
    border-color: var(--color-cyan);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.input-group label {
    font-weight: 600;
    color: var(--color-text);
    font-size: 0.9rem;
}

input {
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px 16px;
    color: #fff;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.3s;
}

input:focus {
    border-color: var(--color-cyan);
}

input[readonly] {
    background: rgba(255, 255, 255, 0.02);
    color: var(--color-cyan);
    cursor: default;
}

/* Dual Logs Panel (Grid Layout) */
.logs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-top: 10px;
}

.log-pane {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.log-pane h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.log-terminal {
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    height: 350px;
    overflow-y: auto;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.8rem;
    line-height: 1.4;
    white-space: pre-wrap;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
}

.log-terminal.cyan {
    color: var(--color-cyan);
    border-color: rgba(0, 210, 255, 0.15);
}

.log-terminal.amber {
    color: #ffa500;
    border-color: rgba(255, 165, 0, 0.15);
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Modal Dialog */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(4, 6, 12, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: #0d111b;
    border: 1px solid var(--border-color);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 40px rgba(0, 210, 255, 0.05);
    border-radius: 20px;
    width: 450px;
    max-width: 90vw;
    padding: 30px;
    animation: modalScale 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalScale {
    from { transform: scale(0.9) translateY(10px); }
    to { transform: scale(1) translateY(0); }
}

.modal-content h3 {
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 8px;
}

.modal-content p {
    font-size: 0.85rem;
    margin-bottom: 20px;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Hardware guide box */
.hardware-tip-box {
    background: rgba(0, 210, 255, 0.04);
    padding: 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    border-left: 3px solid var(--color-cyan);
}

.hardware-tip-box h4 {
    margin-bottom: 6px;
    color: var(--color-cyan);
    font-size: 0.95rem;
    font-weight: 700;
}

.hardware-tip-box ul {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    list-style-position: inside;
    padding-left: 5px;
    line-height: 1.6;
}

/* Responsiveness overrides */
@media (max-width: 1024px) {
    .glass-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 20px;
    }
    .brains-list-container {
        display: none; /* Hide brains status list on tablets/mobiles to save vertical space */
    }
    .tabs-vertical {
        flex-direction: row;
        overflow-x: auto;
        border-top: none;
        padding-top: 10px;
        margin-top: 10px;
    }
    .tabs-vertical .tab-btn {
        padding: 10px 14px;
        font-size: 0.85rem;
    }
    .workspace {
        padding: 24px;
    }
    .logs-grid {
        grid-template-columns: 1fr;
    }
}
