/* static/css/tickets.css */

/* ============================================
   استایل‌های صفحه تیکت (پشتیبانی)
   ============================================ */

.tickets-container {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 2rem;
    margin-top: 1.5rem;
    margin-bottom: 3rem;
}

.ticket-form-wrapper {
    position: sticky;
    top: 100px;
}

.ticket-form {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
}

.ticket-form h3 {
    font-size: 1.1rem;
    margin-bottom: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.ticket-form .form-group {
    margin-bottom: 0.8rem;
}

.ticket-form .form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.2rem;
}

.ticket-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
}

/* ===== اصلاح فیلدها ===== */
.ticket-form .form-group input,
.ticket-form .form-group textarea,
.ticket-form .form-group select {
    width: 100%;
    max-width: 100%;
    padding: 0.6rem 1rem;
    background: rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-main);
    font-family: 'Vazirmatn', sans-serif;
    font-size: 0.85rem;
    transition: all 0.3s;
    direction: rtl;
    box-sizing: border-box;
    display: block;
}

/* ===== اصلاح textarea ===== */
.ticket-form .form-group textarea {
    resize: vertical;
    min-height: 80px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

[data-theme="light"] .ticket-form .form-group input,
[data-theme="light"] .ticket-form .form-group textarea,
[data-theme="light"] .ticket-form .form-group select {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-main);
}

.ticket-form .form-group input:focus,
.ticket-form .form-group textarea:focus,
.ticket-form .form-group select:focus {
    border-color: rgba(139, 92, 246, 0.3);
    outline: none;
    box-shadow: 0 0 20px rgba(108, 60, 225, 0.05);
}

.ticket-form .btn {
    width: 100%;
    justify-content: center;
    box-sizing: border-box;
}

.ticket-message {
    margin-top: 0.8rem;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    font-size: 0.8rem;
    display: none;
    box-sizing: border-box;
    width: 100%;
}

.ticket-message.success {
    display: block;
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.1);
}

.ticket-message.error {
    display: block;
    background: rgba(239, 68, 68, 0.1);
    color: #EF4444;
    border: 1px solid rgba(239, 68, 68, 0.1);
}

/* ===== لیست تیکت‌ها ===== */
.tickets-list-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    max-height: 500px;
    overflow-y: auto;
}

.tickets-list-wrapper::-webkit-scrollbar {
    width: 3px;
}
.tickets-list-wrapper::-webkit-scrollbar-track {
    background: transparent;
}
.tickets-list-wrapper::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

.tickets-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.tickets-list-header h3 {
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.ticket-count {
    font-size: 0.7rem;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.06);
    padding: 0.2rem 0.8rem;
    border-radius: 50px;
}

.ticket-item {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.8rem 1rem;
    margin-bottom: 0.6rem;
    cursor: pointer;
    transition: all 0.3s;
}

[data-theme="light"] .ticket-item {
    background: rgba(0, 0, 0, 0.02);
}

.ticket-item:hover {
    border-color: rgba(108, 60, 225, 0.08);
    transform: translateX(-4px);
}

.ticket-item .ticket-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ticket-item .ticket-item-subject {
    font-weight: 600;
    font-size: 0.9rem;
}

.ticket-item .ticket-item-status {
    font-size: 0.6rem;
    padding: 0.15rem 0.6rem;
    border-radius: 50px;
    font-weight: 500;
}

.ticket-item .ticket-item-status.badge-open {
    background: rgba(16, 185, 129, 0.1);
    color: #10B981;
}
.ticket-item .ticket-item-status.badge-progress {
    background: rgba(245, 158, 11, 0.1);
    color: #F59E0B;
}
.ticket-item .ticket-item-status.badge-answered {
    background: rgba(59, 130, 246, 0.1);
    color: #3B82F6;
}
.ticket-item .ticket-item-status.badge-closed {
    background: rgba(107, 114, 128, 0.1);
    color: #6B7280;
}

.ticket-item .ticket-item-date {
    font-size: 0.6rem;
    color: var(--text-secondary);
}

.ticket-item .ticket-item-preview {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.no-tickets {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem 0;
    font-size: 0.9rem;
}

.no-tickets i {
    font-size: 3rem;
    display: block;
    margin-bottom: 0.8rem;
    opacity: 0.3;
}

.loading-spinner {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 2rem 0;
}

/* ============================================
   مودال تیکت
   ============================================ */

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    max-width: 500px;
    width: 90%;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalFadeIn 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
}

.ticket-modal {
    max-width: 600px;
}

@keyframes modalFadeIn {
    from {
        transform: scale(0.9) translateY(20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* ===== هدر مودال ===== */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-header h3::before {
    content: '🎫';
    font-size: 1.2rem;
}

/* ===== دکمه بستن ===== */
.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(239, 68, 68, 0.08);
    color: #EF4444;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.modal-close:hover {
    background: rgba(239, 68, 68, 0.15);
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.15);
}

.modal-close:active {
    transform: rotate(90deg) scale(0.95);
}

[data-theme="light"] .modal-close {
    background: rgba(239, 68, 68, 0.06);
    color: #DC2626;
}

[data-theme="light"] .modal-close:hover {
    background: rgba(239, 68, 68, 0.12);
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.1);
}

/* ============================================
   استایل بخش‌های مودال
   ============================================ */

/* ===== هدر اطلاعات (وضعیت، اولویت، بخش) ===== */
.ticket-detail-header {
    display: flex;
    gap: 0.8rem;
    margin-bottom: 1.2rem;
    flex-wrap: wrap;
}

/* ===== هر آیتم اطلاعات ===== */
.ticket-info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    background: rgba(0, 0, 0, 0.04);
    padding: 0.4rem 0.8rem;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    min-width: 70px;
    flex: 1;
    transition: all 0.3s ease;
}

[data-theme="light"] .ticket-info-item {
    background: rgba(0, 0, 0, 0.02);
}

.ticket-info-item:hover {
    border-color: rgba(139, 92, 246, 0.15);
}

/* ===== برچسب اطلاعات ===== */
.ticket-info-item .ticket-info-label {
    font-size: 0.55rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== وضعیت (Status) ===== */
.ticket-info-item .ticket-status {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.6rem;
    border-radius: 50px;
    width: 100%;
    text-align: center;
}

.ticket-info-item .ticket-status.open {
    background: rgba(16, 185, 129, 0.15);
    color: #10B981;
    border: 1px solid rgba(16, 185, 129, 0.1);
}

.ticket-info-item .ticket-status.in_progress {
    background: rgba(245, 158, 11, 0.15);
    color: #F59E0B;
    border: 1px solid rgba(245, 158, 11, 0.1);
}

.ticket-info-item .ticket-status.answered {
    background: rgba(59, 130, 246, 0.15);
    color: #3B82F6;
    border: 1px solid rgba(59, 130, 246, 0.1);
}

.ticket-info-item .ticket-status.closed {
    background: rgba(107, 114, 128, 0.15);
    color: #6B7280;
    border: 1px solid rgba(107, 114, 128, 0.1);
}

/* ===== اولویت (Priority) ===== */
.ticket-info-item .ticket-priority {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.6rem;
    border-radius: 50px;
    width: 100%;
    text-align: center;
}

.ticket-info-item .ticket-priority.low {
    background: rgba(16, 185, 129, 0.15);
    color: #10B981;
    border: 1px solid rgba(16, 185, 129, 0.1);
}

.ticket-info-item .ticket-priority.medium {
    background: rgba(245, 158, 11, 0.15);
    color: #F59E0B;
    border: 1px solid rgba(245, 158, 11, 0.1);
}

.ticket-info-item .ticket-priority.high {
    background: rgba(239, 68, 68, 0.15);
    color: #EF4444;
    border: 1px solid rgba(239, 68, 68, 0.1);
}

.ticket-info-item .ticket-priority.urgent {
    background: rgba(239, 68, 68, 0.25);
    color: #DC2626;
    border: 1px solid rgba(239, 68, 68, 0.15);
}

/* ===== بخش (Department) - بنفش مثل بقیه ===== */
.ticket-info-item .ticket-department {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.6rem;
    border-radius: 50px;
    width: 100%;
    text-align: center;
    background: rgba(139, 92, 246, 0.15) !important;
    color: var(--primary-light) !important;
    border: 1px solid rgba(139, 92, 246, 0.1);
}

/* ============================================
   بخش سوال (موضوع و متن پیام)
   ============================================ */

.ticket-question-section {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

[data-theme="light"] .ticket-question-section {
    background: rgba(0, 0, 0, 0.02);
}

.ticket-question-section:hover {
    border-color: rgba(139, 92, 246, 0.15);
}

.ticket-question-section .section-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--primary-light);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* ===== موضوع ===== */
.ticket-detail-subject {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    padding: 0.4rem 0.6rem;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 8px;
    border-left: 3px solid var(--primary-light);
}

[data-theme="light"] .ticket-detail-subject {
    background: rgba(0, 0, 0, 0.01);
}

/* ===== متن پیام ===== */
.ticket-detail-message {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.8;
    padding: 0.8rem;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 10px;
    margin-bottom: 0.8rem;
    border: 1px solid var(--border-color);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

[data-theme="light"] .ticket-detail-message {
    background: rgba(0, 0, 0, 0.02);
}

/* ===== تاریخ ===== */
.ticket-detail-date {
    font-size: 0.65rem;
    color: var(--text-secondary);
    padding: 0.3rem 0.6rem;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 6px;
    display: inline-block;
    border: 1px solid var(--border-color);
}

[data-theme="light"] .ticket-detail-date {
    background: rgba(0, 0, 0, 0.01);
}

/* ============================================
   پاسخ ادمین
   ============================================ */

.ticket-response {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(59, 130, 246, 0.04);
    border: 1px solid rgba(59, 130, 246, 0.08);
    border-radius: 12px;
    animation: fadeInUp 0.4s ease;
    transition: all 0.3s ease;
}

.ticket-response:hover {
    border-color: rgba(59, 130, 246, 0.15);
}

.ticket-response .response-header {
    font-weight: 600;
    font-size: 0.85rem;
    color: #3B82F6;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ticket-response .response-body {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.8;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 8px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.ticket-response .response-date {
    font-size: 0.6rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    text-align: left;
    padding: 0.2rem 0.5rem;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 4px;
    display: inline-block;
}

/* ============================================
   بدون پاسخ
   ============================================ */

.ticket-no-response {
    margin-top: 1rem;
    padding: 1.5rem;
    text-align: center;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 12px;
    border: 1px dashed var(--border-color);
    transition: all 0.3s ease;
}

[data-theme="light"] .ticket-no-response {
    background: rgba(0, 0, 0, 0.02);
}

.ticket-no-response:hover {
    border-color: rgba(139, 92, 246, 0.15);
}

.ticket-no-response .no-response-message i {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
    opacity: 0.6;
}

.ticket-no-response .no-response-message p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.2rem;
}

.ticket-no-response .no-response-message span {
    font-size: 0.7rem;
    color: var(--text-secondary);
    opacity: 0.6;
}

/* ============================================
   انیمیشن‌ها
   ============================================ */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   ریسپانسیو
   ============================================ */

@media (max-width: 992px) {
    .tickets-container {
        grid-template-columns: 1fr;
    }
    .ticket-form-wrapper {
        position: static;
    }
    .ticket-form .form-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .ticket-item .ticket-item-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .ticket-form {
        padding: 1rem;
    }
    .ticket-form .form-group input,
    .ticket-form .form-group textarea,
    .ticket-form .form-group select {
        padding: 0.5rem 0.8rem;
        font-size: 0.8rem;
    }
    
    /* ===== ریسپانسیو مودال ===== */
    .ticket-detail-header {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .ticket-info-item {
        flex-direction: row;
        justify-content: space-between;
        padding: 0.3rem 0.6rem;
        min-width: auto;
    }
    
    .ticket-info-item .ticket-info-label {
        font-size: 0.5rem;
    }
    
    .ticket-info-item .ticket-status,
    .ticket-info-item .ticket-priority,
    .ticket-info-item .ticket-department {
        font-size: 0.65rem;
        padding: 0.1rem 0.4rem;
        width: auto;
    }
    
    .modal-content {
        padding: 1rem;
        width: 95%;
    }
}