/**
 * Estilos para el sistema de soporte - Frontend
 * WhatsApp-like chat + 2-column detail layout + Dark mode
 */

/* ========== Variables ========== */
:root {
    --rz-primary: #6366f1;
    --rz-primary-dark: #4f46e5;
    --rz-primary-light: #eef2ff;
    --rz-success: #10b981;
    --rz-success-light: #d1fae5;
    --rz-warning: #f59e0b;
    --rz-warning-light: #fef3c7;
    --rz-danger: #ef4444;
    --rz-danger-light: #fef2f2;
    --rz-info: #3b82f6;
    --rz-info-light: #eff6ff;
    --rz-gray-50: #f9fafb;
    --rz-gray-100: #f3f4f6;
    --rz-gray-200: #e5e7eb;
    --rz-gray-300: #d1d5db;
    --rz-gray-400: #9ca3af;
    --rz-gray-500: #6b7280;
    --rz-gray-600: #4b5563;
    --rz-gray-700: #374151;
    --rz-gray-800: #1f2937;
    --rz-gray-900: #111827;
    --rz-radius: 10px;
    --rz-radius-sm: 6px;
    --rz-radius-lg: 16px;
    --rz-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --rz-shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --rz-shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px rgba(0,0,0,0.04);
    /* Chat colors */
    --rz-chat-outgoing: #dcf8c6;
    --rz-chat-incoming: #ffffff;
    --rz-chat-staff-incoming: #e3f2fd;
    --rz-chat-bg: #e5ddd5;
    --rz-chat-internal: #fff9c4;
    --rz-chat-escalation: #ffecb3;
    /* Surface colors (for dark mode override) */
    --rz-surface: #ffffff;
    --rz-surface-raised: #ffffff;
    --rz-surface-overlay: #f9fafb;
    --rz-text-primary: #111827;
    --rz-text-secondary: #6b7280;
    --rz-text-muted: #9ca3af;
    --rz-border: #e5e7eb;
}

/* ========== Layout principal ========== */
.rz-support {
    width: 100%;
    padding: 1.5rem 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.rz-support__header {
    margin-bottom: 1.5rem;
}

.rz-support__title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    color: var(--rz-text-primary);
}

.rz-support__notice {
    padding: 0.75rem 1rem;
    background: var(--rz-info-light);
    border: 1px solid #bfdbfe;
    border-radius: var(--rz-radius);
    margin-top: 0.75rem;
}

.rz-support__notice p {
    margin: 0;
    font-size: 0.875rem;
    color: #1e40af;
}

/* ========== Botones ========== */
.rz-support__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 1.125rem;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.4;
    border-radius: var(--rz-radius);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.rz-support__btn--primary {
    background: var(--rz-primary);
    color: #fff;
    box-shadow: 0 1px 2px rgba(99, 102, 241, 0.3);
}

.rz-support__btn--primary:hover {
    background: var(--rz-primary-dark);
    color: #fff;
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

.rz-support__btn--secondary {
    background: var(--rz-gray-100);
    color: var(--rz-gray-700);
}

.rz-support__btn--secondary:hover {
    background: var(--rz-gray-200);
    color: var(--rz-gray-900);
}

.rz-support__btn--sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    border-radius: var(--rz-radius-sm);
}

.rz-support__btn--outline {
    background: transparent;
    color: var(--rz-primary);
    border: 1.5px solid var(--rz-primary);
}

.rz-support__btn--outline:hover {
    background: var(--rz-primary);
    color: #fff;
}

.rz-support__btn--send {
    padding: 0.5rem 1.25rem;
    border-radius: 20px;
}

.rz-support__btn--full {
    width: 100%;
}

/* Action buttons con colores semanticos */
.rz-support__btn--action-progress {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #f59e0b;
}
.rz-support__btn--action-progress:hover {
    background: #fde68a;
}

.rz-support__btn--action-waiting {
    background: var(--rz-gray-100);
    color: var(--rz-gray-700);
    border: 1px solid var(--rz-gray-300);
}
.rz-support__btn--action-waiting:hover {
    background: var(--rz-gray-200);
}

.rz-support__btn--action-resolved {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}
.rz-support__btn--action-resolved:hover {
    background: #a7f3d0;
}

.rz-support__btn--action-close {
    background: var(--rz-danger-light);
    color: #991b1b;
    border: 1px solid var(--rz-danger);
}
.rz-support__btn--action-close:hover {
    background: #fecaca;
}

.rz-support__btn--action-escalate {
    background: #fef3c7;
    color: #78350f;
    border: 1px solid #f59e0b;
    font-weight: 700;
}
.rz-support__btn--action-escalate:hover {
    background: #fde68a;
}

/* ========== Tabs (Admin) ========== */
.rz-support__tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--rz-border);
}

.rz-support__tab {
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--rz-text-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s ease;
}

.rz-support__tab:hover {
    color: var(--rz-primary);
    border-bottom-color: var(--rz-gray-300);
}

.rz-support__tab--active {
    color: var(--rz-primary);
    border-bottom-color: var(--rz-primary);
}

/* ========== Formularios ========== */
.rz-support__actions {
    margin-bottom: 1.5rem;
}

.rz-support__form-wrapper {
    padding: 1.5rem;
    background: var(--rz-surface-overlay);
    border: 1px solid var(--rz-border);
    border-radius: var(--rz-radius-lg);
    margin-bottom: 1.5rem;
}

.rz-support__form-wrapper--hidden {
    display: none;
}

.rz-support__form-title {
    font-size: 1.0625rem;
    font-weight: 600;
    margin: 0 0 1rem;
    color: var(--rz-text-primary);
}

.rz-support__form .rz-support__field {
    margin-bottom: 1rem;
}

.rz-support__form label {
    display: block;
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--rz-gray-700);
    margin-bottom: 0.375rem;
}

.rz-support__form input[type="text"],
.rz-support__form select,
.rz-support__form textarea {
    width: 100%;
    max-width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--rz-gray-300);
    border-radius: var(--rz-radius);
    background: var(--rz-surface);
    color: var(--rz-text-primary);
    transition: border-color 0.2s;
}

.rz-support__form input[type="text"]:focus,
.rz-support__form select:focus,
.rz-support__form textarea:focus {
    outline: none;
    border-color: var(--rz-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.rz-support__form textarea {
    min-height: 120px;
    resize: vertical;
}

.rz-support__hint {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.75rem;
    color: var(--rz-text-muted);
}

.rz-support__file-preview {
    margin-top: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.rz-support__form-actions {
    margin-top: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.rz-support__field--checkbox label {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ========== Badges de estado ========== */
.rz-badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    font-size: 0.6875rem;
    font-weight: 700;
    border-radius: 20px;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.rz-badge--open { background: var(--rz-info); color: #fff; }
.rz-badge--in-progress,
.rz-badge--progress { background: var(--rz-warning); color: #fff; }
.rz-badge--waiting { background: var(--rz-gray-500); color: #fff; }
.rz-badge--escalated { background: var(--rz-danger); color: #fff; }
.rz-badge--resolved { background: var(--rz-success); color: #fff; }
.rz-badge--closed { background: #64748b; color: #fff; }
.rz-badge--category { background: var(--rz-primary-light); color: var(--rz-primary); }

/* Prioridad */
.rz-priority {
    display: inline-block;
    padding: 0.1875rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: 4px;
}

.rz-priority--normal { background: var(--rz-gray-100); color: var(--rz-gray-600); }
.rz-priority--high { background: #fef3c7; color: #92400e; }
.rz-priority--urgent { background: #fef2f2; color: #991b1b; font-weight: 700; }

/* ========== Lista de tickets ========== */
.rz-support__list {
    margin-top: 0;
}

.rz-support__list-title {
    font-size: 1.0625rem;
    font-weight: 600;
    margin: 0 0 1rem;
    color: var(--rz-text-primary);
}

.rz-support__empty {
    padding: 2rem;
    text-align: center;
    color: var(--rz-text-secondary);
    background: var(--rz-surface-overlay);
    border-radius: var(--rz-radius);
    border: 1px dashed var(--rz-gray-300);
}

.rz-support__table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--rz-border);
    border-radius: var(--rz-radius-lg);
    background: var(--rz-surface);
    box-shadow: var(--rz-shadow);
}

.rz-tickets-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.rz-tickets-table th,
.rz-tickets-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--rz-border);
}

.rz-tickets-table thead tr {
    background: var(--rz-surface-overlay);
}

.rz-tickets-table th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--rz-text-secondary);
}

.rz-tickets-table__row {
    transition: background-color 0.15s;
}

.rz-tickets-table__row:hover {
    background: var(--rz-surface-overlay);
}

.rz-tickets-table__row:last-child td {
    border-bottom: none;
}

.rz-tickets-table__row--unread {
    background: #fffbeb;
    border-left: 3px solid var(--rz-warning);
}

.rz-tickets-table__row--unread:hover {
    background: #fef3c7;
}

.rz-ticket-subject {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Badge de mensajes no leidos */
.rz-unread-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.rz-new-icon {
    display: inline-block;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #fff;
    font-weight: 800;
    font-size: 0.5625rem;
    padding: 2px 5px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
    animation: pulse-new 2s ease-in-out infinite;
}

@keyframes pulse-new {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.rz-unread-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--rz-danger);
    color: #fff;
    font-weight: 700;
    font-size: 0.6875rem;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    line-height: 1;
}

/* ========== Vista detalle - Navegacion ========== */
.rz-support--detail .rz-support__nav {
    margin-bottom: 1.25rem;
}

.rz-support__back {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: var(--rz-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.rz-support__back:hover {
    color: var(--rz-primary-dark);
}

.rz-support__detail-title {
    font-size: 1.375rem;
    font-weight: 700;
    margin: 0.5rem 0 0;
    color: var(--rz-text-primary);
    line-height: 1.3;
}

.rz-support__detail-id {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--rz-text-muted);
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    margin-left: 0.375rem;
}

/* ========== 2-Column Detail Layout ========== */
.rz-detail-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1.5rem;
    align-items: start;
}

.rz-detail-layout__main {
    min-width: 0; /* prevent grid blowout */
}

.rz-detail-layout__sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: sticky;
    top: 1rem;
}

/* ========== Sidebar Cards ========== */
.rz-sidebar-card {
    background: var(--rz-surface);
    border: 1px solid var(--rz-border);
    border-radius: var(--rz-radius-lg);
    padding: 1.25rem;
    box-shadow: var(--rz-shadow);
}

.rz-sidebar-card__title {
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--rz-text-secondary);
    margin: 0 0 0.875rem;
    padding-bottom: 0.625rem;
    border-bottom: 1px solid var(--rz-border);
}

.rz-sidebar-card__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 1rem;
}

/* Sidebar meta (definition list) */
.rz-sidebar-card__meta {
    margin: 0;
}

.rz-sidebar-card__meta-row {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--rz-gray-100);
}

.rz-sidebar-card__meta-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.rz-sidebar-card__meta-row:first-child {
    padding-top: 0;
}

.rz-sidebar-card__meta-row dt {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--rz-text-muted);
}

.rz-sidebar-card__meta-row dd {
    margin: 0;
    font-size: 0.875rem;
    color: var(--rz-text-primary);
}

.rz-sidebar-card__meta-row dd strong {
    font-weight: 600;
}

.rz-sidebar-card__role {
    display: block;
    font-size: 0.75rem;
    color: var(--rz-text-secondary);
    font-weight: 400;
    margin-top: 0.0625rem;
}

/* Sidebar - Escalation card */
.rz-sidebar-card--escalation {
    border-color: var(--rz-warning);
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
}

.rz-sidebar-card--escalation .rz-sidebar-card__title {
    color: #92400e;
    border-bottom-color: rgba(245, 158, 11, 0.3);
}

.rz-sidebar-card__escalation-reason {
    font-size: 0.875rem;
    color: #78350f;
    line-height: 1.5;
    margin: 0 0 0.5rem;
    white-space: pre-wrap;
}

.rz-sidebar-card__escalation-by,
.rz-sidebar-card__escalation-date {
    display: block;
    font-size: 0.75rem;
    color: #92400e;
}

/* Sidebar - Actions */
.rz-sidebar-card__actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.rz-sidebar-card__divider {
    border: none;
    border-top: 1px solid var(--rz-border);
    margin: 0.25rem 0;
}

/* ========== Legacy Ticket Card (fallback) ========== */
.rz-ticket-card {
    background: var(--rz-surface);
    border: 1px solid var(--rz-border);
    border-radius: var(--rz-radius-lg);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--rz-shadow);
}

.rz-ticket-card__header {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--rz-border);
}

.rz-ticket-card__title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.rz-ticket-card__title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    color: var(--rz-text-primary);
    line-height: 1.3;
}

.rz-ticket-card__id {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--rz-text-muted);
    white-space: nowrap;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.rz-ticket-card__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.rz-ticket-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    margin-bottom: 1rem;
}

.rz-ticket-card__meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.rz-ticket-card__meta-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--rz-text-secondary);
}

.rz-ticket-card__meta-value {
    font-size: 0.875rem;
    color: var(--rz-text-primary);
}

.rz-ticket-card__meta-value small {
    color: var(--rz-text-secondary);
    font-weight: 400;
}

/* Escalacion box */
.rz-ticket-card__escalation {
    display: flex;
    gap: 0.75rem;
    margin: 1rem 0;
    padding: 1rem;
    background: var(--rz-warning-light);
    border: 1px solid var(--rz-warning);
    border-radius: var(--rz-radius);
}

.rz-ticket-card__escalation-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    min-width: 28px;
    background: var(--rz-warning);
    color: #fff;
    font-weight: 800;
    font-size: 1rem;
    border-radius: 50%;
    line-height: 1;
}

.rz-ticket-card__escalation-content {
    flex: 1;
    font-size: 0.875rem;
    color: #78350f;
}

.rz-ticket-card__escalation-content strong {
    display: block;
    margin-bottom: 0.25rem;
}

.rz-ticket-card__escalation-content p {
    margin: 0.25rem 0 0;
    white-space: pre-wrap;
}

.rz-ticket-card__escalation-footer {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: #92400e;
}

/* Action buttons bar */
.rz-ticket-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--rz-border);
}

/* ========== Chat WhatsApp Style ========== */
.rz-chat {
    margin-bottom: 1.25rem;
}

.rz-chat__title {
    font-size: 1.0625rem;
    font-weight: 600;
    margin: 0 0 0.75rem;
    color: var(--rz-text-primary);
}

.rz-chat__messages {
    background: var(--rz-chat-bg);
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23000000' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    border-radius: var(--rz-radius-lg);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 300px;
    max-height: 65vh;
    overflow-y: auto;
}

/* Custom scrollbar for chat */
.rz-chat__messages::-webkit-scrollbar {
    width: 6px;
}
.rz-chat__messages::-webkit-scrollbar-track {
    background: transparent;
}
.rz-chat__messages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
    border-radius: 3px;
}
.rz-chat__messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.25);
}

/* Row de mensaje */
.rz-chat__row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    max-width: 80%;
}

.rz-chat__row--left {
    align-self: flex-start;
}

.rz-chat__row--right {
    align-self: flex-end;
    flex-direction: row-reverse;
}

/* Avatar */
.rz-chat__avatar {
    flex-shrink: 0;
}

.rz-chat__avatar img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* Bubble */
.rz-chat__bubble {
    padding: 0.625rem 0.875rem;
    border-radius: var(--rz-radius-lg);
    position: relative;
    box-shadow: 0 1px 1px rgba(0,0,0,0.08);
    word-break: break-word;
}

.rz-chat__bubble--incoming {
    background: var(--rz-chat-incoming);
    border-bottom-left-radius: 4px;
}

.rz-chat__bubble--outgoing {
    background: var(--rz-chat-outgoing);
    border-bottom-right-radius: 4px;
}

.rz-chat__bubble--incoming.rz-chat__bubble--staff {
    background: var(--rz-chat-staff-incoming);
}

.rz-chat__bubble--internal {
    background: var(--rz-chat-internal);
    border: 1px dashed #e0c800;
}

.rz-chat__bubble--escalation {
    background: var(--rz-chat-escalation);
    border: 1px solid var(--rz-warning);
}

/* Author info */
.rz-chat__author {
    display: flex;
    align-items: baseline;
    gap: 0.375rem;
    margin-bottom: 0.25rem;
}

.rz-chat__name {
    font-weight: 700;
    font-size: 0.8125rem;
    color: var(--rz-gray-800);
}

.rz-chat__bubble--outgoing .rz-chat__name {
    color: #1b5e20;
}

.rz-chat__bubble--incoming.rz-chat__bubble--staff .rz-chat__name {
    color: #1565c0;
}

.rz-chat__role {
    font-size: 0.6875rem;
    color: var(--rz-gray-500);
    font-weight: 500;
}

.rz-chat__bubble--outgoing .rz-chat__role {
    color: #558b2f;
}

/* System badges */
.rz-chat__system-badge {
    display: inline-block;
    padding: 0.1875rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    background: rgba(245, 158, 11, 0.3);
    color: #92400e;
    border-radius: 4px;
    margin-bottom: 0.375rem;
}

.rz-chat__system-badge--internal {
    background: rgba(234, 179, 8, 0.25);
    color: #854d0e;
}

/* Message body */
.rz-chat__body {
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--rz-gray-800);
}

.rz-chat__body p:last-child {
    margin-bottom: 0;
}

.rz-chat__body p:first-child {
    margin-top: 0;
}

/* Time */
.rz-chat__time {
    display: block;
    font-size: 0.6875rem;
    color: var(--rz-gray-400);
    text-align: right;
    margin-top: 0.25rem;
}

/* Attachments in chat */
.rz-chat__attachments {
    margin-top: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.rz-chat__attachment {
    max-width: 180px;
    background: rgba(0,0,0,0.04);
    border-radius: var(--rz-radius);
    overflow: hidden;
}

.rz-chat__attachment img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: var(--rz-radius) var(--rz-radius) 0 0;
}

.rz-chat__attachment-info {
    padding: 0.375rem 0.5rem;
}

.rz-chat__attachment-info a {
    font-size: 0.75rem;
    color: var(--rz-primary);
    text-decoration: none;
    word-break: break-all;
}

.rz-chat__attachment-info a:hover {
    text-decoration: underline;
}

.rz-chat__attachment-info small {
    display: block;
    font-size: 0.6875rem;
    color: var(--rz-text-secondary);
    margin-top: 0.125rem;
}

/* ========== Reply form (bottom bar style) ========== */
.rz-chat__reply {
    background: var(--rz-surface);
    border: 1px solid var(--rz-border);
    border-radius: var(--rz-radius-lg);
    padding: 1rem 1.25rem;
    box-shadow: var(--rz-shadow);
}

.rz-chat__reply-title {
    font-size: 0.9375rem;
    font-weight: 600;
    margin: 0 0 0.75rem;
    color: var(--rz-text-primary);
}

.rz-chat__reply-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.rz-chat__reply-input textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    border: 1px solid var(--rz-gray-300);
    border-radius: var(--rz-radius);
    background: var(--rz-surface-overlay);
    color: var(--rz-text-primary);
    resize: vertical;
    min-height: 60px;
    transition: border-color 0.2s;
    font-family: inherit;
}

.rz-chat__reply-input textarea:focus {
    outline: none;
    border-color: var(--rz-primary);
    background: var(--rz-surface);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.rz-chat__reply-extras {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.rz-chat__reply-attach-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--rz-gray-100);
    color: var(--rz-text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.rz-chat__reply-attach-btn:hover {
    background: var(--rz-gray-200);
    color: var(--rz-primary);
}

.rz-chat__reply-file-input {
    display: none;
}

.rz-chat__reply-internal {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    color: var(--rz-text-secondary);
    cursor: pointer;
    white-space: nowrap;
}

.rz-chat__reply-internal input[type="checkbox"] {
    accent-color: var(--rz-warning);
}

.rz-chat__file-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.rz-chat__file-preview .rz-file-thumb {
    position: relative;
    display: inline-block;
}

.rz-chat__file-preview .rz-file-thumb img {
    max-width: 80px;
    max-height: 80px;
    border-radius: var(--rz-radius-sm);
    border: 1px solid var(--rz-border);
    object-fit: cover;
}

.rz-chat__file-preview .rz-file-thumb__remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    background: var(--rz-danger);
    color: #fff;
    border: 2px solid #fff;
    border-radius: 50%;
    font-size: 0.6875rem;
    line-height: 16px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* ========== Responsive ========== */
@media (max-width: 1024px) {
    .rz-detail-layout {
        grid-template-columns: 1fr 280px;
        gap: 1rem;
    }
}

@media (max-width: 768px) {
    .rz-support {
        padding: 1rem 0;
    }

    /* Stack detail layout to single column on mobile */
    .rz-detail-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .rz-detail-layout__sidebar {
        position: static;
        order: -1; /* Show ticket info above chat on mobile */
    }

    .rz-support__detail-title {
        font-size: 1.125rem;
    }

    .rz-chat__messages {
        max-height: 50vh;
        min-height: 200px;
    }

    .rz-support__table-wrap {
        overflow-x: visible;
    }

    .rz-support__table-wrap .rz-tickets-table,
    .rz-support__table-wrap thead,
    .rz-support__table-wrap tbody,
    .rz-support__table-wrap th,
    .rz-support__table-wrap td,
    .rz-support__table-wrap tr {
        display: block;
    }

    .rz-support__table-wrap thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .rz-support__table-wrap tbody tr {
        border: 1px solid var(--rz-border);
        border-radius: var(--rz-radius);
        margin-bottom: 0.75rem;
        padding: 0.75rem;
        background: var(--rz-surface);
        box-shadow: var(--rz-shadow);
    }

    .rz-support__table-wrap td {
        border: none;
        border-bottom: 1px solid var(--rz-gray-100);
        padding: 0.5rem 0.5rem 0.5rem 40%;
        position: relative;
        text-align: left;
    }

    .rz-support__table-wrap td:last-child {
        border-bottom: none;
    }

    .rz-support__table-wrap td::before {
        content: attr(data-label);
        position: absolute;
        left: 0.75rem;
        width: 35%;
        font-weight: 600;
        font-size: 0.75rem;
        color: var(--rz-text-secondary);
    }

    .rz-support__tabs {
        overflow-x: auto;
    }

    .rz-support__tab {
        padding: 0.625rem 1rem;
        font-size: 0.8125rem;
        white-space: nowrap;
    }

    .rz-ticket-card {
        padding: 1rem;
    }

    .rz-ticket-card__title-row {
        flex-direction: column;
        gap: 0.25rem;
    }

    .rz-ticket-card__title {
        font-size: 1.0625rem;
    }

    .rz-ticket-card__meta {
        gap: 0.75rem;
    }

    .rz-ticket-card__actions {
        gap: 0.375rem;
    }

    .rz-ticket-card__actions .rz-support__btn {
        flex: 1;
        min-width: 0;
        font-size: 0.75rem;
        padding: 0.375rem 0.5rem;
    }

    .rz-chat__row {
        max-width: 92%;
    }

    .rz-chat__messages {
        padding: 0.75rem;
    }

    .rz-chat__reply-extras {
        flex-wrap: wrap;
    }

    .rz-new-icon {
        font-size: 0.5rem;
        padding: 2px 4px;
    }

    .rz-sidebar-card {
        padding: 1rem;
        overflow: hidden;
    }

    .rz-sidebar-card__title {
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 0;
        padding-bottom: 0;
        border-bottom: none;
    }

    .rz-sidebar-card__title::after {
        content: '\25B8';
        font-size: 0.75rem;
        transition: transform 0.2s ease;
        flex-shrink: 0;
        margin-left: 0.5rem;
    }

    /* Collapsed state: hide content below title */
    .rz-sidebar-card > *:not(.rz-sidebar-card__title) {
        display: none;
    }

    /* Expanded state */
    .rz-sidebar-card--expanded > *:not(.rz-sidebar-card__title) {
        display: block;
    }

    .rz-sidebar-card--expanded .rz-sidebar-card__title {
        margin-bottom: 0.875rem;
        padding-bottom: 0.625rem;
        border-bottom: 1px solid var(--rz-border);
    }

    .rz-sidebar-card--expanded .rz-sidebar-card__title::after {
        transform: rotate(90deg);
    }

    .rz-sidebar-card--expanded .rz-sidebar-card__badges {
        display: flex;
    }

    .rz-sidebar-card--expanded .rz-sidebar-card__actions {
        display: flex;
    }
}

/* ========== Dark Mode ========== */
body.dark-mode {
    --rz-primary: #818cf8;
    --rz-primary-dark: #6366f1;
    --rz-primary-light: rgba(99, 102, 241, 0.15);
    --rz-success: #34d399;
    --rz-success-light: rgba(16, 185, 129, 0.15);
    --rz-warning: #fbbf24;
    --rz-warning-light: rgba(245, 158, 11, 0.15);
    --rz-danger: #f87171;
    --rz-danger-light: rgba(239, 68, 68, 0.15);
    --rz-info: #60a5fa;
    --rz-info-light: rgba(59, 130, 246, 0.15);
    --rz-gray-50: #1a1a2e;
    --rz-gray-100: #1e1e33;
    --rz-gray-200: #2a2a40;
    --rz-gray-300: #3a3a50;
    --rz-gray-400: #6b7280;
    --rz-gray-500: #9ca3af;
    --rz-gray-600: #d1d5db;
    --rz-gray-700: #e5e7eb;
    --rz-gray-800: #f3f4f6;
    --rz-gray-900: #f9fafb;
    --rz-surface: #16162a;
    --rz-surface-raised: #1e1e33;
    --rz-surface-overlay: #1a1a2e;
    --rz-text-primary: #f1f5f9;
    --rz-text-secondary: #94a3b8;
    --rz-text-muted: #64748b;
    --rz-border: #2a2a40;
    --rz-shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --rz-shadow-md: 0 4px 6px rgba(0,0,0,0.25), 0 2px 4px rgba(0,0,0,0.2);
    --rz-shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.3), 0 4px 6px rgba(0,0,0,0.2);
    /* Chat dark colors */
    --rz-chat-outgoing: #1a3a2a;
    --rz-chat-incoming: #1e1e33;
    --rz-chat-staff-incoming: #1a2a3d;
    --rz-chat-bg: #0f0f1e;
    --rz-chat-internal: #2a2a1a;
    --rz-chat-escalation: #2d2510;
}

/* Dark mode overrides that can't use variables */
body.dark-mode .rz-support__notice {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.25);
}

body.dark-mode .rz-support__notice p {
    color: #93c5fd;
}

body.dark-mode .rz-badge--open { background: rgba(59, 130, 246, 0.8); }
body.dark-mode .rz-badge--progress,
body.dark-mode .rz-badge--in-progress { background: rgba(245, 158, 11, 0.8); }
body.dark-mode .rz-badge--waiting { background: rgba(107, 114, 128, 0.8); }
body.dark-mode .rz-badge--escalated { background: rgba(239, 68, 68, 0.8); }
body.dark-mode .rz-badge--resolved { background: rgba(16, 185, 129, 0.8); }
body.dark-mode .rz-badge--closed { background: rgba(100, 116, 139, 0.8); }
body.dark-mode .rz-badge--category {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
}

body.dark-mode .rz-priority--normal { background: rgba(107, 114, 128, 0.2); color: #9ca3af; }
body.dark-mode .rz-priority--high { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
body.dark-mode .rz-priority--urgent { background: rgba(239, 68, 68, 0.2); color: #f87171; }

body.dark-mode .rz-tickets-table__row--unread {
    background: rgba(245, 158, 11, 0.08);
    border-left-color: var(--rz-warning);
}

body.dark-mode .rz-tickets-table__row--unread:hover {
    background: rgba(245, 158, 11, 0.12);
}

/* Dark mode chat bubbles text */
body.dark-mode .rz-chat__name {
    color: #e2e8f0;
}

body.dark-mode .rz-chat__bubble--outgoing .rz-chat__name {
    color: #86efac;
}

body.dark-mode .rz-chat__bubble--incoming.rz-chat__bubble--staff .rz-chat__name {
    color: #93c5fd;
}

body.dark-mode .rz-chat__role {
    color: #64748b;
}

body.dark-mode .rz-chat__bubble--outgoing .rz-chat__role {
    color: #4ade80;
}

body.dark-mode .rz-chat__body {
    color: #e2e8f0;
}

body.dark-mode .rz-chat__time {
    color: #64748b;
}

body.dark-mode .rz-chat__avatar img {
    border-color: #2a2a40;
}

body.dark-mode .rz-chat__bubble--internal {
    border-color: rgba(234, 179, 8, 0.3);
}

body.dark-mode .rz-chat__bubble--escalation {
    border-color: rgba(245, 158, 11, 0.4);
}

body.dark-mode .rz-chat__system-badge {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

body.dark-mode .rz-chat__system-badge--internal {
    background: rgba(234, 179, 8, 0.15);
    color: #facc15;
}

body.dark-mode .rz-chat__attachment {
    background: rgba(255,255,255,0.05);
}

/* Dark mode action buttons */
body.dark-mode .rz-support__btn--action-progress {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.4);
}
body.dark-mode .rz-support__btn--action-progress:hover {
    background: rgba(245, 158, 11, 0.25);
}

body.dark-mode .rz-support__btn--action-waiting {
    background: rgba(107, 114, 128, 0.15);
    color: #9ca3af;
    border-color: rgba(107, 114, 128, 0.4);
}
body.dark-mode .rz-support__btn--action-waiting:hover {
    background: rgba(107, 114, 128, 0.25);
}

body.dark-mode .rz-support__btn--action-resolved {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.4);
}
body.dark-mode .rz-support__btn--action-resolved:hover {
    background: rgba(16, 185, 129, 0.25);
}

body.dark-mode .rz-support__btn--action-close {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.4);
}
body.dark-mode .rz-support__btn--action-close:hover {
    background: rgba(239, 68, 68, 0.25);
}

body.dark-mode .rz-support__btn--action-escalate {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.4);
}
body.dark-mode .rz-support__btn--action-escalate:hover {
    background: rgba(245, 158, 11, 0.25);
}

body.dark-mode .rz-support__btn--outline {
    color: #a5b4fc;
    border-color: #a5b4fc;
}
body.dark-mode .rz-support__btn--outline:hover {
    background: var(--rz-primary);
    color: #fff;
}

body.dark-mode .rz-support__btn--secondary {
    background: rgba(255,255,255,0.06);
    color: #e2e8f0;
}
body.dark-mode .rz-support__btn--secondary:hover {
    background: rgba(255,255,255,0.1);
}

/* Dark mode escalation sidebar card */
body.dark-mode .rz-sidebar-card--escalation {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, rgba(245, 158, 11, 0.15) 100%);
    border-color: rgba(245, 158, 11, 0.35);
}

body.dark-mode .rz-sidebar-card--escalation .rz-sidebar-card__title {
    color: #fbbf24;
    border-bottom-color: rgba(245, 158, 11, 0.2);
}

body.dark-mode .rz-sidebar-card__escalation-reason {
    color: #fde68a;
}

body.dark-mode .rz-sidebar-card__escalation-by,
body.dark-mode .rz-sidebar-card__escalation-date {
    color: #fbbf24;
}

/* Dark mode scrollbar */
body.dark-mode .rz-chat__messages::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
}
body.dark-mode .rz-chat__messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.25);
}

/* Dark mode file preview */
body.dark-mode .rz-chat__file-preview .rz-file-thumb__remove {
    border-color: #1e1e33;
}

/* Dark mode new icon */
body.dark-mode .rz-new-icon {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}
