/* ============================================================
   Advanced Support Ticket System — Frontend CSS
   ============================================================ */

:root {
    --ast-primary:    #2563eb;
    --ast-primary-h:  #1d4ed8;
    --ast-success:    #16a34a;
    --ast-danger:     #dc2626;
    --ast-warning:    #d97706;
    --ast-border:     #e2e8f0;
    --ast-surface:    #ffffff;
    --ast-surface-2:  #f8fafc;
    --ast-text:       #1e293b;
    --ast-text-muted: #64748b;
    --ast-radius:     12px;
    --ast-shadow:     0 2px 8px rgba(0,0,0,.08);
}

.ast-frontend { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: var(--ast-text); }
.ast-frontend * { box-sizing: border-box; }

/* Card */
.ast-card { background: var(--ast-surface); border: 1px solid var(--ast-border); border-radius: var(--ast-radius); box-shadow: var(--ast-shadow); overflow: hidden; }
.ast-card__header { padding: 24px 24px 20px; border-bottom: 1px solid var(--ast-border); background: linear-gradient(135deg, #f8fafc 0%, #fff 100%); }
.ast-card__title { font-size: 20px; font-weight: 700; margin: 0 0 6px; display: flex; align-items: center; gap: 10px; }
.ast-card__title svg { width: 22px; height: 22px; color: var(--ast-primary); }
.ast-card__subtitle { margin: 0; font-size: 14px; color: var(--ast-text-muted); }
.ast-card__body { padding: 24px; }

/* Buttons */
.ast-btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; border: 1px solid transparent; text-decoration: none; transition: all .15s ease; white-space: nowrap; line-height: 1; }
.ast-btn svg { width: 16px; height: 16px; }
.ast-btn--primary  { background: var(--ast-primary); color: #fff; }
.ast-btn--primary:hover { background: var(--ast-primary-h); color: #fff; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,.3); }
.ast-btn--secondary { background: var(--ast-surface); color: var(--ast-text); border-color: var(--ast-border); }
.ast-btn--secondary:hover { background: var(--ast-surface-2); color: var(--ast-text); }
.ast-btn--ghost { background: transparent; color: var(--ast-text-muted); border: 1px solid var(--ast-border); }
.ast-btn--ghost:hover { background: var(--ast-surface-2); color: var(--ast-text); }
.ast-btn--danger { background: var(--ast-danger); color: #fff; }
.ast-btn--full { width: 100%; justify-content: center; }
.ast-btn--sm { padding: 6px 12px; font-size: 12px; }

/* Form Elements */
.ast-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--ast-text); }
.ast-required { color: var(--ast-danger); }
.ast-input, .ast-select, .ast-textarea { width: 100%; padding: 10px 14px; border: 1.5px solid var(--ast-border); border-radius: 8px; font-size: 14px; color: var(--ast-text); background: var(--ast-surface); font-family: inherit; transition: border-color .15s ease, box-shadow .15s ease; }
.ast-input:focus, .ast-select:focus, .ast-textarea:focus { outline: none; border-color: var(--ast-primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.ast-textarea { resize: vertical; line-height: 1.5; }
.ast-input--sm, .ast-select--sm { padding: 7px 10px; font-size: 13px; }

/* Fields */
.ast-field { margin-bottom: 16px; }
.ast-field-row { display: flex; gap: 16px; }
.ast-field-row--two .ast-field { flex: 1; }

/* Alerts */
.ast-alert, .ast-notice { padding: 12px 16px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.ast-alert--error, .ast-notice--error { background: #fef2f2; color: #991b1b; border: 1px solid #fca5a5; }
.ast-alert--success, .ast-notice--success { background: #f0fdf4; color: #166534; border: 1px solid #86efac; }
.ast-notice--warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.ast-notice--info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* Success State */
.ast-success-state { text-align: center; padding: 32px 24px; }
.ast-success-icon { width: 60px; height: 60px; background: var(--ast-success); color: #fff; border-radius: 50%; font-size: 28px; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.ast-success-state h3 { font-size: 20px; margin: 0 0 8px; }
.ast-success-state p { color: var(--ast-text-muted); margin: 0; }

/* My Tickets */
.ast-ticket-list { display: flex; flex-direction: column; }
.ast-ticket-item { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--ast-border); }
.ast-ticket-item:last-child { border-bottom: none; }
.ast-ticket-item__left { display: flex; align-items: center; gap: 12px; }
.ast-ticket-item__info { display: flex; flex-direction: column; gap: 3px; }
.ast-ticket-item__title { font-weight: 600; text-decoration: none; color: var(--ast-text); font-size: 14px; }
.ast-ticket-item__title:hover { color: var(--ast-primary); }
.ast-ticket-item__date { font-size: 12px; color: var(--ast-text-muted); }
.ast-ticket-item__right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* Badges */
.ast-badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; letter-spacing: .03em; }
.ast-badge--agent    { background: #dbeafe; color: #1e40af; }
.ast-badge--customer { background: #f3e8ff; color: #6b21a8; }
.ast-badge--internal { background: #fef3c7; color: #92400e; }

.ast-ticket-num { font-size: 11px; font-weight: 700; font-family: monospace; background: var(--ast-surface-2); border: 1px solid var(--ast-border); border-radius: 4px; padding: 2px 7px; white-space: nowrap; }

/* Ticket View / Reply Thread */
.ast-back-link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--ast-primary); text-decoration: none; margin-bottom: 12px; }
.ast-ticket-view__header h2 { margin: 8px 0 6px; font-size: 20px; }
.ast-ticket-view__meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.ast-ticket-date { font-size: 12px; color: var(--ast-text-muted); }

.ast-reply { border: 1px solid var(--ast-border); border-radius: 10px; margin-bottom: 14px; overflow: hidden; }
.ast-reply--original { border-left: 3px solid #8b5cf6; }
.ast-reply--agent    { border-left: 3px solid var(--ast-primary); }
.ast-reply--internal { border-left: 3px solid #f59e0b; background: #fffbeb; }

.ast-reply__header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--ast-surface-2); border-bottom: 1px solid var(--ast-border); }
.ast-reply__header .avatar { border-radius: 50%; flex-shrink: 0; }
.ast-reply__meta { flex: 1; }
.ast-reply__meta strong { display: block; font-size: 13px; }
.ast-reply__email { font-size: 12px; color: var(--ast-text-muted); display: block; }
.ast-reply__time  { font-size: 11px; color: var(--ast-text-muted); }
.ast-reply__body  { padding: 14px 16px; font-size: 14px; line-height: 1.6; }
.ast-reply__body p { margin: 0 0 10px; }
.ast-reply__body p:last-child { margin: 0; }

/* Reply Box */
.ast-reply-box { margin-top: 20px; background: var(--ast-surface); border: 1.5px solid var(--ast-border); border-radius: 10px; overflow: hidden; }
.ast-reply-box h4 { margin: 0; padding: 14px 16px 12px; font-size: 14px; font-weight: 600; border-bottom: 1px solid var(--ast-border); }
.ast-reply-box__tabs { display: flex; border-bottom: 1px solid var(--ast-border); }
.ast-tab { flex: 1; padding: 10px 14px; background: none; border: none; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--ast-text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .15s ease; }
.ast-tab--active { color: var(--ast-primary); border-bottom-color: var(--ast-primary); background: #eff6ff; }
.ast-reply-box .ast-textarea { border: none; border-radius: 0; padding: 14px 16px; min-height: 120px; }
.ast-reply-box .ast-textarea:focus { box-shadow: none; }
.ast-reply-box__footer { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: var(--ast-surface-2); border-top: 1px solid var(--ast-border); }
.ast-reply-type-hint { font-size: 12px; color: var(--ast-text-muted); }

/* Frontend Admin Panel */
.ast-admin-panel { background: var(--ast-surface); border: 1px solid var(--ast-border); border-radius: var(--ast-radius); overflow: hidden; box-shadow: var(--ast-shadow); }

.ast-fe-stats { display: flex; border-bottom: 1px solid var(--ast-border); background: var(--ast-surface-2); flex-wrap: wrap; }
.ast-fe-stat { display: flex; flex-direction: column; align-items: center; padding: 14px 18px; text-decoration: none; color: var(--ast-text); border-right: 1px solid var(--ast-border); transition: background .15s ease; border-bottom: 3px solid transparent; }
.ast-fe-stat:last-child { border-right: none; }
.ast-fe-stat:hover { background: #fff; color: var(--ast-text); }
.ast-fe-stat--active { border-bottom-color: var(--sc, var(--ast-primary)); background: #fff; }
.ast-fe-stat--total { margin-left: auto; }
.ast-fe-stat__num { font-size: 22px; font-weight: 700; color: var(--sc, var(--ast-text)); }
.ast-fe-stat__lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ast-text-muted); }

.ast-fe-filters { padding: 12px 16px; border-bottom: 1px solid var(--ast-border); background: var(--ast-surface); }
.ast-fe-filters form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.ast-bulk-bar { display: flex; gap: 10px; align-items: center; padding: 10px 16px; background: #eff6ff; border-bottom: 1px solid #bfdbfe; font-size: 13px; }

.ast-fe-table-wrap { overflow-x: auto; }
.ast-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ast-table thead { background: var(--ast-surface-2); }
.ast-table th { padding: 10px 14px; text-align: left; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ast-text-muted); border-bottom: 1px solid var(--ast-border); }
.ast-table td { padding: 12px 14px; border-bottom: 1px solid var(--ast-border); vertical-align: middle; }
.ast-table tbody tr:last-child td { border-bottom: none; }
.ast-table tbody tr:hover td { background: var(--ast-surface-2); }

.ast-ticket-link { text-decoration: none; color: var(--ast-text); font-weight: 500; }
.ast-ticket-link:hover { color: var(--ast-primary); }
.ast-ticket-link .ast-ticket-num { display: block; margin-bottom: 2px; }

.ast-customer-compact { display: flex; align-items: center; gap: 8px; }
.ast-customer-compact .avatar { border-radius: 50%; }
.ast-priority-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.ast-unassigned { color: var(--ast-text-muted); font-style: italic; }
.ast-date-cell { font-size: 12px; color: var(--ast-text-muted); white-space: nowrap; }
.ast-empty-state { text-align: center; padding: 48px 24px; color: var(--ast-text-muted); }

/* Frontend Admin Detail */
.ast-fe-breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 14px 16px; border-bottom: 1px solid var(--ast-border); color: var(--ast-text-muted); background: var(--ast-surface-2); }
.ast-fe-breadcrumb a { color: var(--ast-primary); text-decoration: none; }

.ast-fe-detail-layout { display: grid; grid-template-columns: 1fr 280px; gap: 0; }
.ast-fe-detail-main { padding: 20px; border-right: 1px solid var(--ast-border); }
.ast-fe-detail-sidebar { padding: 16px; background: var(--ast-surface-2); }

.ast-fe-ticket-header h2 { margin: 0 0 8px; font-size: 18px; }
.ast-fe-ticket-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.ast-dept-tag { font-size: 11px; background: var(--ast-surface); border: 1px solid var(--ast-border); border-radius: 4px; padding: 2px 7px; color: var(--ast-text-muted); }

.ast-fe-card { background: var(--ast-surface); border: 1px solid var(--ast-border); border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.ast-fe-card h4 { margin: 0 0 12px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--ast-text-muted); }
.ast-customer-card { display: flex; gap: 10px; align-items: center; }
.ast-customer-card .avatar { border-radius: 50%; flex-shrink: 0; }
.ast-customer-card strong { display: block; font-size: 13px; }
.ast-customer-card a { font-size: 12px; color: var(--ast-primary); text-decoration: none; }

.ast-props { display: flex; flex-direction: column; gap: 10px; }
.ast-prop { display: flex; flex-direction: column; gap: 4px; }
.ast-prop label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--ast-text-muted); }
.ast-prop .ast-select { width: 100%; }

.ast-assigned-preview { display: flex; align-items: center; gap: 8px; background: var(--ast-surface-2); border-radius: 7px; padding: 7px 10px; }
.ast-assigned-preview .avatar { border-radius: 50%; }
.ast-assigned-preview span { font-size: 13px; font-weight: 500; }

.ast-quick-actions { display: flex; flex-direction: column; gap: 7px; }
.ast-fe-assign-notice { padding: 10px 14px; border-radius: 8px; background: #f0fdf4; color: #166534; border: 1px solid #86efac; font-size: 13px; }

/* Responsive */
@media (max-width: 700px) {
    .ast-field-row--two { flex-direction: column; }
    .ast-fe-detail-layout { grid-template-columns: 1fr; }
    .ast-fe-detail-main { border-right: none; border-bottom: 1px solid var(--ast-border); }
    .ast-fe-stats { overflow-x: auto; flex-wrap: nowrap; }
    .ast-fe-filters form { flex-direction: column; }
    .ast-fe-filters form .ast-input, .ast-fe-filters form .ast-select { width: 100%; }
}
