/* CSS Root Variables & Base Reset */
:root {
    --bg-darker: #070a0e;
    --bg-dark: #0d1117;
    --bg-panel: #161b22;
    --bg-hover: #21262d;
    --border-color: #30363d;
    --border-active: #58a6ff;
    
    /* Neon Theme Colors */
    --irc-green: #10b981;
    --irc-green-dim: rgba(16, 185, 129, 0.15);
    --irc-green-glow: 0 0 10px rgba(16, 185, 129, 0.4);
    
    --irc-cyan: #06b6d4;
    --irc-cyan-dim: rgba(6, 182, 212, 0.15);
    --irc-cyan-glow: 0 0 10px rgba(6, 182, 212, 0.4);
    
    --irc-magenta: #ec4899;
    --irc-yellow: #eab308;
    --text-main: #e6edf3;
    --text-muted: #8b949e;
    --text-system: #58a6ff;
    
    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: 'Fira Code', 'Courier New', Courier, monospace;
}

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

body {
    background-color: var(--bg-darker);
    color: var(--text-main);
    font-family: var(--font-ui);
    font-size: 14px;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* App Container */
#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* 1. Header / Status Bar */
.status-bar {
    background-color: var(--bg-dark);
    height: 36px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    font-family: var(--font-mono);
    font-size: 12px;
}

.status-bar .logo {
    font-weight: 700;
    color: var(--irc-green);
    text-shadow: 0 0 8px rgba(16, 185, 129, 0.3);
}

.status-bar .logo .version {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 400;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
}

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

.status-dot.online {
    background-color: var(--irc-green);
    box-shadow: var(--irc-green-glow);
}

.server-info {
    color: var(--text-muted);
}

/* 2. Main Workspace */
.workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebars Base */
aside {
    background-color: var(--bg-dark);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
}

.sidebar-left {
    width: 230px;
}

.sidebar-right {
    width: 230px;
    border-right: none;
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: hidden;
}

.sidebar-right .sidebar-section {
    overflow-y: auto;
    flex: 1;
}

.sidebar-section {
    padding: 12px 0;
}

.sidebar-section h3 {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    padding: 0 15px 6px 15px;
    letter-spacing: 1px;
}

.sidebar-section ul {
    list-style: none;
}

.sidebar-section li {
    padding: 6px 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    transition: all 0.15s ease;
    color: var(--text-muted);
}

.sidebar-section li:hover {
    background-color: var(--bg-hover);
    color: var(--text-main);
}

.sidebar-section li.active {
    background-color: var(--irc-green-dim);
    color: var(--irc-green);
    font-weight: 600;
    border-left: 3px solid var(--irc-green);
    padding-left: 15px;
}

.sidebar-left li.active {
    text-shadow: 0 0 4px rgba(16, 185, 129, 0.2);
}

.prefix {
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.sidebar-section li.active .prefix {
    color: var(--irc-green);
}

/* User List Specific Styles */
#user-list li {
    font-family: var(--font-mono);
    font-size: 12px;
    padding-left: 12px;
    padding-right: 12px;
}

#user-list li span:nth-child(2) {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90px;
}

#user-list .user-badge {
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 3px;
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    margin-left: auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 85px;
}

#user-list li.local-user {
    color: var(--irc-cyan);
}

#user-list li.federated-user {
    color: var(--irc-yellow);
}

/* 3. Center: Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-darker);
    overflow: hidden;
    position: relative;
}

/* Chat Tabs */
.chat-tabs {
    display: flex;
    background-color: var(--bg-dark);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}

.chat-tabs .tab {
    padding: 8px 16px;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
    border-right: 1px solid var(--border-color);
    transition: all 0.15s ease;
}

.chat-tabs .tab:hover {
    background-color: var(--bg-hover);
    color: var(--text-main);
}

.chat-tabs .tab.active {
    background-color: var(--bg-darker);
    color: var(--irc-green);
    border-bottom: 2px solid var(--irc-green);
    font-weight: 600;
}

/* Chat Output area */
.chat-output-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column-reverse; /* Bottom-up feed */
}

.chat-output {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
}

/* Chat Message Styles */
.msg-line {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background-color 0.15s ease;
}

.msg-line:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.msg-line.selected {
    background-color: rgba(6, 182, 212, 0.08) !important;
    border-left: 2px solid var(--irc-cyan);
    padding-left: 2px;
}

.msg-time {
    color: var(--text-muted);
    font-size: 11px;
    user-select: none;
    white-space: nowrap;
    padding-top: 1px;
}

.msg-sender {
    color: var(--irc-cyan);
    font-weight: bold;
    white-space: nowrap;
    cursor: pointer;
}

.msg-sender:hover {
    text-decoration: underline;
}

.msg-content {
    color: var(--text-main);
    word-break: break-word;
    white-space: pre-wrap;
}

.msg-content a {
    color: var(--irc-cyan);
    text-decoration: none;
}

.msg-content a:hover {
    text-decoration: underline;
}

/* Message Types */
.msg-line.system {
    color: var(--text-system);
}
.msg-line.system .msg-content {
    color: var(--text-system);
    font-style: italic;
}

.msg-line.action {
    color: var(--irc-magenta);
}
.msg-line.action .msg-content {
    color: var(--irc-magenta);
    font-style: italic;
}

.msg-line.notice {
    color: var(--irc-yellow);
}
.msg-line.notice .msg-content {
    color: var(--irc-yellow);
}

.msg-line.direct-msg {
    border-left: 2px solid var(--irc-magenta);
    background-color: rgba(236, 72, 153, 0.03);
}

/* Input Bar */
.chat-input-bar {
    background-color: var(--bg-dark);
    border-top: 1px solid var(--border-color);
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-input-bar .prompt {
    font-family: var(--font-mono);
    color: var(--irc-green);
    font-weight: 600;
    user-select: none;
}

.chat-input-bar input {
    flex: 1;
    background-color: var(--bg-darker);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 4px;
    outline: none;
    transition: all 0.2s ease;
}

.chat-input-bar input:focus {
    border-color: var(--irc-green);
    box-shadow: 0 0 5px rgba(16, 185, 129, 0.2);
}

/* 4. Bottom Panel: ActivityPub Monitor */
.bottom-panel {
    background-color: var(--bg-panel);
    height: 230px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.bottom-panel.collapsed {
    display: none !important;
}

.panel-header {
    background-color: var(--bg-dark);
    height: 36px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
}

.panel-header h3 {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--irc-cyan);
    letter-spacing: 1px;
    text-shadow: 0 0 6px rgba(6, 182, 212, 0.2);
}

.panel-actions {
    display: flex;
    gap: 10px;
}

/* Buttons styling */
.btn {
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
}

.btn-primary {
    background-color: var(--irc-cyan);
    color: var(--bg-darker);
}

.btn-primary:hover {
    background-color: #22d3ee;
    box-shadow: var(--irc-cyan-glow);
}

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

.btn-secondary:hover {
    background-color: var(--bg-hover);
}

.panel-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.ap-log-container, .ap-json-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ap-log-container {
    border-right: 1px solid var(--border-color);
}

.ap-log-header {
    background-color: rgba(0, 0, 0, 0.2);
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    padding: 4px 10px;
    border-bottom: 1px solid var(--border-color);
}

.ap-log-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    font-family: var(--font-mono);
    font-size: 11px;
    background-color: rgba(0, 0, 0, 0.15);
}

.log-entry {
    margin-bottom: 4px;
    line-height: 1.4;
    word-break: break-all;
}

.log-entry.system {
    color: var(--text-muted);
}

.log-entry.outbox {
    color: var(--irc-green);
}

.log-entry.inbox {
    color: var(--irc-cyan);
}

.log-entry .timestamp {
    color: #475569;
    margin-right: 5px;
}

/* JSON Viewer */
.json-viewer {
    flex: 1;
    overflow: auto;
    padding: 10px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: #38bdf8;
    background-color: #0b0e14;
    white-space: pre;
}

/* 5. Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.open {
    display: flex;
}

.modal-content {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-active);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    width: 450px;
    max-width: 90vw;
    display: flex;
    flex-direction: column;
    animation: modalSlide 0.2s ease;
}

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

.modal-header {
    background-color: var(--bg-dark);
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top-left-radius: 7px;
    border-top-right-radius: 7px;
}

.modal-header h3 {
    font-size: 14px;
    color: var(--irc-cyan);
}

.close-modal {
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
}

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

.modal-body {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-body label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.modal-body input, .modal-body select, .modal-body textarea {
    background-color: var(--bg-darker);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 8px 10px;
    border-radius: 4px;
    font-family: var(--font-ui);
    font-size: 13px;
    outline: none;
}

.modal-body input:focus, .modal-body select:focus, .modal-body textarea:focus {
    border-color: var(--irc-cyan);
}

.modal-body textarea {
    resize: none;
    font-family: var(--font-mono);
    font-size: 12px;
}

.modal-footer {
    background-color: var(--bg-dark);
    padding: 10px 15px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    border-bottom-left-radius: 7px;
    border-bottom-right-radius: 7px;
}

.field-info {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-darker);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #4f5b66;
}

/* Group Creator Styling */
.group-contact-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-main);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: background-color 0.15s ease;
}

.group-contact-item:hover {
    background-color: var(--bg-hover);
}

.group-contact-item input[type="checkbox"] {
    cursor: pointer;
    accent-color: var(--irc-cyan);
}

/* Landing Page (OAuth Login Splash) */
#landing-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-darker);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.login-card {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), var(--irc-cyan-glow);
    width: 580px;
    max-width: 90vw;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.terminal-header {
    background-color: var(--bg-dark);
    border-bottom: 1px solid var(--border-color);
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.term-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.term-dot.close { background-color: #ff5f56; }
.term-dot.minimize { background-color: #ffbd2e; }
.term-dot.expand { background-color: #27c93f; }

.term-title {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 10px;
}

.login-body {
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.ascii-logo {
    font-family: var(--font-mono);
    font-size: 8px;
    line-height: 1.2;
    color: var(--irc-green);
    text-shadow: var(--irc-green-glow);
    white-space: pre;
    margin-bottom: 5px;
    user-select: none;
}

.login-tagline {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    max-width: 440px;
    line-height: 1.5;
}

.login-form-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    margin-top: 10px;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-row label {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--irc-cyan);
    font-weight: bold;
}

.input-wrapper {
    display: flex;
    background-color: var(--bg-darker);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    transition: border-color 0.2s ease;
}
.input-wrapper:focus-within {
    border-color: var(--irc-cyan);
    box-shadow: 0 0 5px rgba(6, 182, 212, 0.2);
}

.input-prefix {
    padding: 10px 5px 10px 12px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 13px;
    user-select: none;
}

.input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 13px;
    padding: 10px 12px 10px 0;
    outline: none;
}

.btn-glowing {
    background-color: var(--irc-green);
    color: var(--bg-darker);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 700;
    padding: 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
    box-shadow: var(--irc-green-glow);
}

.btn-glowing:hover {
    background-color: #34d399;
    box-shadow: 0 0 15px rgba(52, 211, 153, 0.6);
    transform: translateY(-1px);
}

#auth-status-console {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-darker);
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 11px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.console-title {
    color: var(--irc-cyan);
    font-weight: bold;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 4px;
}

.console-output {
    height: 100px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: left;
    width: 100%;
}

.console-line {
    color: var(--text-muted);
    line-height: 1.4;
}

.console-line.success {
    color: var(--irc-green);
}

.console-line.working {
    color: var(--irc-cyan);
}

/* Autocomplete Popup Styling */
.autocomplete-popup {
    position: absolute;
    bottom: 52px; /* Just above the input bar */
    left: 15px;
    background-color: var(--bg-panel);
    border: 1px solid var(--border-active);
    box-shadow: var(--irc-cyan-glow);
    border-radius: 4px;
    max-height: 180px;
    overflow-y: auto;
    z-index: 1000;
    min-width: 260px;
    display: flex;
    flex-direction: column;
    padding: 4px 0;
}

.autocomplete-item {
    padding: 6px 12px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    transition: background-color 0.1s ease, color 0.1s ease;
}

.autocomplete-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-main);
}

.autocomplete-item.selected {
    background-color: var(--irc-cyan-dim);
    color: var(--irc-cyan);
    font-weight: bold;
    border-left: 2px solid var(--irc-cyan);
    padding-left: 10px;
}

.autocomplete-item .type-badge {
    font-size: 9px;
    color: var(--text-muted);
    background-color: var(--bg-darker);
    padding: 2px 5px;
    border-radius: 3px;
    border: 1px solid var(--border-color);
}
