/*
 * Enhanced User Dashboard styles for Universal Support Tickets
 * Perfectly aligned with the Agent Dashboard UI/UX.
 */

:root {
    --jst-primary: var(--jst-primary-color, #14a34b);
    --jst-primary-dark: #0f8a3f;
    --jst-accent: var(--jst-accent-color, #6366f1);
    --jst-bg: var(--jst-bg-primary, #f5f7fb);
    --jst-surface: var(--jst-bg-secondary, #ffffff);
    --jst-text: var(--jst-text-primary, #111827);
    --jst-muted: var(--jst-text-secondary, #64748b);
    --jst-border: var(--jst-border-color, #e2e8f0);
    --jst-shadow: 0 22px 60px rgba(15, 23, 42, 0.12);
    --jst-shadow-soft: 0 12px 30px rgba(15, 23, 42, 0.08);
    --jst-radius: 22px;
    --jst-radius-sm: 14px;
    --jst-transition: 180ms ease;
}

.jst-dashboard-container {
    max-width: 1240px;
    margin: 32px auto;
    padding: clamp(18px, 2.5vw, 32px);
    color: var(--jst-text);
    background: 
        radial-gradient(circle at top left, rgba(20, 163, 75, 0.13), transparent 30%),
        radial-gradient(circle at top right, rgba(99, 102, 241, 0.12), transparent 28%),
        var(--jst-bg);
    border: 1px solid rgba(226, 232, 240, 0.86);
    border-radius: 30px;
    box-shadow: var(--jst-shadow);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
}

.jst-dashboard-header {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
    padding: clamp(26px, 4vw, 42px);
    color: #ffffff;
    background: 
        linear-gradient(135deg, rgba(15, 23, 42, 0.18), rgba(15, 23, 42, 0.02)),
        linear-gradient(135deg, var(--jst-primary), #16a34a 48%, var(--jst-accent));
    border: none;
    border-radius: 26px;
    box-shadow: 0 22px 44px rgba(20, 163, 75, 0.23);
}

.jst-dashboard-header::before {
    content: "";
    position: absolute;
    right: -70px;
    top: -100px;
    width: 290px;
    height: 290px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.15);
}

.jst-dashboard-title h2 {
    position: relative;
    z-index: 1;
    margin: 0;
    color: #ffffff;
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 850;
    letter-spacing: -0.045em;
    line-height: 1.05;
}

.jst-user-info {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 10px 10px 16px;
    color: rgba(255, 255, 255, 0.92);
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    backdrop-filter: blur(10px);
    font-weight: 750;
}

.jst-logout-link {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 8px 12px;
    color: #ffffff !important;
    background: rgba(15, 23, 42, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 850;
    text-decoration: none !important;
    transition: background var(--jst-transition), transform var(--jst-transition);
}

.jst-logout-link:hover {
    background: rgba(15, 23, 42, 0.28);
    transform: translateY(-1px);
}

.jst-dashboard-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.jst-stat-card {
    position: relative;
    overflow: hidden;
    min-height: 140px;
    padding: 22px;
    text-align: left;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(226, 232, 240, 0.92);
    border-radius: var(--jst-radius);
    box-shadow: var(--jst-shadow-soft);
    transition: transform var(--jst-transition), box-shadow var(--jst-transition), border-color var(--jst-transition);
}

.jst-stat-card::before {
    content: "";
    position: absolute;
    top: 18px;
    right: 18px;
    width: 46px;
    height: 46px;
    border-radius: 16px;
    background: rgba(20, 163, 75, 0.12);
}

.jst-stat-card::after {
    content: "";
    position: absolute;
    top: 31px;
    right: 31px;
    width: 20px;
    height: 20px;
    border: 3px solid var(--jst-primary);
    border-radius: 7px;
}

.jst-stat-card:hover {
    transform: translateY(-4px);
    border-color: rgba(20, 163, 75, 0.35);
    box-shadow: 0 24px 45px rgba(15, 23, 42, 0.13);
}

.jst-stat-number {
    margin: 0 0 8px;
    color: var(--jst-text);
    font-size: clamp(2.2rem, 4vw, 3.35rem);
    font-weight: 850;
    letter-spacing: -0.055em;
    line-height: 0.98;
}

.jst-stat-label {
    color: var(--jst-muted);
    font-size: 0.88rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.jst-dashboard-actions-bar {
    margin-bottom: 24px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--jst-border);
    border-radius: 20px;
}

.jst-tickets-list {
    overflow: hidden;
    padding: 8px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--jst-border);
    border-radius: 24px;
    box-shadow: var(--jst-shadow-soft);
}

.jst-ticket-item {
    position: relative;
    margin: 8px;
    padding: 20px;
    background: #ffffff;
    border: 1px solid #eef2f7;
    border-radius: 20px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.045);
    transition: transform var(--jst-transition), box-shadow var(--jst-transition), border-color var(--jst-transition), background var(--jst-transition);
}

.jst-ticket-item:hover {
    transform: translateY(-3px);
    border-color: rgba(20, 163, 75, 0.30);
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.10);
}

.jst-ticket-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.jst-ticket-number {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 6px 10px;
    color: #047857;
    background: #ecfdf5;
    border-radius: 999px;
    font-size: 0.86rem;
    font-weight: 850;
}

.jst-ticket-date {
    color: var(--jst-muted);
    font-size: 0.86rem;
    font-weight: 650;
    text-align: right;
}

.jst-ticket-subject {
    margin-bottom: 12px;
    color: var(--jst-text);
    font-size: 1.2rem;
    font-weight: 850;
    letter-spacing: -0.025em;
}

.jst-ticket-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-bottom: 12px;
    color: var(--jst-muted);
    font-size: 0.9rem;
}

.jst-ticket-meta strong {
    color: #334155;
}

.jst-status, .jst-priority {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 27px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 850;
    letter-spacing: 0.055em;
    line-height: 1;
    text-transform: uppercase;
    white-space: nowrap;
}

.jst-status::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: currentColor;
}

.jst-status-open { background: #dbeafe; color: #1d4ed8; }
.jst-status-in_progress { background: #fef3c7; color: #b45309; }
.jst-status-pending { background: #ede9fe; color: #6d28d9; }
.jst-status-closed { background: #dcfce7; color: #15803d; }

.jst-priority-low { background: #ecfdf5; color: #047857; }
.jst-priority-normal { background: #eff6ff; color: #1d4ed8; }
.jst-priority-high { background: #fff7ed; color: #c2410c; }
.jst-priority-urgent { background: #fee2e2; color: #b91c1c; }

.jst-ticket-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.jst-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 11px 18px;
    color: #ffffff !important;
    background: linear-gradient(135deg, var(--jst-primary), #16a34a);
    border: 1px solid transparent;
    border-radius: 999px;
    box-shadow: 0 12px 24px rgba(20, 163, 75, 0.24);
    font-size: 0.94rem;
    font-weight: 850;
    line-height: 1;
    text-decoration: none !important;
    cursor: pointer;
    transition: transform var(--jst-transition), box-shadow var(--jst-transition), filter var(--jst-transition), background var(--jst-transition);
}

.jst-btn:hover {
    color: #ffffff !important;
    transform: translateY(-2px);
    box-shadow: 0 16px 34px rgba(20, 163, 75, 0.28);
    filter: saturate(1.06);
}

.jst-view-ticket {
    min-height: 38px;
    padding: 9px 14px;
    background: linear-gradient(135deg, var(--jst-accent), #4f46e5);
    box-shadow: 0 10px 22px rgba(79, 70, 229, 0.22);
    font-size: 0.86rem;
}

/* Modal Styles */
#jst-ticket-modal.jst-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: none;
    padding: clamp(16px, 3vw, 38px);
    overflow-y: auto;
    background: rgba(15, 23, 42, 0.62);
    backdrop-filter: blur(7px);
}

.jst-modal-content {
    width: min(980px, 100%);
    margin: 0 auto;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 26px;
    box-shadow: 0 34px 90px rgba(15, 23, 42, 0.35);
}

.jst-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 26px;
    color: #ffffff;
    background: linear-gradient(135deg, var(--jst-primary), var(--jst-accent));
}

.jst-modal-header h3 {
    margin: 0;
    color: #ffffff;
    font-size: 1.25rem;
    font-weight: 850;
    letter-spacing: -0.025em;
}

.jst-modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.26);
    border-radius: 999px;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    transition: background var(--jst-transition), transform var(--jst-transition);
}

.jst-modal-close:hover {
    background: rgba(255, 255, 255, 0.26);
    transform: rotate(90deg);
}

.jst-modal-body {
    max-height: min(78vh, 760px);
    overflow-y: auto;
    padding: clamp(20px, 3vw, 30px);
}

.jst-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}

.jst-info-item {
    display: grid;
    gap: 5px;
    padding: 15px;
    background: #f8fafc;
    border: 1px solid #eef2f7;
    border-radius: 16px;
}

.jst-info-item strong {
    color: var(--jst-muted);
    font-size: 0.72rem;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.jst-info-item span {
    color: var(--jst-text);
    font-weight: 700;
}

.jst-ticket-content,
.jst-ticket-responses,
.jst-add-response {
    margin-top: 18px;
    padding: 20px;
    background: #ffffff;
    border: 1px solid var(--jst-border);
    border-radius: 20px;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.05);
}

.jst-ticket-content h4,
.jst-ticket-responses h5,
.jst-add-response h5 {
    margin: 0 0 12px;
    color: var(--jst-text);
    font-weight: 850;
    letter-spacing: -0.02em;
}

.jst-response {
    margin: 14px 0;
    padding: 16px;
    background: #f8fafc;
    border: 1px solid #eef2f7;
    border-left: 4px solid #cbd5e1;
    border-radius: 16px;
}

.jst-admin-response {
    background: rgba(20, 163, 75, 0.06);
    border-left-color: var(--jst-primary);
}

.jst-user-response {
    background: rgba(99, 102, 241, 0.06);
    border-left-color: var(--jst-accent);
}

.jst-response-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-bottom: 8px;
}

.jst-response-date {
    color: var(--jst-muted);
    font-size: 0.82rem;
}

.jst-admin-badge {
    display: inline-flex;
    padding: 4px 8px;
    color: #ffffff;
    background: var(--jst-primary);
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 850;
    text-transform: uppercase;
}

.jst-form-control {
    display: block;
    width: 100%;
    min-height: 126px;
    padding: 12px 14px;
    color: var(--jst-text);
    background: #ffffff;
    border: 1px solid var(--jst-border);
    border-radius: 15px;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
    font-size: 0.98rem;
    resize: vertical;
    transition: border-color var(--jst-transition), box-shadow var(--jst-transition);
}

.jst-form-control:focus {
    outline: none;
    border-color: var(--jst-primary);
    box-shadow: 0 0 0 4px rgba(20, 163, 75, 0.13);
}

/* Loading Spinner */
.jst-loading-spinner {
    width: 34px;
    height: 34px;
    margin: 40px auto;
    border: 3px solid #dbeafe;
    border-top-color: var(--jst-primary);
    border-radius: 999px;
    animation: jstSpin 0.8s linear infinite;
}

@keyframes jstSpin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 1024px) {
    .jst-dashboard-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
    .jst-dashboard-header { flex-direction: column; align-items: flex-start; }
    .jst-user-info { width: 100%; flex-direction: column; align-items: flex-start; border-radius: 18px; }
    .jst-dashboard-stats { grid-template-columns: 1fr; }
    .jst-ticket-header { flex-direction: column; align-items: stretch; }
    .jst-ticket-date { text-align: left; }
}

/* Tracking Specific Styles */
.jst-tracking-container {
    max-width: 900px;
    margin: 40px auto;
}

.jst-tracking-form-card, .jst-tracking-help-card, .jst-ticket-progress-card {
    padding: 32px;
    background: #ffffff;
    border: 1px solid var(--jst-border);
    border-radius: 24px;
    box-shadow: var(--jst-shadow-soft);
    margin-bottom: 24px;
}

.jst-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.jst-help-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 24px;
    margin-top: 20px;
}

.jst-help-item strong {
    display: block;
    margin-bottom: 8px;
    color: var(--jst-primary);
    font-weight: 850;
}

.jst-help-item p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--jst-muted);
    line-height: 1.5;
}

.jst-progress-timeline {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    position: relative;
    padding-bottom: 20px;
}

.jst-progress-timeline::before {
    content: "";
    position: absolute;
    top: 15px;
    left: 40px;
    right: 40px;
    height: 2px;
    background: #e2e8f0;
    z-index: 1;
}

.jst-timeline-item {
    position: relative;
    z-index: 2;
    text-align: center;
    flex: 1;
}

.jst-timeline-marker {
    width: 32px;
    height: 32px;
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 50%;
    margin: 0 auto 12px;
    transition: all 0.3s ease;
}

.jst-timeline-completed .jst-timeline-marker {
    background: var(--jst-primary);
    border-color: var(--jst-primary);
    box-shadow: 0 0 0 4px rgba(20, 163, 75, 0.15);
}

.jst-timeline-current .jst-timeline-marker {
    background: #ffffff;
    border-color: var(--jst-primary);
    box-shadow: 0 0 0 4px rgba(20, 163, 75, 0.15);
}

.jst-timeline-content h5 {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 850;
}

.jst-timeline-content p {
    margin: 4px 0 0;
    font-size: 0.75rem;
    color: var(--jst-muted);
}

@media (max-width: 640px) {
    .jst-form-grid { grid-template-columns: 1fr; }
    .jst-progress-timeline { flex-direction: column; gap: 24px; align-items: flex-start; }
    .jst-progress-timeline::before { display: none; }
    .jst-timeline-item { text-align: left; display: flex; gap: 16px; }
    .jst-timeline-marker { margin: 0; }
}
