/* Google Fonts - JetBrains Mono and Fira Code */
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* Catppuccin Mocha Color Palette (Dark - Default) */
:root, [data-theme="dark"] {
    --ctp-rosewater: #f5e0dc;
    --ctp-flamingo: #f2cdcd;
    --ctp-pink: #f5c2e7;
    --ctp-mauve: #cba6f7;
    --ctp-red: #f38ba8;
    --ctp-maroon: #eba0ac;
    --ctp-peach: #fab387;
    --ctp-yellow: #f9e2af;
    --ctp-green: #a6e3a1;
    --ctp-teal: #94e2d5;
    --ctp-sky: #89dceb;
    --ctp-sapphire: #74c7ec;
    --ctp-blue: #89b4fa;
    --ctp-lavender: #b4befe;
    --ctp-text: #cdd6f4;
    --ctp-subtext1: #bac2de;
    --ctp-subtext0: #a6adc8;
    --ctp-overlay2: #9399b2;
    --ctp-overlay1: #7f849c;
    --ctp-overlay0: #6c7086;
    --ctp-surface2: #585b70;
    --ctp-surface1: #45475a;
    --ctp-surface0: #313244;
    --ctp-base: #1e1e2e;
    --ctp-mantle: #181825;
    --ctp-crust: #11111b;
}

/* Catppuccin Latte Color Palette (Light) */
[data-theme="light"] {
    --ctp-rosewater: #dc8a78;
    --ctp-flamingo: #dd7878;
    --ctp-pink: #ea76cb;
    --ctp-mauve: #8839ef;
    --ctp-red: #d20f39;
    --ctp-maroon: #e64553;
    --ctp-peach: #fe640b;
    --ctp-yellow: #df8e1d;
    --ctp-green: #40a02b;
    --ctp-teal: #179299;
    --ctp-sky: #04a5e5;
    --ctp-sapphire: #209fb5;
    --ctp-blue: #1e66f5;
    --ctp-lavender: #7287fd;
    --ctp-text: #4c4f69;
    --ctp-subtext1: #5c5f77;
    --ctp-subtext0: #6c6f85;
    --ctp-overlay2: #7c7f93;
    --ctp-overlay1: #8c8fa1;
    --ctp-overlay0: #9ca0b0;
    --ctp-surface2: #acb0be;
    --ctp-surface1: #bcc0cc;
    --ctp-surface0: #ccd0da;
    --ctp-base: #eff1f5;
    --ctp-mantle: #e6e9ef;
    --ctp-crust: #dce0e8;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--ctp-base);
    color: var(--ctp-text);
    height: 100vh;
    padding: 0;
    overflow: hidden;
}

.container {
    width: 100%;
    height: 100vh;
    margin: 0;
    background: var(--ctp-base);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Main Layout - Flexbox for content + sidebar */
.main-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: margin-right 0.3s ease;
}

/* Settings Sidebar */
.settings-sidebar {
    position: fixed;
    top: 60px;
    right: 0;
    bottom: 0;
    width: 0;
    overflow: hidden;
    background: var(--ctp-mantle);
    transition: width 0.3s ease;
    z-index: 100;
}

.settings-sidebar.active {
    width: 330px;
}

.settings-sidebar > * {
    min-width: 330px;
}

/* Push content when sidebar is open */
body.sidebar-open .main-content {
    margin-right: 330px;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 16px;
    border-bottom: 1px solid var(--ctp-surface0);
    font-weight: 600;
    color: var(--ctp-text);
}

.sidebar-close {
    background: none;
    border: none;
    color: var(--ctp-subtext0);
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}

.sidebar-close:hover {
    background: var(--ctp-surface0);
    color: var(--ctp-text);
}

header {
    background: var(--ctp-mantle);
    color: var(--ctp-text);
    padding: 10px;
    text-align: center;
    position: relative;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-logo {
    position: absolute;
    left: 16px;
    height: 40px;
    width: auto;
}

header h1 {
    font-size: 2em;
    margin-bottom: 0;
    color: var(--ctp-lavender);
}

.tabs {
    display: flex;
    gap: 4px;
    background: var(--ctp-crust);
    padding: 8px 8px 0 8px;
    border-bottom: 1px solid var(--ctp-surface0);
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

.tab {
    padding: 8px 20px;
    background: var(--ctp-surface0);
    color: var(--ctp-subtext0);
    border: none;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    min-width: 100px;
    text-align: center;
}

.tab:hover {
    background: var(--ctp-surface1);
    color: var(--ctp-text);
}

.tab.active {
    background: var(--ctp-mantle);
    color: var(--ctp-mauve);
    border-top: 2px solid var(--ctp-mauve);
}

.tab-status {
    font-size: 12px;
    margin-right: 4px;
}

.tab-content {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.tab-content.active {
    display: flex;
    position: relative;
    z-index: 1;
}

.controls {
    padding: 8px 8px;
    background: var(--ctp-mantle);
    border-bottom: 1px solid var(--ctp-surface0);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.controls-left {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.controls-right {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.db-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.status-indicator {
    font-size: 15px;
}

.status-text {
    color: var(--ctp-subtext0);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
}

.control-group.flex-grow {
    flex: 1;
}

label {
    font-weight: 600;
    color: var(--ctp-subtext0);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input, select, button {
    padding: 8px 12px;
    border: 1px solid var(--ctp-surface2);
    border-radius: 2px;
    font-size: 14px;
    font-weight: 600;
    background: var(--ctp-surface0);
    color: var(--ctp-text);
    box-sizing: border-box;
    height: 32px;
    transition: all 0.3s;
}

input[type="text"] {
    min-width: 160px;
}

#topicFilter {
    min-width: 280px;
}

#brokerTopicFilter {
    min-width: 280px;
}

#customQuery {
    min-width: 760px;
    flex: 1;
}

select {
    min-width: 64px;
}

input[type="text"]:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--ctp-mauve);
    box-shadow: 0 0 0 2px rgba(203, 166, 247, 0.2);
}

button {
    background: var(--ctp-mauve);
    color: var(--ctp-crust);
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

button:hover {
    background: var(--ctp-lavender);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

button:disabled {
    background: var(--ctp-surface2);
    cursor: not-allowed;
    transform: none;
}

.btn-active {
    background: var(--ctp-green) !important;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.stats {
    padding: 20px 30px;
    background: var(--ctp-crust);
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--ctp-surface0);
}

.stat-box {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat-label {
    font-size: 12px;
    color: var(--ctp-overlay1);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: var(--ctp-blue);
}

.content {
    padding: 0 8px 8px 8px;
    flex: 1;
    min-height: 0;
    overflow: auto;
}

.query-builder {
    margin-bottom: 16px;
    padding: 16px;
    background: var(--ctp-mantle);
    border-radius: 2px;
    border: 1px solid var(--ctp-surface0);
}

.query-builder label {
    color: var(--ctp-text);
}

textarea {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--ctp-surface2);
    border-radius: 2px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    resize: vertical;
    min-height: 95px;
    background: var(--ctp-surface0);
    color: var(--ctp-text);
}

.error {
    background: var(--ctp-red);
    color: var(--ctp-crust);
    padding: 14px;
    border-radius: 2px;
    margin-bottom: 16px;
    border: 1px solid var(--ctp-maroon);
    font-size: 14px;
}

.success {
    background: var(--ctp-green);
    color: var(--ctp-crust);
    padding: 14px;
    border-radius: 2px;
    margin-bottom: 16px;
    border: 1px solid var(--ctp-teal);
    font-size: 14px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0;
    background: var(--ctp-mantle);
    border-radius: 2px;
    overflow: hidden;
    font-family: var(--table-font, 'JetBrains Mono', monospace);
}

th, td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid var(--ctp-surface0);
    font-size: 14px;
    line-height: 20px;
    height: 36px;
    box-sizing: border-box;
}

th {
    background: var(--ctp-surface0);
    color: var(--ctp-mauve);
    font-weight: 600;
    position: sticky;
    top: 0;
    padding: 6px 8px;
    z-index: 100;
}

tr:hover {
    background: var(--ctp-surface0);
}

td:first-child {
    color: var(--ctp-subtext1);
}

.timestamp {
    color: var(--ctp-subtext1);
}

.topic {
    color: var(--ctp-sapphire);
    font-weight: 600;
}

.payload {
    color: var(--ctp-peach);
}

/* Messages table column widths - Database and Broker tabs */
#results table,
#mqtt-messages-table {
    table-layout: fixed;
    width: 100%;
}

#results table th:nth-child(1),
#results table td:nth-child(1),
#mqtt-messages-table th:nth-child(1),
#mqtt-messages-table td:nth-child(1) {
    width: 240px;
}

#results table th:nth-child(2),
#results table td:nth-child(2),
#mqtt-messages-table th:nth-child(2),
#mqtt-messages-table td:nth-child(2) {
    width: 25%;
}

#results table th:nth-child(3),
#results table td:nth-child(3),
#mqtt-messages-table th:nth-child(3),
#mqtt-messages-table td:nth-child(3) {
    width: auto;
}

#results table th:nth-child(4),
#results table td:nth-child(4),
#mqtt-messages-table th:nth-child(4),
#mqtt-messages-table td:nth-child(4) {
    width: 320px;
}

#mqtt-messages-table th:nth-child(5),
#mqtt-messages-table td:nth-child(5) {
    width: 50px;
    text-align: center;
}

#mqtt-messages-table th:nth-child(6),
#mqtt-messages-table td:nth-child(6) {
    width: 80px;
}

#mqtt-messages-table th:nth-child(7),
#mqtt-messages-table td:nth-child(7) {
    width: 80px;
}

/* Copyable cell styling */
.copyable {
    cursor: default;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}

.copyable .cell-text {
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: calc(100% - 28px);
    vertical-align: middle;
}

.copyable .copy-icon {
    display: inline-block;
    margin-left: 6px;
    opacity: 0;
    cursor: pointer;
    font-size: 12px;
    padding: 1px 3px;
    border-radius: 2px;
    background: var(--ctp-surface1);
    transition: opacity 0.15s ease;
    vertical-align: middle;
}

.copyable:hover .copy-icon {
    opacity: 0.7;
}

.copyable .copy-icon:hover {
    opacity: 1;
    background: var(--ctp-surface2);
}

.copyable .copy-icon.copied {
    opacity: 1;
    background: var(--ctp-green);
    color: var(--ctp-base);
}

.ulid {
    color: var(--ctp-overlay0);
}

/* Headers column styling */
.headers {
    color: var(--ctp-overlay0);
}

.header-item {
    white-space: nowrap;
}

.header-name {
    color: var(--ctp-overlay1);
}

.loading {
    text-align: center;
    padding: 38px;
    color: var(--ctp-subtext0);
}

.spinner {
    border: 2px solid var(--ctp-surface0);
    border-top: 2px solid var(--ctp-mauve);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.no-results {
    text-align: center;
    padding: 57px;
    color: var(--ctp-overlay1);
    font-size: 16px;
}

.loading-cell {
    text-align: center;
    padding: 0;
}

.limit-warning {
    background: var(--ctp-surface0);
    border: 1px solid var(--ctp-yellow);
    border-radius: 4px;
    padding: 10px 16px;
    margin-bottom: 12px;
    color: var(--ctp-yellow);
    font-size: 14px;
}

/* Broker tab styles */
.broker-section {
    margin-bottom: 24px;
    flex-shrink: 0;
}

/* ACL tables horizontal layout */
.acl-tables-row {
    display: flex;
    gap: 24px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.acl-tables-row .acl-table-section {
    min-width: 0;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Clients table - 25% width */
.acl-tables-row .acl-table-section:nth-child(1) {
    flex: 2;
}

/* Groups table - 30% width */
.acl-tables-row .acl-table-section:nth-child(2) {
    flex: 2.5;
}

/* Roles & ACLs table - 45% width */
.acl-tables-row .acl-table-section:nth-child(3) {
    flex: 3.5;
}

.acl-tables-row .acl-table-section h3 {
    margin-bottom: 0;
    border-radius: 2px 2px 0 0;
}

.acl-tables-row .acl-table-section .broker-content {
    padding: 0;
    border-radius: 0 0 2px 2px;
    border-top: none;
    max-height: none;
    flex: 1;
    min-height: 0;
    overflow: auto;
}

.broker-section h3 {
    color: var(--ctp-mauve);
    margin-bottom: 12px;
    padding: 8px 12px;
    background: var(--ctp-surface0);
    border-radius: 2px;
    font-size: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.broker-content {
    background: var(--ctp-mantle);
    border: 1px solid var(--ctp-surface0);
    border-radius: 2px;
    padding: 16px;
    max-height: 500px;
    overflow: auto;
}

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

.acl-table th {
    background: var(--ctp-surface1);
    color: var(--ctp-text);
    padding: 8px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    border-bottom: 2px solid var(--ctp-surface2);
}

.acl-table td {
    padding: 8px;
    border-bottom: 1px solid var(--ctp-surface0);
    font-size: 14px;
}

.acl-table tr:hover {
    background: var(--ctp-surface0);
}

/* Roles table column widths */
#roles-table th:first-child,
#roles-table td:first-child {
    width: 240px;
    min-width: 240px;
}

#roles-table th:last-child,
#roles-table td:last-child {
    width: 80px;
    min-width: 80px;
}

#roles-table th:nth-child(2),
#roles-table td:nth-child(2) {
    width: auto;
}

.acl-item {
    padding: 4px 0;
    margin: 2px 0;
    font-size: 12px;
}

/* Collapsible rows for Roles table */
.collapsible-row {
    cursor: pointer;
}

.collapsible-row .acls-cell {
    max-width: 0;
}

.collapsible-row .acls-content {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    max-height: 1.8em;
    transition: max-height 0.3s ease;
}

.collapsible-row .acls-content .acl-item {
    padding: 0;
    margin: 0;
    flex-shrink: 0;
}

.collapsible-row.expanded .acls-content {
    flex-direction: column;
    flex-wrap: nowrap;
    white-space: normal;
    max-height: none;
}

.collapsible-row.expanded .acls-content .acl-item {
    padding: 4px 0;
    margin: 2px 0;
}

.collapsible-row:hover {
    background: var(--ctp-surface0);
}

.acl-allow {
    color: var(--ctp-green);
}

.acl-deny {
    color: var(--ctp-red);
}

/* Default ACL Header Styles */
.default-acl-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.default-acl-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: normal;
}

.acl-permission {
    display: flex;
    align-items: center;
    gap: 8px;
}

.acl-permission-name {
    font-weight: normal;
    font-size: 14px;
    color: var(--ctp-text);
}

.acl-separator {
    color: var(--ctp-overlay0);
    font-weight: 300;
}

.acl-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}

.acl-toggle input {
    display: none;
}

.acl-toggle-slider {
    width: 36px;
    height: 18px;
    background: var(--ctp-red);
    border-radius: 9px;
    position: relative;
    transition: background 0.2s;
}

.acl-toggle-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    background: var(--ctp-base);
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
}

.acl-toggle input:checked + .acl-toggle-slider {
    background: var(--ctp-green);
}

.acl-toggle input:checked + .acl-toggle-slider::before {
    transform: translateX(18px);
}

.acl-toggle .acl-toggle-label.acl-allow {
    display: none;
}

.acl-toggle .acl-toggle-label.acl-deny {
    display: inline;
}

.acl-toggle input:checked ~ .acl-toggle-label.acl-allow {
    display: inline;
}

.acl-toggle input:checked ~ .acl-toggle-label.acl-deny {
    display: none;
}

.json-viewer {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.summary-box {
    display: inline-block;
    padding: 8px 16px;
    background: var(--ctp-surface0);
    border-radius: 2px;
    margin-right: 12px;
    margin-bottom: 12px;
}

.summary-label {
    color: var(--ctp-subtext0);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-value {
    color: var(--ctp-blue);
    font-size: 22px;
    font-weight: bold;
}

/* Checkbox styling for filters */
.checkbox-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.checkbox-label {
    color: var(--ctp-subtext0);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--ctp-mauve);
    cursor: pointer;
}

/* Retain column styling */
td.retained {
    text-align: center;
    width: 70px;
}

.retain-check {
    color: var(--ctp-green);
    font-weight: bold;
    font-size: 14px;
    line-height: 20px;
}

/* Actions column styling */
td.actions {
    text-align: center;
    white-space: nowrap;
    width: 70px;
    vertical-align: middle;
}

/* Broker tab actions column - center aligned for single trash icon */
#mqtt-messages-table td.actions {
    text-align: center;
    width: 60px;
}

.action-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 2px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    height: 32px;
    transition: all 0.3s;
}

.action-btn.create-btn {
    background: var(--ctp-green);
    color: var(--ctp-base);
}

.action-btn.create-btn:hover {
    background: var(--ctp-teal);
}

.action-btn.edit-btn {
    background: var(--ctp-blue);
    color: var(--ctp-base);
    margin-right: 6px;
}

.action-btn.edit-btn:hover {
    background: var(--ctp-sapphire);
}

.action-btn.delete-btn {
    background: var(--ctp-red);
    color: var(--ctp-base);
}

.action-btn.delete-btn:hover {
    background: var(--ctp-maroon);
}

/* Icon buttons for ACL tab (edit/delete) */
.icon-btn {
    background: transparent;
    border: none;
    padding: 4px;
    margin: 0 2px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    height: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    opacity: 0.7;
    border-radius: 2px;
}

.icon-btn:hover {
    opacity: 1;
    transform: scale(1.1);
    background: var(--ctp-surface0);
}

.icon-btn.create-btn {
    color: var(--ctp-green);
    font-weight: bold;
    font-size: 32px;
    padding: 0 4px;
    margin: 0;
    line-height: 1;
}

/* Trash icon button for Broker tab - same style as ACL tab icons */
#mqtt-messages-table .delete-btn {
    background: transparent;
    border: none;
    padding: 4px;
    margin: 0;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    height: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    opacity: 0.7;
    border-radius: 2px;
}

#mqtt-messages-table .delete-btn:hover {
    opacity: 1;
    transform: scale(1.1);
    background: var(--ctp-surface0);
}

/* Vertical separator for controls */
.separator-vertical {
    width: 1px;
    height: 40px;
    background: var(--ctp-surface2);
    margin: 0 8px;
}

/* Publish controls styling */
#publishTopic {
    width: 320px;
}

#publishMessage {
    width: 480px;
}

#publishQos {
    width: 72px;
}

/* Settings Menu */
.settings-wrapper {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000;
}

.settings-btn {
    background: transparent;
    border: none;
    color: var(--ctp-subtext0);
    font-size: 22px;
    cursor: pointer;
    padding: 4px 10px 8px 10px;
    border-radius: 2px;
    transition: background 0.2s, color 0.2s, transform 0.2s;
    position: relative;
    top: 2px;
}

.settings-btn:hover {
    background: var(--ctp-surface0);
    color: var(--ctp-text);
    transform: translateY(-1px);
}

.auth-btn {
    background: transparent;
    border: 1px solid var(--ctp-surface1);
    color: var(--ctp-subtext0);
    font-size: 14px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 2px;
    margin-right: 8px;
    transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.2s;
}

.auth-btn:hover {
    background: var(--ctp-surface0);
    color: var(--ctp-text);
    border-color: var(--ctp-surface2);
    transform: translateY(-1px);
}

.settings-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: -10px;
    margin-top: 14px;
    background: var(--ctp-mantle);
    border: 1px solid var(--ctp-surface1);
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    min-width: 180px;
    z-index: 1000;
    padding: 6px 0;
}

.settings-menu.active {
    display: block;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    color: var(--ctp-text);
    font-size: 14px;
    transition: background 0.15s;
}

.menu-item:not(.menu-item-row):hover {
    background: var(--ctp-surface0);
    cursor: pointer;
}

.menu-item-row {
    justify-content: space-between;
    gap: 16px;
}

.menu-item-row select {
    padding: 6px 10px;
    font-size: 13px;
    min-width: 140px;
}

/* Theme Toggle Slider */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.theme-toggle-label {
    color: var(--ctp-subtext0);
    font-size: 12px;
    min-width: 32px;
    text-align: center;
}

.theme-toggle-label.active {
    color: var(--ctp-text);
    font-weight: 500;
}

.theme-slider {
    position: relative;
    width: 44px;
    height: 22px;
    background: var(--ctp-surface0);
    border-radius: 11px;
    cursor: pointer;
    transition: background 0.3s;
    border: 1px solid var(--ctp-surface2);
}

.theme-slider:hover {
    border-color: var(--ctp-lavender);
}

.theme-slider-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--ctp-lavender);
    border-radius: 50%;
    transition: transform 0.3s;
}

.theme-slider.light .theme-slider-knob {
    transform: translateX(22px);
}

/* Column Toggle Slider (similar to theme toggle) */
.column-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.toggle-label {
    color: var(--ctp-subtext0);
    font-size: 12px;
    min-width: 32px;
    text-align: center;
}

.toggle-label.active {
    color: var(--ctp-text);
    font-weight: 500;
}

.toggle-slider {
    position: relative;
    width: 44px;
    height: 22px;
    background: var(--ctp-surface0);
    border-radius: 11px;
    cursor: pointer;
    transition: background 0.3s;
    border: 1px solid var(--ctp-surface2);
}

.toggle-slider:hover {
    border-color: var(--ctp-lavender);
}

.toggle-slider-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--ctp-lavender);
    border-radius: 50%;
    transition: transform 0.3s;
}

.toggle-slider.on .toggle-slider-knob {
    transform: translateX(22px);
}

.menu-section-title {
    font-size: 11px;
    color: var(--ctp-subtext0);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 12px;
    margin-top: 4px;
}

/* Hide QoS column when toggled */
.hide-qos-column #mqtt-messages-table th:nth-child(5),
.hide-qos-column #mqtt-messages-table td:nth-child(5) {
    display: none;
}

/* Hide Retained column when toggled */
.hide-retained-column #mqtt-messages-table th:nth-child(6),
.hide-retained-column #mqtt-messages-table td:nth-child(6) {
    display: none;
}

.menu-icon {
    width: 20px;
    margin-right: 8px;
    text-align: center;
}

.menu-separator {
    height: 1px;
    background: var(--ctp-surface1);
    margin: 6px 0;
}

/* About Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1001;
    justify-content: center;
    align-items: center;
}

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

.modal-content {
    background: var(--ctp-mantle);
    border-radius: 8px;
    border: 1px solid var(--ctp-surface1);
    min-width: 320px;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    position: relative;
}

#clientModal .modal-content,
#roleModal .modal-content {
    min-width: 560px;
    max-width: 700px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    /* border-bottom: 1px solid var(--ctp-surface0); */
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
    color: var(--ctp-lavender);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--ctp-subtext0);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--ctp-surface0);
    color: var(--ctp-text);
}

.modal-body {
    padding: 20px;
}

/* Confirmation Modal */
.confirm-modal {
    max-width: 720px;
}

.confirm-modal .modal-body p {
    margin: 0 0 20px 0;
    color: var(--ctp-text);
    word-break: break-all;
}

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

.modal-btn {
    padding: 8px 12px;
    border-radius: 2px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    height: 32px;
    transition: all 0.3s;
}

.modal-btn-cancel {
    background: var(--ctp-surface1);
    color: var(--ctp-text);
}

.modal-btn-cancel:hover {
    background: var(--ctp-surface2);
}

.modal-btn-confirm {
    background: var(--ctp-red);
    color: var(--ctp-base);
}

.modal-btn-confirm:hover {
    background: var(--ctp-maroon);
}

.modal-btn-submit {
    background: var(--ctp-green);
    color: var(--ctp-base);
}

.modal-btn-submit:hover {
    background: var(--ctp-teal);
}

.modal-btn-login {
    background: var(--ctp-blue);
    color: var(--ctp-base);
    width: 100%;
}

.modal-btn-login:hover {
    background: var(--ctp-sapphire);
}

/* Login Modal */
.login-modal {
    min-width: 320px;
    max-width: 380px;
}

.login-modal .modal-header {
    justify-content: center;
}

.login-modal .modal-header h2 {
    font-size: 16px;
    color: var(--ctp-text);
    text-align: center;
}

.login-info {
    color: var(--ctp-subtext0);
    font-size: 13px;
    margin: 0 0 16px 0;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--ctp-subtext1);
    font-weight: 500;
    text-transform: none;
    letter-spacing: normal;
}

.form-group input {
    width: 100%;
    padding: 8px 12px;
    background: var(--ctp-surface0);
    border: 1px solid var(--ctp-surface1);
    border-radius: 2px;
    color: var(--ctp-text);
    font-size: 14px;
    font-weight: 600;
    height: 32px;
    box-sizing: border-box;
    transition: all 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--ctp-blue);
    box-shadow: 0 0 0 2px rgba(137, 180, 250, 0.2);
}

.form-group input:disabled {
    background: var(--ctp-surface0);
    color: var(--ctp-overlay1);
    cursor: not-allowed;
}

.form-hint {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: var(--ctp-overlay1);
}

.modal-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px;
    background: var(--ctp-surface0);
    border-radius: 4px;
    max-height: 150px;
    overflow-y: auto;
}

.modal-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--ctp-mantle);
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.modal-checkbox-label:hover {
    background: var(--ctp-surface1);
}

.modal-checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--ctp-blue);
    cursor: pointer;
}

.no-roles {
    color: var(--ctp-overlay1);
    font-style: italic;
}

/* ACL Editor Styles */
.acls-editor {
    background: var(--ctp-surface0);
    border-radius: 4px;
    padding: 8px;
    margin-bottom: 12px;
    max-height: 200px;
    overflow-y: auto;
}

.no-acls {
    color: var(--ctp-overlay1);
    font-style: italic;
    padding: 8px;
    text-align: center;
}

.acl-edit-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: var(--ctp-mantle);
    border-radius: 4px;
    margin-bottom: 4px;
}

.acl-edit-item:last-child {
    margin-bottom: 0;
}

.acl-edit-type {
    font-weight: 500;
    color: var(--ctp-blue);
    min-width: 140px;
}

.acl-edit-topic {
    flex: 1;
    color: var(--ctp-text);
    font-family: 'Fira Code', monospace;
    font-size: 12px;
}

.acl-add-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.acl-add-row select {
    padding: 8px 12px;
    background: var(--ctp-surface0);
    border: 1px solid var(--ctp-surface2);
    border-radius: 2px;
    color: var(--ctp-text);
    font-size: 14px;
    font-weight: 600;
    height: 32px;
    transition: all 0.3s;
}

.acl-add-row input {
    flex: 1;
    padding: 8px 12px;
    background: var(--ctp-surface0);
    border: 1px solid var(--ctp-surface2);
    border-radius: 2px;
    color: var(--ctp-text);
    font-size: 14px;
    font-weight: 600;
    height: 32px;
    transition: all 0.3s;
}

.acl-add-row input:focus,
.acl-add-row select:focus {
    outline: none;
    border-color: var(--ctp-blue);
}

.login-error {
    display: none;
    padding: 10px 12px;
    background: rgba(243, 139, 168, 0.15);
    border: 1px solid var(--ctp-red);
    border-radius: 2px;
    color: var(--ctp-red);
    font-size: 13px;
    margin-bottom: 16px;
}

.remember-me {
    margin-top: 8px;
    margin-bottom: 8px;
}

.remember-me .checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--ctp-text);
    font-weight: normal;
    margin-bottom: 0;
}

.remember-me .checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    margin: 0;
}

.remember-me .checkbox-label span {
    color: var(--ctp-subtext0);
}

.login-modal .modal-buttons {
    margin-top: 32px;
    justify-content: center;
}

.login-modal .modal-buttons button {
    min-width: 120px;
    width: auto;
}

.about-modal {
    text-align: center;
}

.about-modal .modal-header {
    justify-content: flex-start;
}

.about-modal .modal-header .about-logo {
    margin: 0;
}

.about-modal .modal-header .about-logo img {
    max-width: 100px;
    height: auto;
}

.about-modal .modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
}

.about-body {
    padding: 24px 32px;
}

.about-logo {
    margin-bottom: 12px;
}

.about-logo img {
    max-width: 80px;
    height: auto;
}

.about-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--ctp-lavender);
    margin: 0 0 8px 0;
}

.about-version {
    font-size: 14px;
    color: var(--ctp-subtext0);
    margin-bottom: 16px;
}

.about-separator {
    height: 1px;
    background: var(--ctp-surface1);
    margin: 16px 0;
}

.about-info {
    font-size: 13px;
    color: var(--ctp-subtext1);
    line-height: 1.5;
}

.about-info p {
    margin: 0;
}

.about-maintainer {
    display: flex;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    margin-bottom: 12px;
}

.about-label {
    color: var(--ctp-overlay1);
}

.about-value {
    color: var(--ctp-text);
    font-weight: 500;
}

.about-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    margin-bottom: 8px;
}

.about-label {
    color: var(--ctp-overlay1);
}

.about-link {
    color: var(--ctp-sapphire);
    text-decoration: none;
    transition: color 0.2s;
}

.about-link:hover {
    color: var(--ctp-sky);
    text-decoration: underline;
}

.about-shortcuts {
    text-align: left;
    font-size: 12px;
}

.about-shortcuts .about-label {
    margin-bottom: 8px;
    color: var(--ctp-subtext0);
}

.shortcut-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 4px 0;
    color: var(--ctp-subtext1);
}

kbd {
    display: inline-block;
    padding: 2px 6px;
    font-size: 11px;
    font-family: var(--table-font, 'JetBrains Mono', monospace);
    background: var(--ctp-surface0);
    border: 1px solid var(--ctp-surface1);
    border-radius: 4px;
    color: var(--ctp-text);
}

.about-copyright {
    font-size: 12px;
    color: var(--ctp-overlay0);
}

/* Login required message */
.login-required {
    text-align: center;
    padding: 40px 20px;
    color: var(--ctp-subtext0);
    font-style: italic;
}
