/**
 * ReplyBridge Single Ticket View Styles
 * Three-column layout for individual ticket display
 */

/* ========================================
   Ticket Layout
   ======================================== */
.rb-ticket-layout {
    display: flex;
    gap: 0;
    min-height: calc(100vh - 200px);
    width: 100%;
    background: white;
}

/* ========================================
   Left Sidebar
   ======================================== */
.rb-ticket-sidebar {
    width: 280px;
    background: var(--rb-gray-50);
    border-right: 1px solid var(--rb-gray-300);
    padding: var(--rb-spacing-xl);
    overflow-y: auto;
    flex-shrink: 0;
}

.rb-sidebar-section {
    background: white;
    border-radius: 0;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid var(--rb-gray-200);
    overflow: hidden;
}

.rb-sidebar-section:last-child {
    border-bottom: none;
}

.rb-section-title,
.rb-sidebar-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    color: #666;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e0e0e0;
    letter-spacing: 0.5px;
}

.rb-section-title--with-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rb-section-actions {
    margin-left: auto;
    display: inline-flex;
    gap: 6px;
}

.rb-icon-btn {
    border: 1px solid var(--rb-gray-200);
    background: #fff;
    color: var(--rb-gray-600);
    border-radius: 6px;
    padding: 4px 6px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.rb-icon-btn:hover,
.rb-icon-btn:focus {
    color: var(--rb-primary);
    border-color: var(--rb-primary);
    outline: none;
}

/* Ticket Details */
.rb-ticket-details {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rb-detail-row {
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 12px;
}

.rb-detail-row label {
    color: #666;
    font-weight: 500;
    flex: 0 0 80px;
    min-width: 0;
    font-size: 12px;
}

.rb-detail-value {
    color: var(--rb-gray-900);
    text-align: right;
    width: 120px;
    min-width: 120px;
    max-width: 120px;
    padding: 4px 6px;
    border: 1px solid var(--rb-gray-300);
    border-radius: var(--rb-border-radius-sm);
    background: white;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    flex: none;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rb-select-sm {
    width: 120px !important;
    min-width: 120px;
    max-width: 120px;
    padding: 4px 6px;
    border: 1px solid var(--rb-gray-300);
    border-radius: var(--rb-border-radius-sm);
    font-size: var(--rb-font-size-sm);
    background: white;
    cursor: pointer;
    position: relative;
    z-index: 10;
    flex: none;
    box-sizing: border-box;
}

/* Customer Info */
.rb-customer-card,
.rb-profile-card {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
    background: white;
    padding: 12px;
    border-radius: var(--rb-border-radius-lg);
    border: 1px solid var(--rb-gray-200);
}

.rb-customer-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.rb-customer-avatar,
.rb-customer-avatar-lg {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    background: var(--rb-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.rb-customer-avatar-lg {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    font-size: 18px;
    background: linear-gradient(135deg, var(--rb-primary), var(--rb-secondary));
}

.rb-customer-info-main {
    flex: 1;
    min-width: 0;
}

.rb-customer-name-lg {
    font-weight: 600;
    font-size: var(--rb-font-size-base);
    color: var(--rb-gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rb-customer-email,
.rb-customer-phone,
.rb-customer-email-lg {
    font-size: var(--rb-font-size-sm);
    color: var(--rb-gray-600);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rb-customer-details {
    flex: 1;
    min-width: 0;
}

.rb-customer-name {
    font-weight: 600;
    font-size: var(--rb-font-size-base);
    margin-bottom: 2px;
    color: var(--rb-gray-900);
}

.rb-customer-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--rb-gray-200);
}

.rb-stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rb-customer-stats .rb-stat-label {
    font-size: 13px;
    color: var(--rb-gray-700);
}

.rb-customer-stats .rb-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #0073aa;
    line-height: 1.1;
}

.rb-quick-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 15px;
    padding-bottom: 15px;
}

.rb-customer-stat {
    text-align: center;
}

.rb-customer-stat-value {
    font-size: var(--rb-font-size-lg);
    font-weight: 600;
    color: var(--rb-gray-900);
}

.rb-customer-stat-label {
    font-size: var(--rb-font-size-xs);
    color: var(--rb-gray-600);
    text-transform: uppercase;
}

/* ========================================
   Center Content Area
   ======================================== */
.rb-ticket-content {
    flex: 1;
    background: white;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Ticket Header */
.rb-ticket-header {
    padding: 12px 20px;
    border-bottom: 1px solid var(--rb-gray-200);
}

.rb-ticket-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
    gap: 15px;
}

.rb-ticket-meta {
    flex: 1;
    display: flex;
    gap: 25px;
    align-items: center;
}

.rb-ticket-meta-item {
    font-size: 14px;
    color: var(--rb-gray-600);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.rb-ticket-number {
    font-size: var(--rb-font-size-sm);
    color: var(--rb-gray-600);
    margin-bottom: 0;
}

.rb-ticket-subject {
    font-size: var(--rb-font-size-lg, 1.5rem);
    font-weight: 600;
    color: var(--rb-gray-900);
    margin: 0;
    padding: 0;
    line-height: 1.3;
}

.rb-ticket-badges {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.rb-ticket-actions {
    display: flex;
    gap: 8px;
}

/* Timeline Container */
.rb-timeline {
    padding: 0;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.rb-timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--rb-gray-200);
}

.rb-timeline-title {
    font-size: var(--rb-font-size-lg);
    font-weight: 600;
    color: var(--rb-gray-900);
}

.rb-timeline-filters {
    display: flex;
    gap: 8px;
}

.rb-filter-btn {
    padding: 4px 8px;
    background: transparent;
    border: 1px solid var(--rb-gray-300);
    border-radius: var(--rb-border-radius-sm);
    font-size: var(--rb-font-size-xs);
    color: var(--rb-gray-600);
    cursor: pointer;
    transition: all var(--rb-transition);
}

.rb-filter-btn:hover {
    background: var(--rb-gray-100);
}

.rb-filter-btn.active {
    background: var(--rb-primary);
    color: white;
    border-color: var(--rb-primary);
}

/* Timeline Items */
.rb-timeline-container {
    overflow-y: auto;
    padding-right: 10px;
    flex: 1;
    max-height: none;
    min-height: 200px;
}

.rb-timeline-container::-webkit-scrollbar {
    width: 6px;
}

.rb-timeline-container::-webkit-scrollbar-track {
    background: var(--rb-gray-100);
    border-radius: 3px;
}

.rb-timeline-container::-webkit-scrollbar-thumb {
    background: var(--rb-gray-400);
    border-radius: 3px;
}

.rb-timeline-item {
    position: relative;
    padding-left: 40px;
    margin-bottom: 25px;
}

.rb-timeline-item::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 30px;
    bottom: -25px;
    width: 2px;
    background: var(--rb-gray-200);
}

.rb-timeline-item:last-child::before {
    display: none;
}

.rb-timeline-item--new .rb-timeline-bubble {
    animation: rbTimelineHighlight 0.45s ease;
}

.rb-timeline-marker {
    position: absolute;
    left: 8px;
    top: 8px;
    width: 16px;
    height: 16px;
    background: transparent;
    border: 2px solid rgba(148, 163, 184, 0.4);
    border-radius: 50%;
    z-index: 1;
}

.rb-timeline-marker.reply {
    background: var(--rb-primary);
    border-color: var(--rb-primary);
}

.rb-timeline-marker.note {
    background: var(--rb-warning);
    border-color: var(--rb-warning);
}

.rb-timeline-marker.system {
    background: var(--rb-gray-400);
    border-color: var(--rb-gray-400);
}

.rb-timeline-bubble {
    width: 100%;
    max-width: 72%;
    background: var(--rb-gray-50);
    border-radius: var(--rb-border-radius-lg);
    border: 1px solid rgba(148, 163, 184, 0.25);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
    padding: 16px 20px;
}

.rb-timeline-item--agent .rb-timeline-bubble {
    margin-left: auto;
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    color: #1e3a8a;
    border-color: rgba(99, 102, 241, 0.25);
    box-shadow: 0 12px 22px rgba(79, 110, 247, 0.18);
}

.rb-timeline-item--system .rb-timeline-bubble {
    width: 100%;
    max-width: 100%;
    background: #eef2ff;
    border-color: rgba(99, 102, 241, 0.35);
    color: #3730a3;
    padding: 14px 18px;
    box-shadow: none;
    border-left: 4px solid rgba(99, 102, 241, 0.55);
}

.rb-timeline-item--preview .rb-timeline-bubble {
    border: 2px dashed rgba(255, 193, 7, 0.55);
    background: rgba(255, 249, 219, 0.6);
    color: #5f370e;
}

.rb-timeline-bubble--has-highlight {
    background: rgba(255, 244, 229, 0.85);
    border-color: rgba(245, 158, 11, 0.65);
    box-shadow: 0 12px 24px rgba(245, 158, 11, 0.18);
}

.rb-timeline-bubble--has-highlight .rb-timeline-content--preview.is-html {
    color: #7c2d12;
}

.rb-timeline-content--preview.is-html {
    cursor: text;
}

.rb-timeline-bubble--has-highlight .rb-timeline-content--preview .replybridge-notice {
    margin-bottom: 12px;
}

.rb-timeline-bubble--has-highlight .rb-timeline-content--preview .replybridge-notice:last-child {
    margin-bottom: 0;
}

.rb-timeline-content {
    line-height: 1.6;
    font-size: var(--rb-font-size-sm);
}

.rb-timeline-content--agent {
    color: #1e3a8a;
}

.rb-timeline-content--system {
    color: #3730a3;
}

.rb-timeline-content--preview {
    background: transparent;
    color: #5f370e;
    border: none;
}

.rb-timeline-content--agent a,
.rb-timeline-content--agent strong {
    color: inherit;
}

.rb-timeline-meta {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    font-size: var(--rb-font-size-xs);
    margin-bottom: 6px;
    color: var(--rb-gray-500);
}

.rb-timeline-item--agent .rb-timeline-meta {
    flex-direction: row-reverse;
    color: rgba(30, 58, 138, 0.7);
}

.rb-timeline-item--system .rb-timeline-meta {
    justify-content: flex-start;
    font-size: var(--rb-font-size-xxs);
    margin-bottom: 4px;
}

.rb-email-item {
    cursor: pointer;
}

.rb-email-item--selected .rb-timeline-bubble {
    box-shadow: 0 10px 18px rgba(76, 110, 245, 0.18);
    border-color: rgba(76, 110, 245, 0.35);
}

.rb-email-snippet {
    font-size: var(--rb-font-size-xs);
    font-style: italic;
    color: var(--rb-gray-500);
}

.rb-timeline-item--agent .rb-email-snippet {
    color: rgba(255, 255, 255, 0.9);
}

.rb-timeline-empty {
    padding: 24px;
    border-radius: var(--rb-border-radius-lg);
    border: 1px dashed rgba(99, 102, 241, 0.25);
    background: #f8fafc;
    color: var(--rb-gray-500);
    text-align: center;
    font-size: var(--rb-font-size-sm);
}

@keyframes rbTimelineHighlight {
    0% {
        transform: scale(0.98);
        box-shadow: 0 8px 20px rgba(76, 110, 245, 0.28);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 14px 24px rgba(76, 110, 245, 0.18);
    }
}

@keyframes rbTimelineSkeleton {
    0% {
        background-position: 0% 50%;
    }
    100% {
        background-position: 100% 50%;
    }
}

.rb-timeline-attachments {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--rb-gray-200);
}

.rb-attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.rb-attachment {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: white;
    border: 1px solid var(--rb-gray-300);
    border-radius: var(--rb-border-radius);
    font-size: var(--rb-font-size-sm);
    color: var(--rb-gray-700);
    text-decoration: none;
    transition: all var(--rb-transition);
}

.rb-attachment:hover {
    background: var(--rb-gray-100);
    border-color: var(--rb-primary);
}

.replybridge-message-attachments {
    margin-top: 12px;
    padding-top: 8px;
}

.replybridge-attachment-thumbnails {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.replybridge-attachment-thumbnail {
    display: inline-flex;
    width: 72px;
    height: 72px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--rb-gray-200);
    background: var(--rb-gray-50);
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.replybridge-attachment-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.replybridge-attachment-thumbnail:hover {
    transform: scale(1.05);
    border-color: var(--rb-primary);
}

.replybridge-attachment-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.replybridge-attachment-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid var(--rb-gray-200);
    background: var(--rb-gray-50);
    font-size: var(--rb-font-size-xs);
    color: var(--rb-gray-700);
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.replybridge-attachment-link:hover {
    border-color: var(--rb-primary);
    color: var(--rb-primary);
}

.rb-ticket-content .replybridge-attachments-subsection {
    padding: 10px 14px;
    border: 1px solid var(--rb-gray-200);
    border-radius: 0;
    background: var(--rb-gray-50);
    overflow-y: auto;
    display: none;
}

.replybridge-attachments-subsection--compact {
    border-radius: 0 !important;
}

.rb-ticket-content .replybridge-attachments-subsection[data-visible="true"] {
    display: block;
}

.rb-ticket-content .replybridge-attachments-title {
    font-size: var(--rb-font-size-sm);
    font-weight: 600;
    display: flex;
    gap: 6px;
    align-items: center;
    color: var(--rb-gray-800);
    margin-bottom: 8px;
}

.rb-ticket-content .replybridge-attachments-grid {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.replybridge-attachment-item {
    display: inline-flex;
    flex-direction: column;
    width: 80px;
    min-width: 80px;
    text-decoration: none;
    color: inherit;
    gap: 4px;
}

.replybridge-attachment-preview {
    width: 100%;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--rb-gray-200);
    background: var(--rb-gray-100);
}

.replybridge-attachment-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.replybridge-attachment-name {
    font-size: var(--rb-font-size-xs);
    line-height: 1.2;
    color: var(--rb-gray-700);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
}

.rb-attachment-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    padding: 20px;
    overflow-y: auto;
}

.rb-attachment-lightbox.active {
    display: flex;
}

.rb-attachment-lightbox__backdrop {
    position: absolute;
    inset: 0;
}

.rb-attachment-lightbox__dialog {
    position: relative;
    z-index: 1;
    width: min(960px, 90vw);
    height: min(640px, 85vh);
    min-width: 320px;
    min-height: 320px;
    background: #0f172a;
    border-radius: var(--rb-border-radius-xl);
    padding: 18px 22px 16px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.4);
    display: flex;
    flex-direction: column;
    gap: 12px;
    resize: both;
    overflow: visible;
}

.rb-attachment-lightbox__header {
    text-align: center;
    color: #e2e8f0;
    font-weight: 600;
    font-size: var(--rb-font-size-sm);
    padding: 0 24px;
}

.rb-attachment-lightbox__stage {
    position: relative;
    flex: 1;
    background: #0b1220;
    border-radius: var(--rb-border-radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 0;
}

.rb-attachment-lightbox__image-wrap {
    width: 100%;
    height: 100%;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 48px;
    box-sizing: border-box;
}

.rb-attachment-lightbox__image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.1s ease;
    will-change: transform;
    border-radius: var(--rb-border-radius);
}

.rb-attachment-lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(15, 23, 42, 0.7);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    transition: background 0.2s ease;
    z-index: 2;
}

.rb-attachment-lightbox__nav--prev {
    left: 18px;
}

.rb-attachment-lightbox__nav--next {
    right: 18px;
}

.rb-attachment-lightbox__nav:hover {
    background: rgba(59, 130, 246, 0.85);
}

.rb-attachment-lightbox__nav.is-disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

.rb-attachment-lightbox__close {
    position: absolute;
    top: 10px;
    right: 10px;
    border: none;
    background: rgba(15, 23, 42, 0.5);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.rb-attachment-lightbox__close:hover {
    background: rgba(59, 130, 246, 0.85);
}

.rb-attachment-lightbox__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    color: #cbd5f5;
    font-size: var(--rb-font-size-xs);
}

.rb-attachment-lightbox__dimensions {
    min-width: 140px;
}

.rb-attachment-lightbox__zoom-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    color: #fff;
}

.rb-attachment-lightbox__zoom-input {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--rb-border-radius);
    padding: 2px 6px;
    position: relative;
}

.rb-attachment-lightbox__zoom-input input {
    width: 64px;
    background: transparent;
    border: none;
    color: #e2e8f0;
    font-size: var(--rb-font-size-xs);
    outline: none;
    text-align: right;
    padding-right: 16px;
}

.rb-attachment-lightbox__zoom-input input::-webkit-outer-spin-button,
.rb-attachment-lightbox__zoom-input input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.rb-attachment-lightbox__zoom-input input {
    appearance: textfield;
}

.rb-attachment-lightbox__zoom-input span {
    color: #94a3b8;
    font-size: var(--rb-font-size-xs);
}

.rb-attachment-lightbox__zoom-dropdown {
    border: none;
    background: transparent;
    color: #cbd5f5;
    cursor: pointer;
    font-size: 12px;
    padding: 0 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.rb-attachment-lightbox__zoom-dropdown:hover {
    color: #ffffff;
}

.rb-attachment-lightbox__zoom-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    min-width: 100px;
    background: #101a32;
    border: 1px solid rgba(148, 163, 184, 0.4);
    border-radius: var(--rb-border-radius);
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.35);
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 10;
}

.rb-attachment-lightbox__zoom-menu[hidden] {
    display: none !important;
}

.rb-attachment-lightbox__zoom-menu-item {
    border: none;
    background: transparent;
    color: #e2e8f0;
    text-align: left;
    padding: 4px 8px;
    border-radius: var(--rb-border-radius-sm, 4px);
    font-size: var(--rb-font-size-xs);
    cursor: pointer;
}

.rb-attachment-lightbox__zoom-menu-item:hover {
    background: rgba(59, 130, 246, 0.25);
}

.rb-attachment-lightbox__zoom-range {
    min-width: 120px;
}

.rb-attachment-lightbox__zoom-range input[type="range"] {
    width: 160px;
}

.rb-attachment-lightbox__image-wrap::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.rb-attachment-lightbox__image-wrap::-webkit-scrollbar-track {
    background: rgba(148, 163, 184, 0.15);
    border-radius: 999px;
}

.rb-attachment-lightbox__image-wrap::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.7);
    border-radius: 999px;
}

.rb-attachment-lightbox__image-wrap::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.95);
}

.rb-attachment-lightbox__image-wrap {
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.7) rgba(148, 163, 184, 0.15);
}

@media (max-width: 768px) {
    .rb-attachment-lightbox__stage {
        padding: 0;
    }
    .rb-attachment-lightbox__image-wrap {
        padding: 16px 24px;
    }
    .rb-attachment-lightbox__zoom-range {
        display: none;
    }
}

/* Reply Section */
.rb-reply-section {
    background: white;
    border-top: 2px solid var(--rb-gray-300);
    padding: var(--rb-spacing-xl);
}

.rb-reply-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.rb-reply-title {
    font-size: var(--rb-font-size-lg);
    font-weight: 600;
    color: var(--rb-gray-900);
}

.rb-reply-type-toggle {
    display: flex;
    gap: 4px;
    background: var(--rb-gray-100);
    padding: 2px;
    border-radius: var(--rb-border-radius);
}

.rb-reply-type-btn {
    padding: 4px 12px;
    background: transparent;
    border: none;
    border-radius: var(--rb-border-radius-sm);
    font-size: var(--rb-font-size-sm);
    color: var(--rb-gray-600);
    cursor: pointer;
    transition: all var(--rb-transition);
}

.rb-reply-type-btn:hover {
    background: white;
}

.rb-reply-type-btn.active {
    background: white;
    color: var(--rb-primary);
    box-shadow: var(--rb-shadow-sm);
}

.rb-reply-textarea {
    width: 100%;
    min-height: 150px;
    padding: var(--rb-spacing-md);
    border: 1px solid var(--rb-gray-300);
    border-radius: var(--rb-border-radius);
    font-size: var(--rb-font-size-base);
    font-family: inherit;
    resize: vertical;
    margin-bottom: 15px;
    transition: all var(--rb-transition);
}

.rb-reply-textarea:focus {
    outline: none;
    border-color: var(--rb-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.rb-reply-toolbar {
    display: flex;
    gap: 8px;
    padding: 8px 0;
    margin-bottom: 15px;
}

.rb-reply-toolbar .rb-btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

.rb-toolbar-btn {
    padding: 4px 8px;
    background: transparent;
    border: none;
    color: var(--rb-gray-600);
    cursor: pointer;
    border-radius: var(--rb-border-radius-sm);
    transition: all var(--rb-transition);
}

.rb-toolbar-btn:hover {
    background: white;
    color: var(--rb-gray-900);
}

.rb-reply-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.rb-status-indicator {
    display: flex;
    flex-direction: column;
    min-width: 0;
    color: #5c6677;
    position: relative;
}

.rb-status-indicator__badge {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #1d72b8;
    margin-bottom: 2px;
}

.rb-status-indicator__badges {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0;
}

.rb-status-indicator__badges .rb-status-badge {
    font-size: 11px;
    padding: 5px 8px;
}

.rb-status-indicator__arrow {
    font-size: 12px;
    color: #6c7a89;
}

.rb-status-badge.is-interactive {
    cursor: pointer;
    border: none;
    background-image: none;
    box-shadow: none;
}

.rb-status-badge.is-interactive:focus-visible {
    outline: 2px solid #1d72b8;
    outline-offset: 2px;
}

.rb-status-indicator__dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 200px;
    background: #fff;
    border: 1px solid #d7dee9;
    box-shadow: 0 12px 30px rgba(20, 33, 61, 0.18);
    border-radius: 8px;
    padding: 6px;
    margin-top: 8px;
    z-index: 20;
}

.rb-status-indicator__dropdown[hidden] {
    display: none;
}

.rb-status-indicator__dropdown-option {
    width: 100%;
    text-align: left;
    display: block;
    padding: 7px 10px;
    border: none;
    background: transparent;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
    color: #1f2933;
    cursor: pointer;
}

.rb-status-indicator__dropdown-option:hover,
.rb-status-indicator__dropdown-option.is-active {
    background: #eff4ff;
    color: #1d4ed8;
}

.rb-status-indicator__dropdown-empty {
    font-size: 12px;
    color: #6b7280;
    padding: 6px 10px;
}

.rb-reply-options {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    padding: 10px;
    background: var(--rb-gray-50);
    border-radius: var(--rb-border-radius);
}

.rb-reply-option {
    display: flex;
    align-items: center;
    gap: 6px;
}

.rb-reply-option input[type="radio"] {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #94a3b8;
    background: #fff;
    position: relative;
    flex-shrink: 0;
    transition: border-color 0.2s ease;
}

.rb-reply-option input[type="radio"]::after {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: #2271b1;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.rb-reply-option input[type="radio"]:checked {
    border-color: #2271b1;
}

.rb-reply-option input[type="radio"]:checked::after {
    opacity: 1;
}

.rb-reply-option label {
    cursor: pointer;
    font-size: var(--rb-font-size-sm);
}

.rb-status-select {
    width: 140px;
    padding: 4px 8px;
    border: 1px solid var(--rb-gray-300);
    border-radius: var(--rb-border-radius-sm);
    font-size: var(--rb-font-size-sm);
    background: white;
}

.rb-reply-actions {
    display: flex;
    gap: 8px;
}

/* ========================================
   Right Sidebar
   ======================================== */
.rb-ticket-right-sidebar {
    width: 320px;
    background: var(--rb-gray-50);
    border-left: 1px solid var(--rb-gray-300);
    padding: var(--rb-spacing-xl);
    overflow-y: auto;
    flex-shrink: 0;
}

/* Related Tickets */
.rb-related-tickets {
    list-style: none;
}

.rb-related-ticket {
    padding: 10px;
    background: white;
    border: 1px solid var(--rb-gray-200);
    border-radius: var(--rb-border-radius);
    margin-bottom: 8px;
    transition: all var(--rb-transition);
    cursor: pointer;
}

.rb-related-ticket:hover {
    border-color: var(--rb-primary);
    box-shadow: var(--rb-shadow-sm);
}

.rb-related-ticket-id {
    font-weight: 600;
    color: var(--rb-primary);
    font-size: var(--rb-font-size-sm);
}

.rb-related-ticket-subject {
    font-size: var(--rb-font-size-sm);
    color: var(--rb-gray-700);
    margin-top: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.rb-related-list {
    list-style: none;
    padding: 0;
}

.rb-related-item {
    padding: 10px;
    background: white;
    border: 1px solid var(--rb-gray-200);
    border-radius: var(--rb-border-radius);
    margin-bottom: 8px;
    transition: all var(--rb-transition);
    cursor: pointer;
}

.rb-related-item:hover {
    border-color: var(--rb-primary);
    box-shadow: var(--rb-shadow-sm);
}

.rb-related-item:last-child {
    margin-bottom: 0;
}

.rb-related-subject {
    font-size: var(--rb-font-size-sm);
    color: var(--rb-gray-700);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* WooCommerce Order */
.rb-order-card {
    background: white;
    padding: 12px;
    border-radius: var(--rb-border-radius-lg);
    border: 1px solid var(--rb-gray-200);
}

.rb-order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--rb-gray-200);
}

.rb-order-number {
    font-weight: 600;
    color: var(--rb-gray-900);
}

.rb-order-status {
    padding: 3px 8px;
    background: var(--rb-success);
    color: white;
    border-radius: var(--rb-border-radius-sm);
    font-size: var(--rb-font-size-xs);
    font-weight: 600;
}

.rb-order-items {
    font-size: var(--rb-font-size-sm);
}

.rb-order-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.rb-order-total {
    padding-top: 8px;
    border-top: 1px solid var(--rb-gray-200);
    margin-top: 8px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
}

.rb-order-status-row {
    margin: 4px 0 8px;
}

.rb-order-info {
    background: var(--rb-gray-50);
    padding: 12px;
    border-radius: var(--rb-border-radius);
    margin-top: 10px;
}

.rb-info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: var(--rb-font-size-sm);
}

.rb-info-row span:first-child {
    color: var(--rb-gray-600);
}

.rb-order-status {
    display: inline-block;
    padding: 2px 6px;
    background: #ffc107;
    color: #333;
    border-radius: var(--rb-border-radius-sm);
    font-size: var(--rb-font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
}

.rb-order-status.processing {
    background: #ffc107;
    color: #333;
}

.rb-order-status.completed {
    background: var(--rb-success);
    color: white;
}

/* Agent Notes */
.rb-agent-note {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: var(--rb-border-radius-lg);
    padding: 15px;
    margin: 0 0 20px 0;
    position: relative;
    display: none;
    animation: slideDown 0.3s ease;
}

.rb-agent-note.active {
    display: block;
}

.rb-agent-note-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.rb-agent-note-title {
    color: #856404;
    font-weight: 600;
    font-size: var(--rb-font-size-base);
    display: flex;
    align-items: center;
    gap: 8px;
}

.rb-agent-note-content {
    color: #856404;
    line-height: 1.5;
    font-size: var(--rb-font-size-sm);
}

.rb-agent-note-meta {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #ffc107;
    font-size: var(--rb-font-size-xs);
    color: #856404;
    opacity: 0.8;
}

.rb-note-feedback {
    margin-top: 10px;
    padding: 10px 12px;
    background: rgba(255, 249, 219, 0.95);
    border: 1px solid rgba(255, 193, 7, 0.5);
    border-radius: var(--rb-border-radius-sm);
    font-size: var(--rb-font-size-sm);
    color: #7c2d12;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.rb-note-feedback.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.rb-note-btn {
    background: transparent;
    border: 1px solid #856404;
    color: #856404;
    padding: 4px 8px;
    border-radius: var(--rb-border-radius-sm);
    font-size: var(--rb-font-size-xs);
    cursor: pointer;
    transition: all var(--rb-transition);
}

.rb-note-btn:hover {
    background: #856404;
    color: white;
}

.rb-agent-note-actions {
    display: flex;
    gap: 8px;
}

.rb-agent-note-title i {
    font-size: 16px;
}

/* ========================================
   Responsive Single Ticket View
   ======================================== */
@media (max-width: 1200px) {
    .rb-ticket-sidebar {
        width: 250px;
    }
    
    .rb-ticket-right-sidebar {
        width: 280px;
    }
}

@media (max-width: 1024px) {
    .rb-ticket-layout {
        display: grid;
        grid-template-columns: 250px 1fr;
        grid-template-rows: auto 1fr;
    }
    
    .rb-ticket-sidebar {
        grid-column: 1;
        grid-row: 1 / 3;
        width: 100%;
    }
    
    .rb-ticket-content {
        grid-column: 2;
        grid-row: 1;
    }
    
    .rb-ticket-right-sidebar {
        grid-column: 2;
        grid-row: 2;
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--rb-gray-300);
        display: flex;
        flex-wrap: wrap;
        gap: var(--rb-spacing-xl);
    }
    
    .rb-ticket-right-sidebar .rb-sidebar-section {
        flex: 1;
        min-width: 250px;
    }
}

@media (max-width: 768px) {
    /* Single column layout for mobile */
    .rb-ticket-layout {
        display: flex;
        flex-direction: column;
        gap: 0;
    }
    
    .rb-ticket-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--rb-gray-300);
        max-height: none;
        padding: 15px;
    }
    
    .rb-ticket-content {
        width: 100%;
        min-height: auto;
        padding: 15px;
    }
    
    .rb-ticket-right-sidebar {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--rb-gray-300);
        padding: 15px;
        display: block;
    }
    
    .rb-ticket-header {
        padding: 15px;
    }
    
    .rb-ticket-subject {
        font-size: 18px;
    }
    
    .rb-timeline {
        padding: 15px;
    }
    
    .rb-timeline-item {
        padding-left: 30px;
    }
    
    .rb-reply-section {
        padding: 15px;
    }
    
    .rb-reply-footer {
        flex-direction: column;
        align-items: stretch;
    }
    
    .rb-reply-options {
        order: 2;
    }
    
    .rb-reply-actions {
        order: 1;
        justify-content: space-between;
    }
    
    /* Ensure grid properties don't interfere */
    .rb-ticket-sidebar,
    .rb-ticket-content,
    .rb-ticket-right-sidebar {
        grid-column: auto;
        grid-row: auto;
    }
}

/* ========================================
   Agent Note Styles
   ======================================== */
.rb-agent-note {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    padding: 15px;
    margin: 0 0 20px 0;
    position: relative;
    display: none;
    animation: slideDown 0.3s ease;
}

.rb-agent-note.active {
    display: block;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.rb-agent-note-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.rb-agent-note-title {
    color: #856404;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rb-agent-note-title i {
    font-size: 16px;
}

.rb-agent-note-actions {
    display: flex;
    gap: 8px;
}

.rb-note-btn {
    background: none;
    border: none;
    color: #856404;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 3px;
    transition: all 0.2s;
}

.rb-note-btn:hover {
    background: #856404;
    color: white;
}

.rb-note-btn.primary {
    background: #856404;
    color: white;
}

.rb-agent-note-content {
    color: #856404;
    line-height: 1.5;
    font-size: 13px;
}

.rb-agent-note-meta {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #ffc107;
    font-size: 12px;
    color: #856404;
    opacity: 0.8;
}

.rb-sidebar-empty {
    font-size: var(--rb-font-size-sm);
    color: var(--rb-gray-600);
    margin: 0;
}

.rb-order-card .rb-order-meta {
    font-size: var(--rb-font-size-sm);
    color: var(--rb-gray-600);
    margin-top: 4px;
}

.rb-order-items-preview {
    font-size: var(--rb-font-size-sm);
    color: var(--rb-gray-700);
    margin: 8px 0;
}

.rb-order-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.rb-order-thumb-list {
    display: flex;
    gap: 4px;
    margin: 8px 0;
}

.rb-order-thumb-list img {
    width: 32px;
    height: 32px;
    border-radius: var(--rb-border-radius-sm);
    object-fit: cover;
    border: 1px solid var(--rb-gray-200);
    background: var(--rb-gray-50);
}

.rb-order-thumb-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--rb-border-radius-sm);
    background: var(--rb-gray-100);
    color: var(--rb-gray-700);
    font-size: var(--rb-font-size-sm);
    border: 1px dashed var(--rb-gray-300);
}

.rb-order-modal-summary {
    margin-bottom: 16px;
}

.rb-order-modal-summary .rb-order-status {
    margin-right: 8px;
}

.rb-order-modal-summary .rb-order-meta,
.rb-order-selection {
    font-size: var(--rb-font-size-sm);
    color: var(--rb-gray-700);
    margin-top: 4px;
}

.rb-order-modal-items {
    list-style: none;
    padding: 0;
    margin: 0 0 16px 0;
}

.rb-order-modal-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--rb-gray-100);
}

.rb-order-modal-item:last-child {
    border-bottom: none;
}

.rb-order-modal-item img,
.rb-order-modal-thumb {
    width: 44px;
    height: 44px;
    border-radius: var(--rb-border-radius-sm);
    object-fit: cover;
    border: 1px solid var(--rb-gray-200);
    background: var(--rb-gray-50);
}

.rb-order-modal-thumb--fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: var(--rb-font-size-sm);
    color: var(--rb-gray-500);
}

.rb-order-modal-item-info {
    flex: 1;
}

.rb-order-modal-item-meta {
    font-size: var(--rb-font-size-xs);
    color: var(--rb-gray-600);
}

.rb-order-modal-item-total {
    font-weight: 600;
    color: var(--rb-gray-800);
}

.rb-order-selection-chip {
    display: inline-flex;
    align-items: center;
    background: var(--rb-gray-100);
    color: var(--rb-gray-700);
    border-radius: var(--rb-border-radius-sm);
    font-size: var(--rb-font-size-xs);
    padding: 2px 8px;
    margin: 6px 0;
}

.rb-order-selected-total {
    font-size: var(--rb-font-size-base);
    font-weight: 600;
    color: var(--rb-gray-900);
    background: rgba(37, 99, 235, 0.08);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: var(--rb-border-radius);
    padding: 6px 10px;
    margin-top: 6px;
}

.rb-order-full-toggle {
    margin-top: 12px;
}

.rb-order-full-list {
    margin-top: 10px;
}

.rb-order-divider {
    height: 1px;
    background: var(--rb-gray-200);
    margin: 12px 0;
}

.rb-order-list-heading {
    font-size: var(--rb-font-size-sm);
    color: var(--rb-gray-600);
    margin-bottom: 6px;
}

.rb-order-manual-card {
    background: var(--rb-gray-50);
    border: 1px solid var(--rb-gray-200);
    border-radius: var(--rb-border-radius);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rb-order-manual-field {
    display: flex;
    justify-content: space-between;
    font-size: var(--rb-font-size-sm);
    gap: 16px;
}

.rb-order-manual-field span {
    color: var(--rb-gray-600);
}

.rb-order-manual-field strong {
    color: var(--rb-gray-900);
}

.rb-order-manual-notes {
    margin-top: 4px;
    font-size: var(--rb-font-size-sm);
    color: var(--rb-gray-800);
    white-space: pre-line;
}

.rb-order-empty {
    font-size: var(--rb-font-size-sm);
    color: var(--rb-gray-600);
}

.rb-order-view-btn i {
    margin-right: 6px;
}

.rb-sidebar-section.rb-customer-tags-sidebar {
    overflow: visible;
    position: relative;
}
.rb-refund-profile-subblock {
    margin-top: 10px;
}
.rb-refund-profile-card {
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 16px;
    padding: 14px;
    background: rgba(15, 23, 42, 0.02);
}
.rb-refund-profile-card.is-compact {
    padding: 10px;
}
.rb-refund-profile-card--empty {
    border-style: dashed;
    color: #6b7280;
}
.rb-refund-profile-card__status {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}
.rb-refund-profile-card__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
}
.rb-refund-profile-card__list span {
    color: #6b7280;
}
.rb-refund-profile-card__list strong {
    font-weight: 600;
}
.rb-refund-profile-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    border: 1px solid rgba(15, 23, 42, 0.15);
}
