/* Conversations History Page Styles */

.page-content {
    padding: 12px 16px;
    max-width: none;
}

/* Page Header - compact toolbar */
.page-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.page-toolbar h1 {
    font-size: 16px;
    margin: 0;
    white-space: nowrap;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.active-filter-count {
    font-size: 11px;
    color: #00d4ff;
    background: #00d4ff15;
    border: 1px solid #00d4ff40;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    white-space: nowrap;
}

.btn-toggle-filters {
    background: #16213e;
    border: 1px solid #333;
    color: #00d4ff;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-toggle-filters:hover {
    background: #1a1a3e;
    border-color: #00d4ff40;
}

.btn-toggle-filters.active {
    background: #00d4ff15;
    border-color: #00d4ff60;
}

/* Filter Panel - collapsible */
.filter-panel {
    margin-bottom: 8px;
    padding: 12px;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-end;
}

.filter-row + .filter-row {
    margin-top: 8px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    min-width: 120px;
    flex: 1;
}

.filter-group label {
    font-size: 10px;
    color: #666;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group input,
.filter-group select {
    padding: 5px 8px;
    font-size: 12px;
}

.filter-group input[type="date"] {
    color-scheme: dark;
}

.filter-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.filter-actions button {
    padding: 5px 14px;
    font-size: 12px;
}

/* Loading State */
.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #333;
    border-top-color: #00d4ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 16px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty State */
.empty-icon {
    font-size: 36px;
    margin-bottom: 8px;
}

.small {
    font-size: 12px;
}

/* Conversations Table - compact, dense */
.table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    padding: 0;
}

.conversations-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.conversations-table thead {
    background: #0f0f23;
    position: sticky;
    top: 0;
    z-index: 1;
}

.conversations-table th {
    padding: 6px 10px;
    text-align: left;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 1px solid #333;
}

.conversations-table td {
    padding: 5px 10px;
    border-bottom: 1px solid #16213e;
    color: #ccc;
    white-space: nowrap;
}

.conversations-table tbody tr {
    cursor: pointer;
    transition: background 0.1s;
}

.conversations-table tbody tr:hover {
    background: #1a1a3e;
}

/* Badges - compact */
.badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-channel {
    background: #1a1a2e;
    border: 1px solid #333;
}

.badge-channel.inbound { color: #00d4ff; border-color: #00d4ff40; }
.badge-channel.outbound { color: #ffa502; border-color: #ffa50240; }
.badge-channel.web { color: #2ed573; border-color: #2ed57340; }

.badge-status {
    background: #1a1a2e;
    border: 1px solid #333;
}

.badge-status.ended { color: #2ed573; border-color: #2ed57340; }
.badge-status.active { color: #ffa502; border-color: #ffa50240; }
.badge-status.created { color: #888; border-color: #88888840; }
.badge-status.error { color: #ff4757; border-color: #ff475740; }

.user-identifier {
    font-family: monospace;
    color: #00d4ff;
    font-size: 11px;
}

.cell-room {
    font-family: monospace;
    font-size: 11px;
    color: #888;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cell-phone {
    font-family: monospace;
    font-size: 11px;
    color: #ddd;
}

.cell-muted {
    color: #666;
    font-size: 11px;
}

.cell-mono {
    font-family: monospace;
    font-size: 11px;
}

.cell-warn {
    font-family: monospace;
    font-size: 11px;
    color: #ffa502;
}

.cell-reason {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: default;
}

.error-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #ff4757;
    border-radius: 50%;
    vertical-align: middle;
    margin-left: 2px;
}

.badge-terminated {
    font-size: 11px;
    color: #888;
}

.badge-terminated.user { color: #00d4ff; }
.badge-terminated.agent { color: #2ed573; }
.badge-terminated.system { color: #ffa502; }
.badge-terminated.error { color: #ff4757; }

/* Pagination - compact */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding: 6px;
}

.pagination button {
    padding: 4px 12px;
    font-size: 12px;
    background: #333;
    color: #eee;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.pagination button:hover:not(:disabled) {
    background: #444;
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination .page-info {
    font-size: 12px;
    color: #888;
}

/* Error Messages */
.error-message {
    background: #ff4757;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 13px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    width: 100%;
    max-width: 850px;
    max-height: 88vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #333;
}

.modal-header h3 {
    font-size: 15px;
    color: #00d4ff;
}

.btn-close {
    background: none;
    border: none;
    color: #888;
    font-size: 22px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.btn-close:hover {
    color: #eee;
}

/* Tabs */
.detail-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid #333;
    margin-bottom: 12px;
}

.detail-tabs button {
    background: none;
    border: none;
    color: #888;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    transition: all 0.2s;
}

.detail-tabs button:hover {
    color: #eee;
}

.detail-tabs button.active {
    color: #00d4ff;
    border-bottom-color: #00d4ff;
}

.tab-content {
    display: none;
}

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

/* Detail Grid */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.detail-item.full-width {
    grid-column: 1 / -1;
}

.detail-label {
    font-size: 10px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    font-size: 13px;
    color: #eee;
    word-break: break-word;
}

.detail-value.mono {
    font-family: monospace;
    font-size: 12px;
}

.detail-section {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #333;
}

.detail-section-title {
    font-size: 11px;
    color: #00d4ff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    font-weight: 600;
}

/* Transcript */
.transcript {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 450px;
    overflow-y: auto;
    padding: 4px;
}

.message-bubble {
    max-width: 80%;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.4;
}

.message-bubble.user {
    align-self: flex-start;
    background: #1a2a4a;
    border-bottom-left-radius: 2px;
}

.message-bubble.assistant,
.message-bubble.agent {
    align-self: flex-end;
    background: #0f3a2e;
    border-bottom-right-radius: 2px;
}

.message-bubble.system {
    align-self: center;
    background: #2a2a3e;
    font-size: 12px;
    color: #888;
    font-style: italic;
}

.message-role {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1px;
}

.message-bubble.user .message-role { color: #00d4ff; }
.message-bubble.assistant .message-role,
.message-bubble.agent .message-role { color: #2ed573; }
.message-bubble.system .message-role { color: #888; }

.message-text {
    color: #ddd;
    white-space: pre-wrap;
    word-break: break-word;
}

.message-meta {
    font-size: 10px;
    color: #666;
    margin-top: 3px;
    display: flex;
    gap: 8px;
}

.message-interrupted {
    color: #ffa502;
    font-size: 10px;
    font-weight: 600;
}

/* Telephony Detail */
.telephony-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Responsive */
@media (max-width: 768px) {
    .page-content {
        padding: 8px;
    }

    .page-toolbar {
        flex-wrap: wrap;
    }

    .filter-row {
        flex-direction: column;
    }

    .filter-group {
        min-width: 100%;
    }

    .detail-grid,
    .telephony-grid {
        grid-template-columns: 1fr;
    }

    .detail-item.full-width {
        grid-column: 1;
    }

    .modal-content {
        max-height: 92vh;
    }

    .message-bubble {
        max-width: 92%;
    }
}

/* --- Recordings Tab --- */

.rec-track-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rec-track-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: #0f0f23;
    border-radius: 8px;
    transition: background 0.2s;
}

.rec-track-item:hover {
    background: #1a1a3e;
}

.rec-track-info {
    flex: 1;
    min-width: 0;
}

.rec-track-name {
    font-weight: 500;
    font-size: 13px;
    color: #eee;
    margin-bottom: 3px;
}

.rec-track-meta {
    display: flex;
    gap: 10px;
    font-size: 11px;
    color: #888;
}

.rec-track-format {
    background: #333;
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 600;
    font-size: 10px;
}

.rec-track-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.rec-btn-play {
    background: #00d4ff;
    color: #000;
    padding: 5px 14px;
    border: none;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.rec-btn-play:hover {
    background: #00b8e6;
}

.rec-btn-download {
    background: #333;
    color: #eee;
    padding: 5px 14px;
    border: none;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}

.rec-btn-download:hover {
    background: #444;
}

.rec-section-title {
    font-size: 10px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 10px;
    margin-bottom: 6px;
}

/* Inline player (shown below track when playing) */
.rec-inline-player {
    padding: 8px 12px;
    background: #0a0a1a;
    border-radius: 0 0 8px 8px;
    margin-top: -6px;
    border-top: 1px solid #1e1e3a;
}

.rec-inline-player audio {
    width: 100%;
    height: 32px;
}

.rec-inline-player audio::-webkit-media-controls-panel {
    background: #0a0a1a;
}

.rec-inline-player audio::-webkit-media-controls-current-time-display,
.rec-inline-player audio::-webkit-media-controls-time-remaining-display {
    color: #eee;
}
