/* ========================================================================== 
   WSLA Phase 06 - Support Tickets
   Scope: ticket list, ticket step one, ticket confirmation, view ticket, feedback.
   Keeps WHMCS/Bootstrap behaviour intact and only normalizes ticket UI.
   ========================================================================== */

.wsla-ticket-page-title,
.wsla-ticket-section-title {
    color: #111827;
    font-size: 22px;
    font-weight: 800;
    line-height: 1.35;
    margin: 0 0 18px;
}

.wsla-ticket-section-title-sm {
    color: #111827;
    font-size: 18px;
    font-weight: 800;
    line-height: 1.35;
    margin: 0 0 14px;
}

.wsla-ticket-muted {
    color: #64748b;
    font-size: 14px;
    line-height: 1.7;
}

/* Ticket list table */
.wsla-ticket-list-card {
    background: #fff !important;
    border: 0 !important;
    box-shadow: none !important;
    border-radius: 18px !important;
    overflow: hidden !important;
}

.wsla-ticket-list-card .dataTables_wrapper { padding: 0 !important; }
.wsla-ticket-list-card table.dataTable {
    width: 100% !important;
    margin: 0 !important;
    border: 0 !important;
    border-collapse: collapse !important;
}
.wsla-ticket-list-card table.dataTable thead th {
    background: #f8fafc !important;
    color: #64748b !important;
    font-size: 13px !important;
    font-weight: 800 !important;
    padding: 15px 20px !important;
    border-bottom: 1px solid #eef2f7 !important;
    text-align: inherit !important;
}
.wsla-ticket-list-card #tableTicketsList tbody tr {
    cursor: pointer !important;
    border-bottom: 1px solid #f1f5f9 !important;
    transition: background-color .18s ease, box-shadow .18s ease !important;
}
.wsla-ticket-list-card #tableTicketsList tbody tr:hover { background: #fbfcfe !important; }
html[dir="rtl"] .wsla-ticket-list-card #tableTicketsList tbody tr:hover,
body.body-rtl .wsla-ticket-list-card #tableTicketsList tbody tr:hover {
    box-shadow: inset -4px 0 0 var(--wsla-orange, #ff8800) !important;
}
html:not([dir="rtl"]) .wsla-ticket-list-card #tableTicketsList tbody tr:hover,
body:not(.body-rtl) .wsla-ticket-list-card #tableTicketsList tbody tr:hover {
    box-shadow: inset 4px 0 0 var(--wsla-orange, #ff8800) !important;
}
.wsla-ticket-list-card #tableTicketsList tbody td {
    padding: 8px 20px !important;
    vertical-align: middle !important;
    border: 0 !important;
    text-align: inherit !important;
}
.wsla-ticket-list-card .ticket-number {
    display: inline-block;
    color: var(--wsla-orange, #ff8800) !important;
    font-size: 15px;
    font-weight: 800;
    margin-bottom: 4px;
}
.wsla-ticket-list-card .ticket-subject {
    color: #334155;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
    margin: 0;
}
.wsla-ticket-list-card .label.status {
    border-radius: 999px !important;
    font-size: 12px !important;
    font-weight: 800 !important;
    padding: 5px 12px !important;
}
.wsla-ticket-list-card td small {
    color: #64748b !important;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px !important;
    white-space: nowrap;
}
.wsla-ticket-list-card .dataTables_info,
.wsla-ticket-list-card .dataTables_paginate {
    padding: 14px 20px !important;
}

/* Step one departments */
.wsla-ticket-search-section {
    padding: 8px 0 20px;
}
.wsla-ticket-search-box {
    position: relative;
}
.wsla-ticket-search-box i {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}
html[dir="rtl"] .wsla-ticket-search-box i,
body.body-rtl .wsla-ticket-search-box i { right: 18px; }
html:not([dir="rtl"]) .wsla-ticket-search-box i,
body:not(.body-rtl) .wsla-ticket-search-box i { left: 18px; }
.wsla-ticket-search-box input {
    width: 100%;
    height: 54px;
    border: 1px solid #d8e0ea;
    border-radius: 14px;
    background: #fff;
    color: #0f172a;
    font-size: 14px;
    font-weight: 600;
    outline: none;
    box-shadow: none;
}
html[dir="rtl"] .wsla-ticket-search-box input,
body.body-rtl .wsla-ticket-search-box input { padding: 0 48px 0 18px; }
html:not([dir="rtl"]) .wsla-ticket-search-box input,
body:not(.body-rtl) .wsla-ticket-search-box input { padding: 0 18px 0 48px; }
.wsla-ticket-dept-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 190px;
    padding: 22px;
    border: 1px solid #eef2f7;
    border-radius: 18px;
    background: #fff;
    color: #1e293b;
    text-decoration: none !important;
    transition: border-color .18s ease, transform .18s ease, background-color .18s ease;
}
.wsla-ticket-dept-card:hover {
    border-color: rgba(255, 136, 0, .35);
    background: #fffdf8;
    color: #1e293b;
    transform: translateY(-2px);
}
.wsla-ticket-dept-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.wsla-ticket-dept-icon {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff4e6;
    color: var(--wsla-orange, #ff8800);
    flex: 0 0 auto;
}
.wsla-ticket-dept-title {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
    color: #111827;
}
.wsla-ticket-dept-desc {
    color: #64748b;
    flex: 1;
    font-size: 14px;
    line-height: 1.75;
    margin: 0 0 18px;
}
.wsla-ticket-dept-action {
    color: var(--wsla-orange, #ff8800);
    font-size: 14px;
    font-weight: 800;
}

/* View ticket */
.wsla-ticket-header-card,
.wsla-ticket-thread-card,
.wsla-ticket-reply-card {
    display: block !important;
    border: 0 !important;
    box-shadow: none !important;
}
.wsla-ticket-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
}
.wsla-ticket-title-number { color: var(--wsla-orange, #ff8800); }
.wsla-ticket-top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.wsla-ticket-top-actions form { display: inline-flex; margin: 0; padding: 0; }
.wsla-ticket-top-actions .btn {
    border-radius: 9px !important;
    font-size: 13px !important;
    font-weight: 800 !important;
    padding: 8px 14px !important;
}
.wsla-ticket-divider {
    border: 0;
    border-top: 1px solid #f1f5f9;
    margin: 20px 0;
}
.wsla-ticket-subject-line {
    color: #334155;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.7;
    margin: 0;
}
.wsla-ticket-subject-line strong { color: #111827; }
.wsla-ticket-meta-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 18px;
}
.wsla-meta-item {
    background: #f8fafc;
    border: 1px solid #eef2f7;
    border-radius: 14px;
    padding: 13px 14px;
}
.wsla-meta-label {
    color: #64748b;
    display: block;
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 7px;
}
.wsla-meta-value {
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    min-width: 0;
}
.wsla-meta-value span { min-width: 0; overflow-wrap: anywhere; }
.wsla-meta-value i { color: #94a3b8; flex: 0 0 auto; }
.wsla-meta-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--wsla-orange, #ff8800);
    flex: 0 0 auto;
}
.wsla-role-badge,
.requestor-badge {
    border-radius: 999px;
    background: #eef2ff;
    color: #475569;
    display: inline-flex;
    font-size: 11px;
    font-weight: 800;
    margin-inline-start: 6px;
    padding: 2px 7px;
}
.wsla-reply-bubble {
    border: 1px solid #eef2f7;
    border-radius: 18px;
    background: #fff;
    padding: 18px;
    margin-bottom: 16px;
}
.wsla-reply-bubble.wsla-staff { background: #fbfcfe; }
.wsla-reply-header { margin-bottom: 12px; }
.wsla-posted-by {
    color: #475569;
    font-size: 14px;
    line-height: 1.6;
}
.wsla-posted-by i { margin-inline-end: 6px; opacity: .55; }
.wsla-reply-body {
    color: #1f2937;
    font-size: 14px;
    line-height: 1.85;
    overflow-wrap: anywhere;
}
.wsla-reply-ip {
    border-top: 1px solid #e2e8f0;
    color: #94a3b8;
    display: block;
    font-size: 12px;
    margin-top: 18px;
    padding-top: 12px;
}
.wsla-reply-attachments {
    border-top: 1px solid #eef2f7;
    margin-top: 16px;
    padding-top: 14px;
}
.wsla-attachments-title {
    color: #475569;
    display: block;
    font-size: 13px;
    font-weight: 800;
    margin-bottom: 10px;
}
.wsla-attachments-title .wsla-removed-note {
    color: #ef4444;
    font-weight: 600;
    margin-inline-start: 6px;
}
.wsla-attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    list-style: none;
    margin: 0;
    padding: 0;
}
.wsla-attachment-link,
.wsla-attachment-removed {
    align-items: center;
    border-radius: 9px;
    display: inline-flex;
    font-size: 13px;
    font-weight: 700;
    gap: 7px;
    padding: 7px 12px;
    text-decoration: none !important;
}
.wsla-attachment-link {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #2563eb;
}
.wsla-attachment-removed {
    background: #fef2f2;
    border: 1px solid #fee2e2;
    color: #ef4444;
}
.wsla-ticket-reply-title {
    color: #111827;
    font-size: 20px;
    font-weight: 800;
    margin: 0 0 18px;
}
.wsla-ticket-reply-title i { color: var(--wsla-orange, #ff8800); margin-inline-end: 8px; }

/* Markdown editor in ticket submit/reply */
.wsla-ticket-editor-field,
.wsla-ticket-reply-editor-field {
    margin-top: 12px;
    margin-bottom: 24px;
}
.wsla-ticket-editor-field .wsla-message-title,
.wsla-ticket-reply-editor-field .wsla-message-title {
    color: var(--wsla-orange, #ff8800);
    display: block;
    font-size: 14px;
    font-weight: 800;
    margin-bottom: 10px;
}
.wsla-ticket-editor-field .md-editor,
.wsla-ticket-reply-editor-field .md-editor {
    border: 1px solid #d8e0ea !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    background: #fff !important;
}
.wsla-ticket-editor-field .md-header,
.wsla-ticket-editor-field .btn-toolbar,
.wsla-ticket-reply-editor-field .md-header,
.wsla-ticket-reply-editor-field .btn-toolbar {
    background: #f8fafc !important;
    border-bottom: 1px solid #e5edf6 !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    padding: 8px !important;
}
.wsla-ticket-editor-field .btn,
.wsla-ticket-reply-editor-field .btn {
    border: 1px solid #d8e0ea !important;
    border-radius: 8px !important;
    color: #334155 !important;
    font-weight: 800 !important;
    min-height: 34px !important;
}
.wsla-ticket-editor-field textarea.markdown-editor,
.wsla-ticket-reply-editor-field textarea.markdown-editor {
    border: 0 !important;
    border-radius: 0 !important;
    min-height: 260px !important;
    padding: 14px !important;
    resize: vertical !important;
}

/* Attachments shared by submit/reply */
.wsla-attachment-wrapper {
    border: 1px solid #d8e0ea;
    border-radius: 12px;
    background: #fff;
    padding: 14px;
    margin: 18px 0;
}
.wsla-file-row {
    display: flex !important;
    align-items: stretch !important;
    gap: 10px;
}
.wsla-file-row .custom-file { flex: 1 1 auto; min-width: 0; }
.wsla-file-row .custom-file-input { cursor: pointer; }
.wsla-file-row .custom-file-label {
    align-items: center;
    background: #f8fafc !important;
    border: 1px solid #d8e0ea !important;
    border-radius: 10px !important;
    color: #475569 !important;
    display: flex !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    height: 48px !important;
    line-height: 48px !important;
    margin: 0 !important;
    overflow: hidden;
    padding: 0 14px !important;
}
.wsla-file-row .custom-file-label:after { display: none !important; }
.wsla-file-row .btn-add-more,
.wsla-file-row #btnTicketAttachmentsAdd {
    align-items: center;
    background: #f1f5f9 !important;
    border: 0 !important;
    border-radius: 10px !important;
    color: #334155 !important;
    display: inline-flex !important;
    font-size: 13px !important;
    font-weight: 800 !important;
    height: 48px !important;
    justify-content: center;
    padding: 0 18px !important;
    white-space: nowrap;
}
.wsla-attachment-info {
    align-items: center;
    color: #64748b;
    display: flex;
    gap: 7px;
    font-size: 12px;
    line-height: 1.7;
    margin-top: 11px;
}
.wsla-ticket-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}
html[dir="rtl"] .wsla-ticket-actions,
body.body-rtl .wsla-ticket-actions { justify-content: flex-start; }

/* Custom optional fields block in ticket submit */
.wsla-ticket-custom-fields-box {
    border: 1px solid #e5edf6;
    border-radius: 14px;
    background: #fbfcfe;
    margin: 22px 0;
    padding: 16px;
}
.wsla-ticket-custom-fields-title {
    color: var(--wsla-orange, #ff8800);
    font-size: 15px;
    font-weight: 800;
    margin: 0 0 6px;
}
.wsla-ticket-custom-fields-note {
    color: #64748b;
    font-size: 13px;
    margin: 0 0 14px;
}

/* Confirm and feedback */
.wsla-ticket-confirm-card,
.wsla-ticket-feedback-card {
    border: 0 !important;
    box-shadow: none !important;
    border-radius: 18px !important;
    background: #fff !important;
    padding: 28px !important;
}
.wsla-ticket-feedback-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.wsla-ticket-feedback-table-wrap table { min-width: 620px; }
.wsla-ticket-feedback-staff {
    border: 1px solid #eef2f7;
    border-radius: 14px;
    padding: 16px;
    margin: 18px 0;
}
.wsla-ticket-feedback-rating-table td,
.wsla-ticket-feedback-rating-table th {
    vertical-align: middle !important;
    white-space: nowrap;
}

@media (max-width: 991.98px) {
    .wsla-ticket-meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767.98px) {
    .wsla-ticket-meta-grid { grid-template-columns: 1fr; }
    .wsla-ticket-header-top { align-items: stretch; }
    .wsla-ticket-top-actions,
    .wsla-ticket-top-actions .btn,
    .wsla-ticket-top-actions form { width: 100%; }
    .wsla-ticket-top-actions .btn { justify-content: center; }
    .wsla-file-row { flex-direction: column; }
    .wsla-file-row .input-group-append { width: 100%; }
    .wsla-file-row .btn-add-more,
    .wsla-file-row #btnTicketAttachmentsAdd { width: 100%; }
    .wsla-ticket-actions { flex-direction: column-reverse; }
    .wsla-ticket-actions .btn-submit,
    .wsla-ticket-actions .wsla-btn-cancel { width: 100%; }
}
.wsla-ticket-confirm-desc { max-width: 720px; }
.wsla-field-lock-icon { font-size: 11px; margin-inline-start: 4px; }
.wsla-posted-by-name { color: #111827; }

/* Phase 06A - Ticket reply/submit polish: keep editor labels and attachment rows clean */
.wsla-ticket-editor-field,
.wsla-ticket-reply-editor-field {
    position: relative !important;
    padding-top: 0 !important;
}
.wsla-ticket-editor-field .wsla-message-title,
.wsla-ticket-reply-editor-field .wsla-message-title {
    position: relative !important;
    inset: auto !important;
    transform: none !important;
    display: inline-flex !important;
    align-items: center !important;
    width: auto !important;
    max-width: 100% !important;
    background: #fff !important;
    color: var(--wsla-orange, #ff8800) !important;
    font-size: 14px !important;
    font-weight: 800 !important;
    line-height: 1.4 !important;
    margin: 0 0 12px !important;
    padding: 0 !important;
    pointer-events: auto !important;
    z-index: 2 !important;
}
.wsla-ticket-editor-field .md-editor,
.wsla-ticket-reply-editor-field .md-editor {
    clear: both !important;
    margin-top: 0 !important;
}
.wsla-ticket-editor-field .md-header,
.wsla-ticket-editor-field .btn-toolbar,
.wsla-ticket-reply-editor-field .md-header,
.wsla-ticket-reply-editor-field .btn-toolbar {
    direction: ltr !important;
    justify-content: flex-end !important;
}
html[dir="rtl"] .wsla-ticket-editor-field .md-header,
html[dir="rtl"] .wsla-ticket-editor-field .btn-toolbar,
html[dir="rtl"] .wsla-ticket-reply-editor-field .md-header,
html[dir="rtl"] .wsla-ticket-reply-editor-field .btn-toolbar,
body.body-rtl .wsla-ticket-editor-field .md-header,
body.body-rtl .wsla-ticket-editor-field .btn-toolbar,
body.body-rtl .wsla-ticket-reply-editor-field .md-header,
body.body-rtl .wsla-ticket-reply-editor-field .btn-toolbar {
    justify-content: flex-end !important;
}

.wsla-attachment-wrapper {
    padding: 16px !important;
}
.wsla-attachment-wrapper .wsla-file-row {
    display: flex !important;
    align-items: stretch !important;
    gap: 10px !important;
    width: 100% !important;
}
.wsla-attachment-wrapper .wsla-file-row .custom-file {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    height: 48px !important;
}
.wsla-attachment-wrapper .wsla-file-row .input-group-append {
    display: flex !important;
    flex: 0 0 auto !important;
    margin: 0 !important;
}
html[dir="rtl"] .wsla-attachment-wrapper .wsla-file-row,
body.body-rtl .wsla-attachment-wrapper .wsla-file-row {
    /* flex-direction: row-reverse !important; */
}
html:not([dir="rtl"]) .wsla-attachment-wrapper .wsla-file-row,
body:not(.body-rtl) .wsla-attachment-wrapper .wsla-file-row {
    flex-direction: row !important;
}
.wsla-attachment-wrapper .wsla-file-row .custom-file-label {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 48px !important;
    min-height: 48px !important;
    line-height: 1.4 !important;
    padding: 0 16px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
}
html[dir="rtl"] .wsla-attachment-wrapper .wsla-file-row .custom-file-label,
body.body-rtl .wsla-attachment-wrapper .wsla-file-row .custom-file-label {
    direction: rtl !important;
    text-align: right !important;
    justify-content: flex-start !important;
}
html:not([dir="rtl"]) .wsla-attachment-wrapper .wsla-file-row .custom-file-label,
body:not(.body-rtl) .wsla-attachment-wrapper .wsla-file-row .custom-file-label {
    direction: ltr !important;
    text-align: left !important;
}
.wsla-attachment-wrapper .wsla-file-row .custom-file-label i {
    margin-inline-end: 6px !important;
}
.wsla-attachment-wrapper .wsla-file-row .btn-add-more,
.wsla-attachment-wrapper .wsla-file-row #btnTicketAttachmentsAdd {
    min-width: 96px !important;
    height: 48px !important;
    min-height: 48px !important;
    margin: 0 !important;
}
.wsla-attachment-wrapper .file-upload .wsla-file-row {
    margin-top: 10px !important;
}
.wsla-attachment-wrapper .file-upload .wsla-file-row .custom-file {
    flex: 1 1 100% !important;
}
.wsla-attachment-wrapper .file-upload .wsla-file-row .input-group-append {
    display: none !important;
}

@media (max-width: 575.98px) {
    .wsla-attachment-wrapper .wsla-file-row,
    html[dir="rtl"] .wsla-attachment-wrapper .wsla-file-row,
    body.body-rtl .wsla-attachment-wrapper .wsla-file-row,
    html:not([dir="rtl"]) .wsla-attachment-wrapper .wsla-file-row,
    body:not(.body-rtl) .wsla-attachment-wrapper .wsla-file-row {
        flex-direction: column !important;
    }
    .wsla-attachment-wrapper .wsla-file-row .input-group-append,
    .wsla-attachment-wrapper .wsla-file-row .btn-add-more,
    .wsla-attachment-wrapper .wsla-file-row #btnTicketAttachmentsAdd {
        width: 100% !important;
    }
}
