/* Admin Bot Conversations Styles */

/* Conversations Table */
.conversations-table {
    width: 100%;
    border-collapse: collapse;
    background: #2b2d31;
    border-radius: 8px;
    overflow: hidden;
}

.conversations-table th,
.conversations-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #3f4147;
}

.conversations-table th {
    background: #1e1f22;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: #b5bac1;
}

.conversations-table tbody tr {
    cursor: pointer;
}

.conversations-table tbody tr:hover {
    background: #36373d;
}

.conversations-table tbody tr:last-child td {
    border-bottom: none;
}

.user-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-cell .username {
    font-weight: 600;
    color: #fff;
}

.user-cell .user-id {
    font-size: 11px;
    color: #6d6f78;
}

.bot-name {
    color: #5865f2;
    font-weight: 500;
}

.message-count-badge {
    background: #404249;
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}

.time-ago {
    color: #b5bac1;
    font-size: 13px;
}

.fsm-state-badge {
    background: #2d6a4f;
    color: #95d5b2;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

/* Pagination */
.pagination {
    margin-top: 20px;
    display: flex;
    justify-content: center;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-info {
    color: #b5bac1;
    font-size: 14px;
}

/* Split View Layout */
.split-view {
    display: grid;
    grid-template-columns: 1fr auto 420px;
    gap: 0;
    height: calc(100vh - 140px);
    padding: 0 !important;
}

.messages-panel,
.debug-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.messages-panel {
    border-right: none;
}

/* Split Resizer */
.split-resizer {
    width: 6px;
    background: #3f4147;
    cursor: col-resize;
    position: relative;
    flex-shrink: 0;
}

.split-resizer::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 40px;
    background: #6d6f78;
    border-radius: 1px;
}

.split-resizer:hover {
    background: #5865f2;
}

.split-resizer:hover::before {
    background: #fff;
}

.split-resizer.active {
    background: #5865f2;
}

.split-resizer.active::before {
    background: #fff;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #2b2d31;
    border-bottom: 1px solid #3f4147;
}

.panel-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
}

.message-count {
    font-size: 12px;
    color: #b5bac1;
}

/* Messages Timeline */
.messages-timeline {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message-item {
    padding: 12px 16px;
    border-radius: 8px;
    background: #2b2d31;
    border-left: 3px solid #5865f2;
}

.message-item.user-message {
    border-left-color: #3ba55d;
}

.message-item.bot-message {
    border-left-color: #5865f2;
}

.message-item.has-debug {
    cursor: pointer;
}

.message-item.has-debug:hover {
    background: #36373d;
}

.message-item.selected {
    background: #36373d;
    border-left-width: 4px;
    box-shadow: 0 0 0 1px #5865f2;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 13px;
}

.message-sender {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.message-sender.user {
    color: #3ba55d;
}

.message-sender.bot {
    color: #5865f2;
}

.message-time {
    color: #6d6f78;
    font-size: 12px;
    margin-left: auto;
}

.debug-indicator {
    color: #f0b232;
    font-size: 12px;
}

.message-body {
    color: #dbdee1;
}

.message-text {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.5;
}

.message-attachments {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.attachment-image {
    max-width: 200px;
    max-height: 150px;
    border-radius: 6px;
}

.message-quick-meta {
    display: flex;
    gap: 16px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #3f4147;
    font-size: 11px;
    color: #6d6f78;
}

.message-quick-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.message-quick-meta i {
    font-size: 10px;
}

/* Debug Panel */
.debug-panel {
    background: #2b2d31;
}

.debug-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.debug-sections {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.debug-section {
    background: #1e1f22;
    border-radius: 6px;
    overflow: hidden;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: #36373d;
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    color: #fff;
}

.section-header:hover {
    background: #404249;
}

.toggle-icon {
    font-size: 10px;
    color: #b5bac1;
    width: 12px;
}

.section-badge {
    margin-left: auto;
    font-size: 11px;
    color: #b5bac1;
    font-weight: normal;
}

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

.section-content.expanded {
    display: block;
}

.code-block {
    background: #2b2d31;
    padding: 12px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    color: #dbdee1;
    margin: 0;
}

.params-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.param-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.param-item label {
    font-size: 11px;
    text-transform: uppercase;
    color: #6d6f78;
    font-weight: 600;
}

.param-item span {
    font-size: 13px;
    color: #dbdee1;
}

.variables-section {
    margin-top: 12px;
}

.variables-section label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    color: #6d6f78;
    font-weight: 600;
    margin-bottom: 6px;
}

.response-content label,
.tool-calls label,
.transition-info label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    color: #6d6f78;
    font-weight: 600;
    margin-bottom: 6px;
}

.response-content {
    margin-bottom: 12px;
}

.tool-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tool-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #2b2d31;
    border-radius: 4px;
    font-size: 13px;
}

.tool-list li i {
    color: #f0b232;
}

.transition-badge {
    display: inline-block;
    background: #5865f2;
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

/* Message History in Debug */
.message-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-message {
    background: #2b2d31;
    border-radius: 6px;
    padding: 10px 12px;
    border-left: 3px solid #6d6f78;
}

.history-message.system {
    border-left-color: #f0b232;
}

.history-message.user {
    border-left-color: #3ba55d;
}

.history-message.assistant {
    border-left-color: #5865f2;
}

.history-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.history-index {
    font-size: 10px;
    color: #6d6f78;
    font-family: monospace;
}

.history-role {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #b5bac1;
}

.history-content {
    font-size: 12px;
    line-height: 1.4;
    color: #dbdee1;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    max-height: 200px;
    overflow-y: auto;
}

.history-images {
    margin-top: 6px;
    display: flex;
    gap: 6px;
}

.image-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #404249;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    color: #b5bac1;
}

/* Debug Actions */
.debug-actions {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #3f4147;
    display: flex;
    gap: 8px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
}

.modal-container {
    position: relative;
    background: #2b2d31;
    border-radius: 8px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-container.modal-large {
    max-width: 1000px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #3f4147;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #b5bac1;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: #fff;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid #3f4147;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Replay Comparison */
.replay-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.replay-column h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
}

.replay-content {
    background: #1e1f22;
    border-radius: 6px;
    padding: 16px;
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
}

.replay-content .code-block {
    background: transparent;
    padding: 0;
}

.replay-meta {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #3f4147;
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: #b5bac1;
}

.replay-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Conversation Meta in Header */
.conversation-meta {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: #b5bac1;
}

.conversation-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Header adjustments for detail view */
#tab-detail .content-header {
    gap: 16px;
}

#tab-detail .content-header h2 {
    flex: 1;
}

/* Responsive */
@media (max-width: 1200px) {
    .split-view {
        grid-template-columns: 1fr auto 350px;
    }
}

@media (max-width: 900px) {
    .split-view {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr auto 1fr;
    }

    .split-resizer {
        width: 100%;
        height: 6px;
        cursor: row-resize;
    }

    .split-resizer::before {
        width: 40px;
        height: 2px;
    }

    .messages-panel {
        border-right: none;
        border-bottom: none;
    }

    .replay-comparison {
        grid-template-columns: 1fr;
    }
}
