/*
 * Enhanced Agent Portal styles for Universal Support Tickets
 * Covers agent login, registration, dashboard, ticket list, and modal workflows.
 */

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

.ust-agent-login,
.ust-agent-registration,
.ust-agent-dashboard,
.ust-agent-registration-page,
.ust-agent-registration-page * ,
.ust-agent-login *,
.ust-agent-registration *,
.ust-agent-dashboard * {
    box-sizing: border-box;
}

.ust-agent-login,
.ust-agent-registration {
    width: min(100%, 480px);
    margin: 48px auto;
    padding: clamp(28px, 5vw, 42px);
    color: var(--ust-agent-text);
    background:
        linear-gradient(#ffffff, #ffffff) padding-box,
        linear-gradient(135deg, rgba(20, 163, 75, 0.55), rgba(99, 102, 241, 0.45)) border-box;
    border: 1px solid transparent;
    border-radius: 28px;
    box-shadow: var(--ust-agent-shadow);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    position: relative;
    overflow: hidden;
}

.ust-agent-login::before,
.ust-agent-registration::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 8px;
    background: linear-gradient(90deg, var(--ust-agent-primary), #16a34a, var(--ust-agent-accent));
}

.ust-agent-login::after,
.ust-agent-registration::after {
    content: "";
    position: absolute;
    top: -78px;
    right: -76px;
    width: 190px;
    height: 190px;
    border-radius: 999px;
    background: rgba(20, 163, 75, 0.09);
    pointer-events: none;
}

.ust-agent-login h2,
.ust-agent-registration h2 {
    position: relative;
    margin: 0 0 10px;
    color: var(--ust-agent-text);
    font-size: clamp(1.85rem, 4vw, 2.45rem);
    font-weight: 850;
    letter-spacing: -0.045em;
    text-align: center;
}

.ust-agent-registration > p,
.ust-agent-login > p {
    position: relative;
    margin: 0 auto 26px;
    max-width: 360px;
    color: var(--ust-agent-muted);
    text-align: center;
}

.ust-form,
.ust-registration-form {
    position: relative;
    z-index: 1;
}

.ust-form-row {
    margin-bottom: 18px;
}

.ust-form-row label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    color: #334155;
    font-size: 0.9rem;
    font-weight: 800;
}

.ust-form-row small {
    display: block;
    margin-top: 7px;
    color: var(--ust-agent-muted);
    font-size: 0.82rem;
}

.ust-form-row input,
.ust-form-row select,
.ust-form-row textarea,
.ust-filter-group input,
.ust-filter-group select,
.ust-action-group select,
.ust-agent-add-response textarea {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    color: var(--ust-agent-text);
    background: #ffffff;
    border: 1px solid var(--ust-agent-border);
    border-radius: 15px;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
    font-size: 0.98rem;
    transition: border-color var(--ust-agent-transition), box-shadow var(--ust-agent-transition), background var(--ust-agent-transition);
}

.ust-form-row input::placeholder,
.ust-filter-group input::placeholder,
.ust-agent-add-response textarea::placeholder {
    color: #94a3b8;
}

.ust-form-row input:focus,
.ust-form-row select:focus,
.ust-form-row textarea:focus,
.ust-filter-group input:focus,
.ust-filter-group select:focus,
.ust-action-group select:focus,
.ust-agent-add-response textarea:focus {
    outline: none;
    border-color: var(--ust-agent-primary);
    box-shadow: 0 0 0 4px rgba(20, 163, 75, 0.13);
}

.ust-form-row input[readonly] {
    color: #64748b;
    background: #f8fafc;
}

.ust-button,
.ust-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(--ust-agent-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(--ust-agent-transition), box-shadow var(--ust-agent-transition), filter var(--ust-agent-transition), background var(--ust-agent-transition);
}

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

.ust-button:disabled,
.ust-btn:disabled {
    cursor: not-allowed;
    opacity: 0.68;
    transform: none;
}

.ust-button-primary {
    width: 100%;
    margin-top: 4px;
}

.ust-message,
.ust-error-message,
.ust-success-message {
    margin: 14px 0;
    padding: 14px 16px;
    border-radius: 15px;
    font-weight: 700;
}

.ust-message.success,
.ust-success-message {
    color: #065f46;
    background: #d1fae5;
    border: 1px solid #a7f3d0;
}

.ust-message.error,
.ust-error-message {
    color: #991b1b;
    background: #fee2e2;
    border: 1px solid #fecaca;
}

.ust-agent-dashboard {
    max-width: 1240px;
    margin: 32px auto;
    padding: clamp(18px, 2.5vw, 32px);
    color: var(--ust-agent-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(--ust-agent-bg);
    border: 1px solid rgba(226, 232, 240, 0.86);
    border-radius: 30px;
    box-shadow: var(--ust-agent-shadow);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
}

.ust-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(--ust-agent-primary), #16a34a 48%, var(--ust-agent-accent));
    border: none;
    border-radius: 26px;
    box-shadow: 0 22px 44px rgba(20, 163, 75, 0.23);
}

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

.ust-dashboard-header 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;
}

.ust-agent-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;
}

.ust-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(--ust-agent-transition), transform var(--ust-agent-transition);
}

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

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

.ust-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(--ust-agent-radius);
    box-shadow: var(--ust-agent-shadow-soft);
    transition: transform var(--ust-agent-transition), box-shadow var(--ust-agent-transition), border-color var(--ust-agent-transition);
}

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

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

.ust-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);
}

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

.ust-stat-label {
    color: var(--ust-agent-muted);
    font-size: 0.78rem;
    font-weight: 850;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.ust-stat-open .ust-stat-number { color: #2563eb; }
.ust-stat-progress .ust-stat-number { color: #d97706; }
.ust-stat-closed .ust-stat-number { color: #059669; }
.ust-stat-open::before { background: rgba(37, 99, 235, 0.11); }
.ust-stat-progress::before { background: rgba(217, 119, 6, 0.12); }
.ust-stat-closed::before { background: rgba(5, 150, 105, 0.12); }
.ust-stat-open::after { border-color: #2563eb; }
.ust-stat-progress::after { border-color: #d97706; }
.ust-stat-closed::after { border-color: #059669; }

.ust-dashboard-filters {
    margin-bottom: 24px;
    padding: 18px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--ust-agent-border);
    border-radius: var(--ust-agent-radius);
    box-shadow: var(--ust-agent-shadow-soft);
}

.ust-filter-group {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(170px, 220px) auto;
    gap: 14px;
    align-items: center;
}

.ust-filter-group .ust-button,
#ust-agent-filter-btn {
    white-space: nowrap;
}

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

.ust-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(--ust-agent-transition), box-shadow var(--ust-agent-transition), border-color var(--ust-agent-transition), background var(--ust-agent-transition);
}

.ust-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);
}

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

.ust-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;
}

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

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

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

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

.ust-ticket-status,
.ust-ticket-priority,
.ust-status,
.ust-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;
}

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

.ust-ticket-status.open,
.ust-status-open { background: #dbeafe; color: #1d4ed8; }
.ust-ticket-status.in_progress,
.ust-status-in_progress { background: #fef3c7; color: #b45309; }
.ust-ticket-status.pending,
.ust-status-pending { background: #ede9fe; color: #6d28d9; }
.ust-ticket-status.closed,
.ust-status-closed { background: #dcfce7; color: #15803d; }
.ust-ticket-priority.low,
.ust-priority-low { background: #ecfdf5; color: #047857; }
.ust-ticket-priority.normal,
.ust-priority-normal { background: #eff6ff; color: #1d4ed8; }
.ust-ticket-priority.high,
.ust-priority-high { background: #fff7ed; color: #c2410c; }
.ust-ticket-priority.urgent,
.ust-priority-urgent { background: #fee2e2; color: #b91c1c; }

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

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

.ust-loading,
.ust-no-tickets {
    margin: 8px;
    padding: clamp(42px, 7vw, 70px) 28px;
    color: var(--ust-agent-muted);
    text-align: center;
    background: #ffffff;
    border: 1px dashed #cbd5e1;
    border-radius: 20px;
}

.ust-loading::before {
    content: "";
    display: block;
    width: 34px;
    height: 34px;
    margin: 0 auto 14px;
    border: 3px solid #dbeafe;
    border-top-color: var(--ust-agent-primary);
    border-radius: 999px;
    animation: ustAgentSpin 0.8s linear infinite;
}

.ust-no-tickets h3 {
    margin: 0 0 8px;
    color: var(--ust-agent-text);
    font-size: 1.35rem;
    font-weight: 850;
}

.ust-agent-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);
}

.ust-agent-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);
}

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

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

.ust-agent-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(--ust-agent-transition), transform var(--ust-agent-transition);
}

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

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

.ust-agent-ticket-details {
    color: var(--ust-agent-text);
    line-height: 1.6;
}

.ust-ticket-actions-top {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 22px;
    padding: 16px;
    background: #f8fafc;
    border: 1px solid var(--ust-agent-border);
    border-radius: 18px;
}

.ust-action-group {
    display: flex;
    flex: 1 1 220px;
    align-items: center;
    gap: 10px;
}

.ust-action-group label {
    margin: 0;
    color: #475569;
    font-weight: 850;
    white-space: nowrap;
}

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

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

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

.ust-info-item span,
.ust-info-item a {
    color: var(--ust-agent-text);
    font-weight: 700;
}

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

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

.ust-description-content,
.ust-response-content {
    color: #334155;
}

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

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

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

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

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

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

.ust-agent-add-response textarea {
    display: block;
    width: 100%;
    min-height: 126px;
    resize: vertical;
}

.ust-response-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 14px;
}

.ust-response-actions label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--ust-agent-muted);
    font-weight: 650;
}

.ust-agent-registration-page {
    max-width: 560px;
    margin: 54px auto;
    padding: 0 20px;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
}

.ust-registration-container {
    overflow: hidden;
    padding: clamp(28px, 5vw, 44px);
    background: #ffffff;
    border: 1px solid var(--ust-agent-border);
    border-radius: 28px;
    box-shadow: var(--ust-agent-shadow);
}

.ust-registration-header {
    margin-bottom: 28px;
    text-align: center;
}

.ust-registration-header h1 {
    margin: 0 0 10px;
    color: var(--ust-agent-text);
    font-size: clamp(2rem, 4vw, 2.65rem);
    font-weight: 850;
    letter-spacing: -0.045em;
}

.ust-registration-header p {
    margin: 0;
    color: var(--ust-agent-muted);
}

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

@media (max-width: 1024px) {
    .ust-dashboard-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ust-filter-group {
        grid-template-columns: 1fr 1fr;
    }

    .ust-filter-group .ust-button,
    #ust-agent-filter-btn {
        grid-column: 1 / -1;
    }
}

@media (max-width: 760px) {
    .ust-agent-dashboard {
        margin: 16px auto;
        border-radius: 22px;
    }

    .ust-dashboard-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .ust-agent-info {
        align-items: flex-start;
        flex-direction: column;
        width: 100%;
        border-radius: 18px;
    }

    .ust-dashboard-stats,
    .ust-filter-group {
        grid-template-columns: 1fr;
    }

    .ust-ticket-header,
    .ust-response-actions,
    .ust-action-group {
        align-items: stretch;
        flex-direction: column;
    }

    .ust-ticket-date {
        text-align: left;
    }

    .ust-agent-modal {
        padding: 10px;
    }

    .ust-agent-modal-content {
        border-radius: 20px;
    }
}

@media (max-width: 520px) {
    .ust-agent-login,
    .ust-agent-registration {
        margin: 18px auto;
        border-radius: 22px;
    }

    .ust-dashboard-stats {
        gap: 12px;
    }

    .ust-stat-card {
        min-height: 118px;
        padding: 18px;
    }
}
