/* ===== TICKET.CSS — Arsen Ticket System ===== */

/* ── Priority Badges ── */
.priority-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 700;
}

.priority-low {
    background: #f0fdf4;
    color: #16a34a;
}

.priority-normal {
    background: #eff6ff;
    color: #3b82f6;
}

.priority-high {
    background: #fff7ed;
    color: #f97316;
}

.priority-urgent {
    background: #fee2e2;
    color: #C8102E;
}

/* ── Empty State ── */
.ticket-empty {
    text-align: center;
    padding: 60px 20px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.ticket-empty-icon {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    background: #fff2f3;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    color: #C8102E;
}

.ticket-empty h4 {
    font-size: 1rem;
    font-weight: 800;
    color: #111827;
    margin-bottom: 6px;
}

.ticket-empty p {
    font-size: 0.82rem;
    color: #9ca3af;
}

/* ── Loading ── */
.ticket-loading {
    text-align: center;
    padding: 40px;
    font-size: 0.85rem;
    color: #9ca3af;
}

/* ── Back Button ── */
.ticket-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 10px;
    border: 1.5px solid #e5e7eb;
    background: #fff;
    font-family: 'Kalameh', sans-serif;
    font-size: 0.83rem;
    font-weight: 700;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 20px;
}

.ticket-back-btn:hover {
    border-color: #C8102E;
    color: #C8102E;
}

/* ── Ticket Detail Card ── */
.ticket-detail-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    margin-bottom: 20px;
}

.ticket-detail-header {
    padding: 24px 28px;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.ticket-detail-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: #111827;
    margin-bottom: 8px;
}

.ticket-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.ticket-detail-meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.76rem;
    color: #9ca3af;
    font-weight: 600;
}

.ticket-detail-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* وضعیت selector در ادمین */
.ticket-status-select {
    padding: 6px 12px;
    border-radius: 8px;
    border: 1.5px solid #e5e7eb;
    background: #fff;
    font-family: 'Kalameh', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    color: #374151;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.ticket-status-select:focus {
    border-color: #C8102E;
}

.ticket-close-btn {
    padding: 7px 16px;
    border-radius: 8px;
    border: 1.5px solid #e5e7eb;
    background: #fff;
    font-family: 'Kalameh', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
}

.ticket-close-btn:hover {
    border-color: #C8102E;
    color: #C8102E;
    background: #fff2f3;
}

/* ── Replies Thread ── */
.ticket-replies-wrap {
    /* wrapper بدون scroll — scroll در تعریف .ticket-replies پایین‌تر هست */
}

.ticket-reply {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    align-items: flex-end;
}

.ticket-reply--user {
    flex-direction: row-reverse;
}

.ticket-reply--admin {
    flex-direction: row;
}

.reply-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 800;
    color: #fff;
}

.reply-avatar--user {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

.reply-avatar--admin {
    background: linear-gradient(135deg, #C8102E, #9b0b22);
}

/* حباب */
.reply-body {
    max-width: 72%;
    border-radius: 14px 14px 14px 4px;
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    background: #f3f4f6;
}

.ticket-reply--user .reply-body {
    background: #dbeafe;
    border-color: #bfdbfe;
    border-radius: 14px 14px 4px 14px;
}

.ticket-reply--admin .reply-body {
    background: #fff2f3;
    border-color: rgba(200, 16, 46, 0.15);
    border-radius: 14px 14px 14px 4px;
}

.reply-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.reply-head strong {
    font-size: 0.82rem;
    font-weight: 800;
    color: #111827;
}

.reply-admin-tag {
    background: linear-gradient(135deg, #C8102E, #9b0b22);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    padding: 1px 8px;
    border-radius: 50px;
}

.reply-time {
    font-size: 0.7rem;
    color: #9ca3af;
    margin-right: auto;
    direction: ltr;
    white-space: nowrap;
}

.reply-text {
    font-size: 0.87rem;
    color: #374151;
    line-height: 1.75;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ── Reply Form ── */
.ticket-reply-form {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    padding: 24px 28px;
}

.ticket-reply-form h4 {
    font-size: 0.9rem;
    font-weight: 800;
    color: #111827;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1.5px solid #f3f4f6;
}

.reply-textarea {
    width: 100%;
    min-height: 110px;
    padding: 12px 14px;
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    font-family: 'Kalameh', sans-serif;
    font-size: 0.87rem;
    color: #1f2937;
    background: #fff;
    outline: none;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.reply-textarea:focus {
    border-color: #C8102E;
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.08);
}

.reply-form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    gap: 10px;
    flex-wrap: wrap;
}

.reply-submit-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    border-radius: 10px;
    border: none;
    background: #C8102E;
    color: #fff;
    font-family: 'Kalameh', sans-serif;
    font-size: 0.87rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 14px rgba(200, 16, 46, 0.3);
}

.reply-submit-btn:hover {
    background: #9b0b22;
    transform: translateY(-1px);
}

.reply-submit-btn:disabled {
    opacity: 0.6;
    pointer-events: none;
}

.ticket-closed-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #f3f4f6;
    border-radius: 10px;
    font-size: 0.82rem;
    color: #6b7280;
    font-weight: 600;
}

/* ── Pagination ── */
.ticket-pagination {
    display: flex;
    gap: 6px;
    margin-top: 16px;
}

.ticket-page-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1.5px solid #e5e7eb;
    background: #fff;
    font-family: 'Kalameh', sans-serif;
    font-size: 0.83rem;
    font-weight: 700;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ticket-page-btn:hover {
    border-color: #C8102E;
    color: #C8102E;
}

.ticket-page-btn.active {
    background: #C8102E;
    border-color: #C8102E;
    color: #fff;
}

/* ── Settings Panel ── */
.tset-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.tset-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
    padding: 24px;
}

.tset-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1.5px solid #f3f4f6;
}

.tset-card-title {
    font-size: 0.9rem;
    font-weight: 800;
    color: #111827;
}

.tset-add-btn {
    padding: 6px 14px;
    border-radius: 8px;
    border: 1.5px solid #C8102E;
    background: #fff2f3;
    color: #C8102E;
    font-family: 'Kalameh', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.tset-add-btn:hover {
    background: #C8102E;
    color: #fff;
}

.tset-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.tset-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #f9fafb;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
}

.tset-item-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tset-item-name {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 700;
    color: #374151;
}

.tset-item-actions {
    display: flex;
    gap: 6px;
}

.tset-edit-btn,
.tset-del-btn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.tset-edit-btn {
    background: #eff6ff;
    color: #3b82f6;
}

.tset-edit-btn:hover {
    background: #3b82f6;
    color: #fff;
}

.tset-del-btn {
    background: #fee2e2;
    color: #C8102E;
}

.tset-del-btn:hover {
    background: #C8102E;
    color: #fff;
}

.tset-form {
    background: #f9fafb;
    border-radius: 10px;
    padding: 14px;
    border: 1.5px dashed #e5e7eb;
}

.tset-form-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    align-items: center;
}

.tset-input {
    flex: 1;
    padding: 9px 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-family: 'Kalameh', sans-serif;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}

.tset-input:focus {
    border-color: #C8102E;
}

.tset-color-input {
    width: 40px;
    height: 38px;
    border-radius: 8px;
    border: 1.5px solid #e5e7eb;
    cursor: pointer;
    padding: 2px;
}

.tset-form-actions {
    display: flex;
    gap: 8px;
}

.tset-check-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    margin-bottom: 10px;
}

.tset-check-label input[type="checkbox"] {
    accent-color: #C8102E;
    width: 16px;
    height: 16px;
}

/* ── Ticket number chip ── */
.ticket-number-chip {
    font-family: monospace;
    font-size: 0.75rem;
    font-weight: 700;
    color: #6b7280;
    background: #f3f4f6;
    padding: 2px 8px;
    border-radius: 6px;
}

/* ── Admin tag in reply ── */
.reply-admin-tag {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #C8102E, #9b0b22);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 50px;
    margin-right: 6px;
    vertical-align: middle;
    letter-spacing: 0.3px;
}

/* ── Reply index badge ── */
.reply-index {
    font-size: 0.68rem;
    font-weight: 700;
    color: #d1d5db;
    background: #f3f4f6;
    padding: 1px 6px;
    border-radius: 5px;
    font-family: monospace;
}

/* ── Spin animation for loading state ── */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Thread scrollable area ── */
.ticket-replies {
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-height: 520px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.ticket-replies::-webkit-scrollbar {
    width: 4px;
}

.ticket-replies::-webkit-scrollbar-track {
    background: #f9fafb;
}

.ticket-replies::-webkit-scrollbar-thumb {
    background: #e5e7eb;
    border-radius: 4px;
}

/* ── Reply form title icon ── */
.ticket-reply-form h4 {
    display: flex;
    align-items: center;
    gap: 7px;
}

/* ── Reply sender name ── */
.reply-sender {
    font-size: 0.83rem;
    font-weight: 800;
    color: #111827;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .tset-grid {
        grid-template-columns: 1fr;
    }

    .ticket-detail-header {
        flex-direction: column;
    }

    .reply-bubble {
        max-width: 90%;
    }

    .ticket-replies {
        padding: 16px;
    }

    .ticket-reply-form {
        padding: 16px;
    }
}