/**
 * 工单系统前端样式
 */

/* ========== 基础变量 ========== */
:root {
    --ts-primary: #0073aa;
    --ts-primary-hover: #006799;
    --ts-secondary: #6c757d;
    --ts-success: #28a745;
    --ts-warning: #ffc107;
    --ts-danger: #dc3545;
    --ts-info: #17a2b8;
    --ts-light: #f8f9fa;
    --ts-dark: #343a40;
    --ts-border: #dee2e6;
    --ts-border-radius: 6px;
    --ts-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --ts-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.12);
    --ts-transition: all 0.2s ease;
}

/* ========== 容器和布局 ========== */
.ts-user-center {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.ts-user-center h1,
.ts-user-center h2 {
    margin-top: 0;
    color: var(--ts-dark);
}

/* ========== 工单列表页 ========== */
.ts-tickets-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.ts-tickets-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 12px 15px;
    background: var(--ts-light);
    border-radius: var(--ts-border-radius);
}

.ts-filter-btn {
    padding: 6px 16px;
    border: 1px solid var(--ts-border);
    background: #fff;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    transition: var(--ts-transition);
    text-decoration: none;
    color: var(--ts-secondary);
}

.ts-filter-btn:hover {
    border-color: var(--ts-primary);
    color: var(--ts-primary);
    text-decoration: none;
}

.ts-filter-btn.active {
    background: var(--ts-primary);
    border-color: var(--ts-primary);
    color: #fff;
}

.ts-tickets-table-wrap {
    background: #fff;
    border-radius: var(--ts-border-radius);
    box-shadow: var(--ts-shadow);
    overflow: hidden;
}

.ts-tickets-table {
    width: 100%;
    border-collapse: collapse;
}

.ts-tickets-table th,
.ts-tickets-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--ts-border);
}

.ts-tickets-table th {
    background: var(--ts-light);
    font-weight: 600;
    font-size: 13px;
    color: var(--ts-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ts-tickets-table tbody tr {
    transition: var(--ts-transition);
}

.ts-tickets-table tbody tr:hover {
    background: #f0f7ff;
}

.ts-tickets-table tbody tr:last-child td {
    border-bottom: none;
}

.ts-ticket-id-col {
    font-family: monospace;
    font-size: 13px;
    color: var(--ts-secondary);
}

.ts-ticket-title-col a {
    color: var(--ts-dark);
    text-decoration: none;
    font-weight: 500;
    transition: var(--ts-transition);
}

.ts-ticket-title-col a:hover {
    color: var(--ts-primary);
}

.ts-no-tickets {
    text-align: center;
    padding: 60px 20px;
    color: var(--ts-secondary);
}

.ts-no-tickets .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.ts-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 20px;
}

.ts-pagination a,
.ts-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--ts-border);
    border-radius: var(--ts-border-radius);
    text-decoration: none;
    font-size: 14px;
    transition: var(--ts-transition);
    color: var(--ts-secondary);
}

.ts-pagination a:hover {
    border-color: var(--ts-primary);
    color: var(--ts-primary);
    text-decoration: none;
}

.ts-pagination .current {
    background: var(--ts-primary);
    border-color: var(--ts-primary);
    color: #fff;
}

/* ========== 状态徽章 ========== */
.ts-status-badge,
.ts-status-open,
.ts-status-processing,
.ts-status-replied,
.ts-status-closed {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.5;
    white-space: nowrap;
}

.ts-status-open {
    background: #e3f2fd;
    color: #1565c0;
}

.ts-status-processing {
    background: #fff3e0;
    color: #e65100;
}

.ts-status-replied {
    background: #e8f5e9;
    color: #2e7d32;
}

.ts-status-closed {
    background: #f5f5f5;
    color: #757575;
}

/* ========== 按钮样式 ========== */
.ts-btn,
a.ts-btn,
button.ts-btn {
    display: inline-flex !important;
    align-items: center;
    gap: 5px;
    padding: 8px 18px;
    border: none;
    border-radius: var(--ts-border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--ts-transition);
    text-decoration: none !important;
    line-height: 1.5;
    box-sizing: border-box;
}

.ts-btn .dashicons,
.ts-btn .fa {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.ts-btn-primary {
    background: var(--ts-primary) !important;
    color: #fff !important;
}

.ts-btn-primary:hover {
    background: var(--ts-primary-hover) !important;
    color: #fff !important;
    text-decoration: none !important;
}

.ts-btn-secondary {
    background: var(--ts-secondary);
    color: #fff;
}

.ts-btn-secondary:hover {
    background: #5a6268;
    color: #fff;
    text-decoration: none;
}

.ts-btn-danger {
    background: var(--ts-danger) !important;
    color: #fff !important;
}

.ts-btn-danger:hover {
    background: #c82333 !important;
    color: #fff !important;
    text-decoration: none !important;
}

.ts-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ========== 创建工单表单 ========== */
.ts-form-card {
    background: #fff;
    border-radius: var(--ts-border-radius);
    box-shadow: var(--ts-shadow);
    padding: 30px;
    max-width: 800px;
    margin: 0 auto;
}

/* ========== 工单表单容器 ========== */
.ts-ticket-form-wrap {
    max-width: 800px;
    margin: 0 auto;
    padding-bottom: 20px;
}

.ts-ticket-form-wrap .ts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.ts-ticket-form-wrap .ts-header h2 {
    margin: 0;
    font-size: 22px;
    color: var(--ts-dark);
}

.ts-info-box {
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid rgba(220, 53, 69, 0.3);
    border-radius: var(--ts-border-radius);
    padding: 18px 22px;
    margin-bottom: 25px;
    box-shadow: var(--ts-shadow);
}

.ts-info-box h4 {
    margin: 0 0 10px 0;
    font-size: 17px;
    font-weight: 700;
    color: #c82333;
}

.ts-info-box h4 i {
    margin-right: 6px;
}

.ts-info-box ul {
    margin: 0;
    padding-left: 22px;
    font-size: 16px;
    color: #a94442;
}

.ts-info-box li {
    margin-bottom: 6px;
    line-height: 1.7;
    color: #a94442;
}

.ts-form-group {
    margin-bottom: 20px;
}

.ts-form-group label,
.ts-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--ts-dark);
    font-size: 14px;
}

.ts-form-group .required,
.ts-label .required {
    color: var(--ts-danger);
}

.ts-form-group input[type="text"],
.ts-form-group textarea,
.ts-form-group select,
.ts-input,
.ts-textarea,
.ts-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--ts-border);
    border-radius: var(--ts-border-radius);
    font-size: 14px;
    transition: var(--ts-transition);
    box-sizing: border-box;
    background: #fff;
}

.ts-input:focus,
.ts-textarea:focus,
.ts-select:focus,
.ts-form-group input[type="text"]:focus,
.ts-form-group textarea:focus,
.ts-form-group select:focus {
    outline: none;
    border-color: var(--ts-primary);
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.15);
}

.ts-textarea {
    min-height: 150px;
    resize: vertical;
    line-height: 1.6;
}

.ts-form-hint,
.ts-help {
    margin-top: 6px;
    font-size: 12px;
    color: var(--ts-secondary);
    display: block;
}

.ts-form-hint code {
    background: var(--ts-light);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
}

.ts-char-count {
    float: right;
    font-size: 12px;
    color: var(--ts-secondary);
}

.ts-char-count.warning {
    color: var(--ts-warning);
}

.ts-char-count.danger {
    color: var(--ts-danger);
}

.ts-form-actions {
    margin-top: 25px;
    margin-bottom: 10px;
    padding-top: 20px;
    padding-bottom: 10px;
    border-top: 1px solid var(--ts-border);
    display: flex;
    gap: 20px;
    align-items: center;
}

.ts-btn-lg {
    padding: 12px 28px;
    font-size: 16px;
}

/* ========== 文件上传 ========== */
.ts-upload-area {
    position: relative;
    border: 2px dashed #b0c4de;
    border-radius: var(--ts-border-radius);
    padding: 30px 20px;
    text-align: center;
    transition: var(--ts-transition);
    background: #f8fafc;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ts-upload-area:hover {
    border-color: var(--ts-primary);
    background: #f0f7ff;
}

.ts-upload-area.drag-over {
    border-color: var(--ts-primary);
    background: #e3f2fd;
}

/* 文件输入框覆盖整个上传区域 */
.ts-file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
    margin: 0;
}

/* 上传区域内容 */
.ts-upload-content {
    position: relative;
    z-index: 1;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ts-upload-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    font-size: 28px;
    font-weight: 400;
    color: var(--ts-primary);
    border: 2px solid var(--ts-primary);
    border-radius: 8px;
    margin-bottom: 8px;
    background: #fff;
    line-height: 1;
}

.ts-upload-title {
    margin: 0 0 4px 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--ts-dark);
}

.ts-upload-help {
    margin: 0;
    font-size: 12px;
    color: var(--ts-secondary);
}

.ts-file-hint {
    margin-top: 8px;
    font-size: 12px;
    color: var(--ts-secondary);
}

.ts-file-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.ts-file-list-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--ts-light);
    border-radius: var(--ts-border-radius);
    font-size: 13px;
    border: 1px solid var(--ts-border);
}

.ts-file-list-item .ts-remove-file {
    background: none;
    border: none;
    color: var(--ts-danger);
    cursor: pointer;
    padding: 0;
    font-size: 16px;
    line-height: 1;
    margin-left: 5px;
}

.ts-file-list-item .ts-remove-file:hover {
    color: #a00;
}

.ts-file-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
    text-align: left;
}

.ts-file-preview-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--ts-light);
    border-radius: var(--ts-border-radius);
    font-size: 13px;
}

.ts-file-preview-item .ts-remove-file {
    background: none;
    border: none;
    color: var(--ts-danger);
    cursor: pointer;
    padding: 0;
    font-size: 16px;
    line-height: 1;
}

/* ========== 工单详情页 ========== */
.ts-ticket-detail {
    max-width: 900px;
    margin: 0 auto;
}

.ts-ticket-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--ts-border);
    flex-wrap: wrap;
    gap: 15px;
}

.ts-ticket-title h2 {
    margin: 0 0 10px 0;
    font-size: 24px;
    color: var(--ts-dark);
}

.ts-ticket-meta {
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 14px;
    color: var(--ts-secondary);
}

.ts-ticket-id {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ts-ticket-body {
    background: #fff;
    border-radius: var(--ts-border-radius);
    box-shadow: var(--ts-shadow);
    padding: 25px;
    margin-bottom: 25px;
}

.ts-ticket-info {
    display: flex;
    gap: 25px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--ts-border);
    flex-wrap: wrap;
}

.ts-info-item {
    display: flex;
    gap: 8px;
    font-size: 14px;
}

.ts-info-item strong {
    color: var(--ts-secondary);
}

.ts-ticket-content h3,
.ts-ticket-replies h3,
.ts-reply-form h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: var(--ts-dark);
}

.ts-content-body {
    line-height: 1.8;
    font-size: 15px;
    color: var(--ts-dark);
}

.ts-content-body p {
    margin-bottom: 12px;
}

.ts-content-body code {
    background: var(--ts-light);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 13px;
}

.ts-content-body pre {
    background: var(--ts-light);
    padding: 15px;
    border-radius: var(--ts-border-radius);
    overflow-x: auto;
}

/* ========== 附件 ========== */
.ts-attachments-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.ts-attachment-item {
    background: var(--ts-light);
    border-radius: var(--ts-border-radius);
    overflow: hidden;
    transition: var(--ts-transition);
}

.ts-attachment-item:hover {
    box-shadow: var(--ts-shadow-hover);
}

.ts-attachment-image img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}

.ts-attachment-file {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    text-decoration: none;
    color: var(--ts-secondary);
}

.ts-attachment-file .dashicons {
    font-size: 36px;
    width: 36px;
    height: 36px;
    margin-bottom: 8px;
}

.ts-attachment-info {
    padding: 8px 10px;
    border-top: 1px solid var(--ts-border);
    font-size: 12px;
}

.ts-attachment-name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ts-attachment-size {
    color: var(--ts-secondary);
    font-size: 11px;
}

/* ========== 回复列表 ========== */
.ts-ticket-replies {
    background: #fff;
    border-radius: var(--ts-border-radius);
    box-shadow: var(--ts-shadow);
    padding: 25px;
    margin-bottom: 25px;
}

.ts-no-replies {
    text-align: center;
    padding: 30px;
    color: var(--ts-secondary);
}

.ts-replies-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ts-reply-item {
    display: flex;
    gap: 15px;
    padding: 18px;
    border-radius: var(--ts-border-radius);
    border-left: 3px solid transparent;
}

.ts-reply-user {
    background: #f0f7ff;
    border-left-color: var(--ts-primary);
}

.ts-reply-admin {
    background: #fff8e1;
    border-left-color: var(--ts-warning);
}

.ts-reply-avatar {
    flex-shrink: 0;
}

.ts-reply-avatar img {
    border-radius: 50%;
}

.ts-avatar-placeholder {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ts-avatar-admin {
    background: var(--ts-warning);
    color: #fff;
}

.ts-avatar-admin .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
}

.ts-reply-body {
    flex: 1;
    min-width: 0;
}

.ts-reply-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 14px;
}

.ts-reply-author {
    color: var(--ts-dark);
}

.ts-reply-role {
    font-weight: normal;
    color: var(--ts-secondary);
    font-size: 12px;
}

.ts-reply-time {
    color: var(--ts-secondary);
    font-size: 12px;
}

.ts-reply-content {
    line-height: 1.7;
    font-size: 14px;
    color: var(--ts-dark);
}

.ts-reply-attachments {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(0,0,0,0.06);
    font-size: 13px;
}

.ts-reply-attachment-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
    color: var(--ts-primary);
    text-decoration: none;
}

.ts-reply-attachment-link:hover {
    text-decoration: underline;
}

/* ========== 回复表单 ========== */
.ts-reply-form {
    background: #fff;
    border-radius: var(--ts-border-radius);
    box-shadow: var(--ts-shadow);
    padding: 25px;
}

/* ========== 提示框 ========== */
.ts-alert {
    padding: 12px 18px;
    border-radius: var(--ts-border-radius);
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ts-alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.ts-alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.ts-alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.ts-alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* ========== 用户中心"我的服务"图标样式 ========== */
.icon-but-box .icon-but-tickets,
.icon-but-box a .icon-but-tickets {
    flex: 1;
    min-width: 0;
    padding: 10px 5px;
}

/* 调整"我的服务"区域图标间距 */
.icon-but-box.user-icon-but-box {
    gap: 15px !important;
}

.icon-but-box.user-icon-but-box > * {
    flex: 1;
    max-width: 80px;
}

/* ========== 响应式适配 ========== */
@media (max-width: 768px) {
    .ts-tickets-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .ts-tickets-table-wrap {
        overflow-x: auto;
    }
    
    .ts-tickets-table {
        min-width: 600px;
    }
    
    .ts-ticket-header {
        flex-direction: column;
    }
    
    .ts-ticket-info {
        flex-direction: column;
        gap: 10px;
    }
    
    .ts-reply-item {
        flex-direction: column;
    }
    
    .ts-form-card,
    .ts-ticket-body,
    .ts-ticket-replies,
    .ts-reply-form {
        padding: 15px;
    }
    
    .ts-attachments-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}

/* ========== 工单关闭提示（用户端） ========== */
.ts-ticket-close-notice {
    margin: 20px 0;
}

.ts-ticket-close-notice .ts-notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 15px 20px;
    border-radius: var(--ts-border-radius);
    font-size: 14px;
    line-height: 1.6;
}

.ts-ticket-close-notice .ts-notice i {
    font-size: 20px;
    margin-top: 2px;
    flex-shrink: 0;
}

.ts-ticket-close-notice .ts-notice-warning {
    background: #fff8e1;
    border: 1px solid #ffcc80;
    color: #e65100;
}

.ts-ticket-close-notice .ts-notice-info {
    background: #e3f2fd;
    border: 1px solid #90caf9;
    color: #1565c0;
}

/* ========== 管理端关闭类型标识 ========== */
.ts-close-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.ts-close-type-badge .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

.ts-close-type-auto {
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffcc80;
}

.ts-close-type-manual {
    background: #e8eaf6;
    color: #283593;
    border: 1px solid #9fa8da;
}

/* ========== 管理端关闭提示条 ========== */
.ts-close-notice-body {
    padding: 12px 20px !important;
}

.ts-admin-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.5;
}

.ts-admin-notice .dashicons {
    font-size: 18px;
    flex-shrink: 0;
}

.ts-admin-notice-warning {
    background: #fff8e1;
    border: 1px solid #ffcc80;
    color: #e65100;
}

.ts-admin-notice-info {
    background: #e3f2fd;
    border: 1px solid #90caf9;
    color: #1565c0;
}
