/* Debug Panel - Candour */
/* Only active when ?debug=1 is in the URL */

#candour-debug-toggle {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 99999;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(20, 20, 30, 0.9);
    color: #00d4ff;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    transition: transform 0.15s, background 0.15s;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    font-family: monospace;
    padding: 0;
    line-height: 1;
}

#candour-debug-toggle:hover {
    transform: scale(1.1);
    background: rgba(30, 30, 45, 0.95);
}

#candour-debug-toggle.active {
    background: rgba(0, 212, 255, 0.15);
    border-color: rgba(0, 212, 255, 0.4);
}

#candour-debug-panel {
    position: fixed;
    bottom: 64px;
    right: 16px;
    z-index: 99998;
    width: 360px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 100px);
    background: rgba(15, 15, 22, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
    font-size: 12px;
    color: #d4d4d8;
    overflow: hidden;
    display: none;
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    flex-direction: column;
}

#candour-debug-panel.open {
    display: flex;
}

/* Panel header - draggable */
.cdp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    cursor: move;
    user-select: none;
    -webkit-user-select: none;
    flex-shrink: 0;
}

.cdp-header-title {
    font-weight: 700;
    font-size: 12px;
    color: #00d4ff;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.cdp-header-page {
    font-size: 11px;
    color: #888;
    font-weight: 400;
}

/* Tabs */
.cdp-tabs {
    display: flex;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    overflow-x: auto;
    scrollbar-width: none;
    flex-shrink: 0;
}

.cdp-tabs::-webkit-scrollbar { display: none; }

.cdp-tab {
    flex-shrink: 0;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 500;
    color: #888;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
    width: auto;
    border-radius: 0;
}

.cdp-tab:hover {
    color: #ccc;
    background: none;
}

.cdp-tab.active {
    color: #00d4ff;
    border-bottom-color: #00d4ff;
    background: none;
}

/* Tab content */
.cdp-body {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    max-height: 400px;
}

.cdp-section {
    display: none;
    padding: 12px 14px;
}

.cdp-section.active {
    display: block;
}

/* Key-value rows */
.cdp-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 5px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    gap: 8px;
}

.cdp-row:last-child {
    border-bottom: none;
}

.cdp-key {
    color: #888;
    font-size: 11px;
    flex-shrink: 0;
}

.cdp-val {
    color: #e4e4e7;
    font-size: 11px;
    text-align: right;
    word-break: break-all;
    max-width: 220px;
}

.cdp-val.cdp-test {
    color: #facc15;
}

.cdp-val.cdp-prod {
    color: #4ade80;
}

/* Section headers within tabs */
.cdp-section-title {
    font-size: 10px;
    font-weight: 700;
    color: #00d4ff;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin: 12px 0 6px;
}

.cdp-section-title:first-child {
    margin-top: 0;
}

/* Database toggle button */
.cdp-db-toggle {
    display: inline-block;
    padding: 6px 12px;
    margin-top: 8px;
    font-size: 11px;
    font-weight: 600;
    font-family: inherit;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    color: #d4d4d8;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    width: auto;
}

.cdp-db-toggle:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
}

/* Request log entries */
.cdp-log-entry {
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.cdp-log-entry:last-child {
    border-bottom: none;
}

.cdp-log-time {
    font-size: 10px;
    color: #666;
    margin-bottom: 2px;
}

.cdp-log-method {
    font-weight: 700;
    color: #00d4ff;
    font-size: 11px;
}

.cdp-log-url {
    font-size: 10px;
    color: #aaa;
    word-break: break-all;
    margin: 2px 0;
}

.cdp-log-status {
    font-size: 11px;
    font-weight: 600;
}

.cdp-log-status.ok {
    color: #4ade80;
}

.cdp-log-status.err {
    color: #f87171;
}

.cdp-log-status.pending {
    color: #facc15;
}

/* Response data display */
.cdp-response-block {
    margin-top: 8px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    max-height: 150px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 10px;
    color: #aaa;
    line-height: 1.4;
}

/* Sentiment display */
.cdp-sentiment-bar {
    height: 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    margin: 8px 0 4px;
    overflow: hidden;
}

.cdp-sentiment-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s, background 0.3s;
}

.cdp-sentiment-label {
    font-size: 11px;
    color: #888;
    margin-top: 2px;
}

/* Empty state */
.cdp-empty {
    color: #555;
    font-size: 11px;
    font-style: italic;
    padding: 8px 0;
}

/* Clear button */
.cdp-clear-btn {
    padding: 4px 10px;
    font-size: 10px;
    font-weight: 600;
    font-family: inherit;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.04);
    color: #888;
    cursor: pointer;
    margin-bottom: 8px;
    width: auto;
}

.cdp-clear-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ccc;
}
