/**
 * TC Helpdesk — Frontend Styles
 *
 * Designed to work with any WordPress theme.
 * Uses .tchd- prefix to avoid conflicts.
 */

/* ── Base ── */
.tchd-wrap {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #1C2430;
    line-height: 1.6;
}
.tchd-wrap * {
    box-sizing: border-box;
}

/* ── Buttons ── */
.tchd-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
    line-height: 1.4;
}
.tchd-btn-primary {
    background: #1F6AE1;
    color: #fff;
}
.tchd-btn-primary:hover {
    background: #1858C1;
    color: #fff;
}
.tchd-btn-secondary {
    background: #f4f5f7;
    color: #1C2430;
    border: 1px solid #e8ecf1;
}
.tchd-btn-secondary:hover {
    background: #e8ecf1;
}
.tchd-btn-sm {
    padding: 6px 14px;
    font-size: 12px;
}

/* ── Notices ── */
.tchd-notice {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}
.tchd-notice-success {
    background: #EBF5F1;
    color: #1F8A70;
    border: 1px solid #c6e6da;
}
.tchd-notice-error {
    background: #FEF0EE;
    color: #C84646;
    border: 1px solid #f5d0d0;
}
.tchd-notice-info {
    background: #EEF4FE;
    color: #1F6AE1;
    border: 1px solid #c8dafc;
}

/* ── Login Prompt ── */
.tchd-login-prompt {
    text-align: center;
    padding: 60px 20px;
    background: #f9fafb;
    border-radius: 12px;
    border: 1px solid #e8ecf1;
}
.tchd-login-prompt p {
    margin-bottom: 16px;
    font-size: 16px;
    color: #5A6270;
}

/* ── Dashboard ── */
.tchd-dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.tchd-dashboard-header h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
}

/* Stats row */
.tchd-stats-row {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.tchd-stat-pill {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    background: #f4f5f7;
    color: #5A6270;
    text-decoration: none;
    border: 1px solid transparent;
    transition: all 0.15s ease;
}
.tchd-stat-pill:hover {
    border-color: #e8ecf1;
    color: #1C2430;
}
.tchd-stat-pill.active {
    background: #1F6AE1;
    color: #fff;
}
.tchd-stat-pill .tchd-count {
    font-weight: 700;
    margin-left: 4px;
}

/* ── Ticket List ── */
.tchd-ticket-list {
    border: 1px solid #e8ecf1;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}
.tchd-ticket-item {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #f0f2f5;
    text-decoration: none;
    color: inherit;
    transition: background 0.12s ease;
    gap: 16px;
}
.tchd-ticket-item:last-child {
    border-bottom: none;
}
.tchd-ticket-item:hover {
    background: #f9fafb;
}
.tchd-ticket-id {
    font-size: 13px;
    font-weight: 600;
    color: #1F6AE1;
    min-width: 50px;
}
.tchd-ticket-info {
    flex: 1;
    min-width: 0;
}
.tchd-ticket-subject {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tchd-ticket-meta {
    font-size: 12px;
    color: #6b7280;
}
.tchd-ticket-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
}
.tchd-ticket-date {
    font-size: 12px;
    color: #6b7280;
    text-align: right;
    min-width: 80px;
}
.tchd-empty-state {
    text-align: center;
    padding: 48px 20px;
    color: #6b7280;
}
.tchd-empty-state p {
    margin-bottom: 16px;
}

/* Status colors */
.tchd-status-open        { background: #1F6AE1; }
.tchd-status-in_progress { background: #D9A441; }
.tchd-status-waiting     { background: #8B5CF6; }
.tchd-status-resolved    { background: #1F8A70; }
.tchd-status-closed      { background: #6b7280; }

/* Priority dots */
.tchd-priority-low    { color: #6b7280; }
.tchd-priority-medium { color: #1F6AE1; }
.tchd-priority-high   { color: #D9A441; }
.tchd-priority-urgent { color: #C84646; }

/* ── Forms ── */
.tchd-form {
    background: #fff;
    border: 1px solid #e8ecf1;
    border-radius: 12px;
    padding: 28px;
}
.tchd-form-group {
    margin-bottom: 20px;
}
.tchd-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #1C2430;
}
.tchd-form-group .tchd-desc {
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
}
.tchd-input,
.tchd-textarea,
.tchd-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #e8ecf1;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: #1C2430;
    transition: border-color 0.15s ease;
    background: #fff;
}
.tchd-input:focus,
.tchd-textarea:focus,
.tchd-select:focus {
    outline: none;
    border-color: #1F6AE1;
    box-shadow: 0 0 0 3px rgba(31, 106, 225, 0.08);
}
.tchd-textarea {
    min-height: 140px;
    resize: vertical;
}
.tchd-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ── Credential Fields Section ── */
.tchd-credentials-section {
    margin-top: 24px;
    padding: 20px;
    background: #FFF9E6;
    border: 1px solid #F0E4B8;
    border-radius: 8px;
}
.tchd-credentials-section h3 {
    margin: 0 0 4px;
    font-size: 15px;
}
.tchd-credentials-section .tchd-desc {
    font-size: 12px;
    color: #8B7A3E;
    margin-bottom: 16px;
}
.tchd-cred-toggle {
    cursor: pointer;
    user-select: none;
}
.tchd-cred-fields {
    display: none;
}
.tchd-cred-fields.tchd-show {
    display: block;
}

/* ── View Ticket ── */
.tchd-ticket-header {
    margin-bottom: 24px;
}
.tchd-ticket-header h2 {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 700;
}
.tchd-ticket-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.tchd-conversation {
    margin-bottom: 24px;
}
.tchd-msg {
    padding: 20px;
    border: 1px solid #e8ecf1;
    border-radius: 8px;
    margin-bottom: 12px;
    background: #fff;
}
.tchd-msg-admin {
    border-left: 3px solid #0E2B53;
}
.tchd-msg-customer {
    border-left: 3px solid #1F6AE1;
}
.tchd-msg-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.tchd-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #e8ecf1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    color: #5A6270;
    flex-shrink: 0;
}
.tchd-msg-avatar-admin {
    background: #0E2B53;
    color: #fff;
}
.tchd-msg-author {
    font-weight: 600;
    font-size: 14px;
}
.tchd-msg-staff-badge {
    background: #0E2B53;
    color: #fff;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 500;
}
.tchd-msg-time {
    font-size: 12px;
    color: #6b7280;
    margin-left: auto;
}
.tchd-msg-body {
    line-height: 1.6;
}
.tchd-msg-body p {
    margin: 0 0 8px;
}
.tchd-msg-attachments {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #f0f2f5;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.tchd-msg-attachments a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #f4f5f7;
    border-radius: 4px;
    font-size: 12px;
    text-decoration: none;
    color: #1F6AE1;
}

/* ── Reply Form (frontend) ── */
.tchd-reply-section {
    background: #fff;
    border: 1px solid #e8ecf1;
    border-radius: 12px;
    padding: 24px;
}
.tchd-reply-section h3 {
    margin: 0 0 16px;
    font-size: 16px;
}
.tchd-file-input {
    margin: 12px 0;
}

/* ── Pagination ── */
.tchd-pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 20px;
}
.tchd-pagination a,
.tchd-pagination span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid #e8ecf1;
    border-radius: 8px;
    text-decoration: none;
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
}
.tchd-pagination .current {
    background: #1F6AE1;
    color: #fff;
    border-color: #1F6AE1;
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .tchd-form-row {
        grid-template-columns: 1fr;
    }
    .tchd-dashboard-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .tchd-stats-row {
        flex-direction: column;
    }
    .tchd-ticket-item {
        flex-wrap: wrap;
    }
}
