/* Core Layout & Theme */
:root {
    --bg-color: #0b0c10;
    --card-bg: #1f2833;
    --accent-primary: #00ff88;
    --accent-secondary: #00e5ff;
    --text-main: #c5c6c7;
    --text-header: #ffffff;
    --border-color: #2c3540;
    --hover-bg: #2b3a4a;
}

body {
    margin: 0;
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background: var(--bg-color);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
    overflow: hidden;
}

/* ===== Sidebar ===== */
#session-sidebar {
    width: 230px;
    min-width: 230px;
    background: #0d1017;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow: hidden;
}

#sidebar-logo {
    padding: 18px 16px 12px;
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 2px;
    color: var(--accent-primary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

#sidebar-logo small {
    display: block;
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.5px;
    color: #4a5568;
    margin-top: 2px;
}

#sidebar-new-btn {
    margin: 10px 12px 4px;
    padding: 8px 12px;
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid rgba(0, 255, 136, 0.3);
    color: var(--accent-primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-align: center;
    transition: background 0.2s, border-color 0.2s;
    flex-shrink: 0;
}

#sidebar-new-btn:hover {
    background: rgba(0, 255, 136, 0.2);
    border-color: var(--accent-primary);
}

#session-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

#session-list::-webkit-scrollbar { width: 4px; }
#session-list::-webkit-scrollbar-track { background: transparent; }
#session-list::-webkit-scrollbar-thumb { background: #2c3540; border-radius: 4px; }

.session-pill {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 9px 12px 9px 14px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.15s, border-color 0.15s;
    position: relative;
}

.session-pill:hover {
    background: rgba(255,255,255,0.03);
}

.session-pill.active {
    background: rgba(0, 255, 136, 0.07);
    border-left-color: var(--accent-primary);
}

.session-pill-info {
    flex: 1;
    min-width: 0;
}

.session-pill-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-header);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-pill.active .session-pill-label {
    color: var(--accent-primary);
}

.session-pill-id {
    font-size: 10px;
    font-family: monospace;
    color: #4a5a6a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-pill-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    margin-left: 6px;
}

.session-badge {
    background: #1a2535;
    color: #5a7a9a;
    font-size: 10px;
    font-weight: 700;
    border-radius: 10px;
    padding: 1px 6px;
    min-width: 18px;
    text-align: center;
}

.session-badge.has-events {
    background: rgba(0, 255, 136, 0.12);
    color: var(--accent-primary);
}

.session-del-btn {
    background: none;
    border: none;
    color: #3a4a5a;
    font-size: 13px;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    line-height: 1;
    transition: color 0.2s, background 0.2s;
}

.session-del-btn:hover {
    color: #e53e3e;
    background: rgba(229, 62, 62, 0.1);
}

#sidebar-footer {
    padding: 10px 12px;
    border-top: 1px solid var(--border-color);
    font-size: 10px;
    color: #2d3748;
    font-family: monospace;
    flex-shrink: 0;
}

/* ===== Main content area ===== */
#main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100vh;
}

.container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    box-sizing: border-box;
}

h2 {
    color: var(--text-header);
    margin: 0 0 4px 0;
    font-size: 24px;
    letter-spacing: -0.5px;
    text-align: center;
}

.app-logo {
    text-align: left;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--accent-primary);
    margin-bottom: 16px;
}

/* Tabs Styling */
.tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    margin-bottom: 24px;
}

.tab-link {
    background: transparent;
    border: none;
    color: var(--text-main);
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease-in-out;
}

.tab-link:hover {
    background: var(--hover-bg);
    color: var(--text-header);
}

.tab-link.active {
    background: rgba(0, 255, 136, 0.15);
    color: var(--accent-primary);
    border: 1px solid rgba(0, 255, 136, 0.3);
}

/* Tab Content Visibility Controller */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Forms & UI Controls */
.input-wrapper {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto 24px auto;
}

.input-wrapper input {
    width: 100%;
    padding: 12px 48px 12px 16px;
    font-size: 15px;
    font-family: monospace;
    background: #090b0f;
    color: var(--accent-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-sizing: border-box;
    outline: none;
    text-align: center;
    transition: border-color 0.2s;
}

.input-wrapper input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 8px rgba(0, 255, 136, 0.2);
}

.copy-btn.endpoint {
    position: absolute;
    top: 50%;
    right: 14px;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--accent-primary);
    font-size: 18px;
    opacity: 0.8;
}

.copy-btn.endpoint:hover {
    opacity: 1;
}

/* Foldout panel */
.foldout {
    margin-bottom: 24px;
    background: #171b26;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.foldout-toggle {
    padding: 12px 16px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    color: var(--accent-secondary);
    user-select: none;
    background: #131720;
    transition: background 0.2s;
}

.foldout-toggle:hover {
    background: #1c2230;
}

.foldout-content {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.foldout-content h4 {
    margin: 0 0 8px 0;
    font-size: 13px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cmd {
    position: relative;
    background: #090b0f;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 12px;
}

.cmd pre {
    margin: 0;
    font-family: monospace;
    font-size: 13px;
    color: var(--accent-primary);
    white-space: pre-wrap;
    word-break: break-all;
    padding-right: 30px;
}

.cmd .copy-btn {
    position: absolute;
    right: 10px;
    top: 10px;
    cursor: pointer;
    color: var(--accent-primary);
    font-size: 15px;
}

.webrtc-note {
    font-size: 12px;
    color: #888;
    margin: 8px 0 0 0;
    line-height: 1.4;
}

/* Cards & Panel Blocks */
.feature-card {
    background: #171b26;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
}

.feature-card h3 {
    margin: 0 0 12px 0;
    font-size: 18px;
    color: var(--text-header);
}

/* Tables */
.table-wrapper {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.table-body {
    max-height: calc(100vh - 320px);
    overflow-y: auto;
}

.table-body::-webkit-scrollbar {
    width: 6px;
}

.table-body::-webkit-scrollbar-track {
    background: #0d1017;
}

.table-body::-webkit-scrollbar-thumb {
    background: #2c3540;
    border-radius: 3px;
}

.table-body::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: #131720;
    color: #888;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 2;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.rownum {
    color: #555;
    font-weight: bold;
}

.query-cell {
    font-family: monospace;
    word-break: break-all;
}

/* Form Styling Details */
.form-group {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: #aaa;
    margin-bottom: 6px;
}

.form-group input, .form-group select, .form-group textarea {
    background: #090b0f;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px;
    font-size: 14px;
    color: var(--text-header);
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--accent-secondary);
}

textarea.assembler-output {
    width: 100%;
    height: 120px;
    background: #090b0f;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px;
    box-sizing: border-box;
    font-family: monospace;
    font-size: 13px;
    color: var(--accent-primary);
    resize: vertical;
    outline: none;
}

.btn {
    background: linear-gradient(135deg, #00ff88 0%, #00e5ff 100%);
    color: #0b0c10;
    border: none;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
}

.btn:hover {
    opacity: 0.9;
}

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

.hosted-table th, .hosted-table td {
    padding: 10px 12px;
}

/* Modal Window */
#modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
}

#modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(5, 5, 8, 0.85);
    backdrop-filter: blur(4px);
}

#modal-content {
    position: relative;
    background: #171b26;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    margin: 15vh auto;
    padding: 24px;
    box-sizing: border-box;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

#modal-close {
    position: absolute;
    top: 16px;
    right: 18px;
    cursor: pointer;
    font-size: 18px;
    color: #888;
}

#modal-close:hover {
    color: var(--text-header);
}

.modal-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-bottom: 8px;
}

.modal-row span:first-child {
    color: #888;
    font-size: 13px;
}

.modal-row span:last-child {
    font-weight: 600;
}

.modal-code {
    font-family: monospace;
    color: var(--accent-primary);
    word-break: break-all;
}

.modal-explain {
    margin-top: 20px;
    background: #11141c;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
}

.modal-explain h4 {
    margin: 0 0 6px 0;
    color: var(--accent-secondary);
}

.modal-explain p {
    margin: 0;
    font-size: 13px;
    color: #999;
    line-height: 1.4;
}

/* Loader animation line */
.loader {
    height: 3px;
    background: #090b0f;
    position: relative;
    overflow: hidden;
}

.loader::before {
    content: "";
    position: absolute;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, var(--accent-primary), transparent);
    animation: loading 2.5s ease-in-out infinite;
}

@keyframes loading {
    from { left: -100%; }
    to { left: 100%; }
}
