/* PK Student Messages UI */

.pk-wrap {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #333;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
    box-sizing: border-box;
}

.pk-wrap * {
    box-sizing: border-box;
}

/* Header */
.pk-header,
.pk-dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
}

.pk-header h2,
.pk-dashboard-header h1 {
    margin: 0;
    font-weight: 600;
    color: #111;
}

/* Buttons */
.pk-btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.pk-btn-primary {
    background: #000;
    color: #fff;
}

.pk-btn-primary:hover {
    background: #333;
}

.pk-btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    color: #666;
}

.pk-btn-icon:hover {
    color: #000;
}

.pk-table .pk-btn-close:hover {
    color: #d63638;
}

.pk-table .pk-btn-delete:hover {
    color: #d63638;
}

/* Inbox List */
.pk-conversation-item {
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: box-shadow 0.2s;
    border: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pk-conversation-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.pk-conv-info h4 {
    margin: 0 0 5px 0;
    font-size: 16px;
}

.pk-conv-meta {
    font-size: 12px;
    color: #888;
}

.pk-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 600;
}

.pk-badge.open {
    background: #e6f7ff;
    color: #0050b3;
}

.pk-badge.closed {
    background: #f5f5f5;
    color: #8c8c8c;
}

.pk-badge.pending {
    background: #fff7e6;
    color: #d46b08;
}

/* Detail View */
.pk-detail-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.pk-btn-back {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: #666;
}

.pk-messages-container {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    height: 400px;
    overflow-y: auto;
    border: 1px solid #eee;
    margin-bottom: 20px;
}

.pk-message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.pk-message.mine {
    align-items: flex-end;
}

.pk-message.theirs {
    align-items: flex-start;
}

.pk-msg-bubble {
    background: #f0f0f0;
    padding: 10px 15px;
    border-radius: 18px;
    max-width: 70%;
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-wrap;
}

.pk-message.mine .pk-msg-bubble {
    background: #000;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.pk-message.theirs .pk-msg-bubble {
    border-bottom-left-radius: 4px;
}

.pk-msg-meta {
    font-size: 10px;
    color: #999;
    margin-top: 4px;
}

/* Composer */
.pk-composer {
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #eee;
}

.pk-composer textarea {
    width: 100%;
    border: none;
    resize: none;
    height: 60px;
    font-family: inherit;
    outline: none;
}

.pk-composer-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    border-top: 1px solid #f5f5f5;
    padding-top: 10px;
}

/* Modal */
.pk-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.pk-modal.hidden,
.hidden {
    display: none;
}

.pk-modal-content {
    background: #fff;
    padding: 30px;
    border-radius: 12px;
    width: 500px;
    max-width: 90%;
    position: relative;
}

.pk-close {
    position: absolute;
    top: 15px;
    right: 15px;
    cursor: pointer;
    font-size: 20px;
    color: #999;
}

.pk-input-full {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: inherit;
}

/* Dashboard Specifics */
.pk-kpi-row {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

@media (max-width: 1024px) {
    .pk-kpi-row {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 600px) {
    .pk-kpi-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

.pk-closed-notice {
    padding: 20px;
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
    border-radius: 4px;
    text-align: center;
    margin: 20px;
    font-weight: 500;
}

.pk-card {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #eee;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.pk-kpi-alert {
    background-color: #fff1f0;
    border-color: #ffccc7;
}

.pk-kpi-value {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 5px;
}

.pk-kpi-label {
    font-size: 13px;
    color: #666;
}

.pk-analytics-row {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 20px;
    margin-bottom: 30px;
}

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

.pk-table th {
    text-align: left;
    padding: 12px;
    border-bottom: 2px solid #f0f0f0;
    font-size: 13px;
    color: #666;
    cursor: pointer;
}

.pk-table td {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}

.pk-sort-arrow::after {
    content: '↕';
    font-size: 10px;
    margin-left: 5px;
    opacity: 0.3;
}

.pk-table th.asc .pk-sort-arrow::after {
    content: '↑';
    opacity: 1;
}

.pk-table th.desc .pk-sort-arrow::after {
    content: '↓';
    opacity: 1;
}

@media (max-width: 768px) {
    .pk-analytics-row {
        grid-template-columns: 1fr;
    }
}

.pk-chart-subtitle {
    font-size: 13px;
    color: #666;
    font-weight: normal;
    margin: -10px 0 15px 0;
    /* Negative top margin to pull it closer to H3 if needed, or just 0 */
}

/* Table Header Actions */
.pk-table-header {
    margin-bottom: 20px;
}

.pk-table-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

#pk-search {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: inherit;
}

#pk-btn-export {
    margin-left: auto;
}

/* Attachments in Message */
.pk-msg-attachments {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dotted #ccc;
}

.pk-att-link {
    display: inline-block;
    margin-right: 10px;
    color: #0073aa;
    text-decoration: none;
    font-size: 13px;
}

.pk-att-link:hover {
    text-decoration: underline;
}

.pk-message.mine .pk-att-link {
    color: #aaddff;
}

/* Deleted Messages */
.pk-message-deleted .pk-msg-bubble {
    background: #f9f9f9;
    color: #999;
    border: 1px dashed #ccc;
}

.pk-deleted-meta {
    font-size: 11px;
    margin-top: 5px;
    font-style: italic;
    color: #aaa;
}

/* Delete Message Button */
.pk-btn-delete-msg {
    margin-left: 10px;
    cursor: pointer;
    font-size: 16px;
    color: #ccc;
    vertical-align: middle;
    display: none;
    /* Hidden by default, shown on hover */
}

.pk-msg-bubble:hover .pk-btn-delete-msg {
    display: inline-block;
}

.pk-btn-delete-msg:hover {
    color: #ff4d4f;
}

/* Recording UI Improvements */
.pk-record-dot {
    width: 10px;
    height: 10px;
    background-color: #ff4d4f;
    border-radius: 50%;
    display: inline-block;
    animation: pk-pulse 1.5s infinite;
}

@keyframes pk-pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(255, 77, 79, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(255, 77, 79, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(255, 77, 79, 0);
    }
}

#pk-btn-stop-record,
#pk-btn-new-stop-record,
#pk-dashboard-btn-stop-record {
    color: #ff4d4f !important;
    opacity: 1 !important;
}

#pk-btn-stop-record .dashicons,
#pk-btn-new-stop-record .dashicons,
#pk-dashboard-btn-stop-record .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
}

.pk-uploading {
    font-size: 13px;
    color: #666;
    margin: 5px 0;
}

.pk-error-text {
    color: #ff4d4f;
    font-weight: 500;
}