/**
 * Improved Frontend styles for Universal Support Tickets
 * Enhanced UI/UX with modern design principles
 */

/* ============================================
   RESET AND BASE STYLES
   ============================================ */
.ust-ticket-form-container.ust-improved *,
.ust-ticket-form-container.ust-improved *::before,
.ust-ticket-form-container.ust-improved *::after {
    box-sizing: border-box;
}

.ust-ticket-form-container.ust-improved {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #2d3748;
}

/* ============================================
   ENHANCED PROGRESS INDICATOR
   ============================================ */
.ust-progress-container {
    margin-bottom: 50px;
    background: #ffffff;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.ust-progress-steps {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.ust-progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
    flex: 0 0 auto;
}

.ust-step-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #e2e8f0;
    border: 3px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    color: #94a3b8;
    transition: all 0.3s ease;
    position: relative;
}

.ust-step-number {
    display: block;
}

.ust-step-check {
    display: none;
    font-size: 24px;
}

.ust-progress-step.ust-active .ust-step-circle {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-color: #10b981;
    color: white;
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.ust-progress-step.ust-completed .ust-step-circle {
    background: #10b981;
    border-color: #10b981;
    color: white;
}

.ust-progress-step.ust-completed .ust-step-number {
    display: none;
}

.ust-progress-step.ust-completed .ust-step-check {
    display: block;
}

.ust-step-label {
    margin-top: 12px;
    font-size: 14px;
    font-weight: 600;
    color: #64748b;
    text-align: center;
    transition: color 0.3s ease;
}

.ust-progress-step.ust-active .ust-step-label {
    color: #10b981;
}

.ust-progress-step.ust-completed .ust-step-label {
    color: #10b981;
}

.ust-progress-line {
    flex: 1;
    height: 3px;
    background: #e2e8f0;
    margin: 0 10px;
    position: relative;
    top: -20px;
    transition: background 0.3s ease;
}

.ust-progress-step.ust-completed + .ust-progress-line {
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
}

/* ============================================
   FORM HEADER
   ============================================ */
.ust-form-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 40px 30px;
    background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
    border-radius: 16px;
    border: 2px solid #d1fae5;
}

.ust-form-header h2 {
    margin: 0 0 12px 0;
    font-size: 2.5rem;
    font-weight: 800;
    color: #1e293b;
    letter-spacing: -0.5px;
}

.ust-form-subheader {
    margin: 0;
    font-size: 1.125rem;
    color: #64748b;
    font-weight: 400;
    max-width: 600px;
    margin: 0 auto;
}

/* ============================================
   FORM STEPS
   ============================================ */
.ust-form-step {
    display: none;
    background: #ffffff;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #f1f5f9;
    margin-bottom: 30px;
}

.ust-form-step.ust-step-active {
    display: block;
    animation: slideInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ust-step-header {
    display: flex;
    align-items: center;
    margin-bottom: 35px;
    padding-bottom: 25px;
    border-bottom: 2px solid #f1f5f9;
}

.ust-step-icon {
    font-size: 48px;
    margin-right: 20px;
    flex-shrink: 0;
}

.ust-step-title h3 {
    margin: 0 0 5px 0;
    font-size: 1.75rem;
    font-weight: 700;
    color: #1e293b;
}

.ust-step-description {
    margin: 0;
    font-size: 1rem;
    color: #64748b;
}

/* ============================================
   FORM GROUPS AND LAYOUT
   ============================================ */
.ust-form-row {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
}

.ust-form-group {
    margin-bottom: 28px;
}

.ust-half-width {
    flex: 1;
}

.ust-form-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #1e293b;
    font-size: 0.95rem;
}

.ust-form-group label .required {
    color: #ef4444;
    font-weight: 700;
    margin-left: 2px;
}

.ust-form-group label .ust-optional {
    color: #94a3b8;
    font-weight: 400;
    font-size: 0.875rem;
}

/* ============================================
   ENHANCED INPUT FIELDS
   ============================================ */
.ust-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.ust-input-wrapper input {
    width: 100%;
    padding: 14px 18px 14px 50px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background-color: #ffffff;
    color: #1e293b;
    font-family: inherit;
}

.ust-input-wrapper input:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
    background-color: #ffffff;
}

.ust-input-wrapper input::placeholder {
    color: #cbd5e1;
}

.ust-input-icon {
    position: absolute;
    left: 16px;
    font-size: 20px;
    pointer-events: none;
    opacity: 0.6;
}

.ust-input-wrapper input:focus + .ust-input-icon {
    opacity: 1;
}

.ust-field-hint {
    display: block;
    margin-top: 6px;
    font-size: 0.875rem;
    color: #64748b;
    font-style: italic;
}

/* ============================================
   CATEGORY GRID (VISUAL CARDS)
   ============================================ */
.ust-category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

.ust-category-card {
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.ust-category-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #10b981, #059669);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.ust-category-card:hover {
    border-color: #10b981;
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.15);
    transform: translateY(-4px);
}

.ust-category-card:hover::before {
    transform: scaleX(1);
}

.ust-category-card.ust-selected {
    border-color: #10b981;
    background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.2);
}

.ust-category-card.ust-selected::before {
    transform: scaleX(1);
}

.ust-category-icon {
    font-size: 40px;
    margin-bottom: 12px;
    display: block;
}

.ust-category-label {
    font-weight: 700;
    color: #1e293b;
    font-size: 1rem;
    margin-bottom: 6px;
}

.ust-category-description {
    font-size: 0.875rem;
    color: #64748b;
    line-height: 1.4;
}

.ust-category-check {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    background: #10b981;
    border-radius: 50%;
    color: white;
    display: none;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

.ust-category-card.ust-selected .ust-category-check {
    display: flex;
    animation: popIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes popIn {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

/* ============================================
   TEXTAREA
   ============================================ */
.ust-textarea-wrapper {
    position: relative;
}

.ust-textarea-wrapper textarea {
    width: 100%;
    padding: 16px 18px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background-color: #ffffff;
    color: #1e293b;
    font-family: inherit;
    resize: vertical;
    min-height: 180px;
}

.ust-textarea-wrapper textarea:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}

.ust-textarea-wrapper textarea::placeholder {
    color: #cbd5e1;
    line-height: 1.6;
}

.ust-character-count {
    text-align: right;
    margin-top: 8px;
    font-size: 0.875rem;
    color: #64748b;
    font-weight: 500;
}

.ust-character-count.warning {
    color: #f59e0b;
}

.ust-character-count.error {
    color: #ef4444;
}

/* ============================================
   PRIORITY SELECTOR (NEW FEATURE)
   ============================================ */
.ust-priority-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.ust-priority-option {
    cursor: pointer;
}

.ust-priority-option input[type="radio"] {
    display: none;
}

.ust-priority-card {
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
}

.ust-priority-option input[type="radio"]:checked + .ust-priority-card {
    border-color: #10b981;
    background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.2);
}

.ust-priority-card:hover {
    border-color: #10b981;
    transform: translateY(-2px);
}

.ust-priority-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.ust-priority-label {
    font-weight: 700;
    color: #1e293b;
    font-size: 1rem;
    margin-bottom: 4px;
}

.ust-priority-time {
    font-size: 0.875rem;
    color: #64748b;
}

/* ============================================
   FORM NAVIGATION
   ============================================ */
.ust-form-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 35px;
    padding-top: 25px;
    border-top: 2px solid #f1f5f9;
    gap: 16px;
}

.ust-form-navigation .ust-btn:only-child {
    margin-left: auto;
}

/* ============================================
   ENHANCED BUTTONS
   ============================================ */
.ust-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 28px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 140px;
    position: relative;
    overflow: hidden;
    font-family: inherit;
}

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

.ust-btn-primary,
.ust-btn-next,
.ust-btn-submit {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.ust-btn-primary:hover,
.ust-btn-next:hover,
.ust-btn-submit:hover:not(:disabled) {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
    transform: translateY(-2px);
}

.ust-btn-secondary,
.ust-btn-prev {
    background: #64748b;
    color: white;
    box-shadow: 0 4px 15px rgba(100, 116, 139, 0.3);
}

.ust-btn-secondary:hover,
.ust-btn-prev:hover {
    background: #475569;
    box-shadow: 0 6px 20px rgba(100, 116, 139, 0.4);
    transform: translateY(-2px);
}

.ust-btn-arrow {
    margin-left: 8px;
    font-size: 18px;
    transition: transform 0.3s ease;
}

.ust-btn-prev .ust-btn-arrow {
    margin-left: 0;
    margin-right: 8px;
}

.ust-btn:hover .ust-btn-arrow {
    transform: translateX(4px);
}

.ust-btn-prev:hover .ust-btn-arrow {
    transform: translateX(-4px);
}

.ust-submit-icon {
    margin-right: 8px;
    font-size: 18px;
}

/* Button loading state */
.ust-btn-loading {
    display: none;
}

.ust-btn.loading .ust-btn-text {
    display: none;
}

.ust-btn.loading .ust-btn-loading {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ust-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================
   ENHANCED SUCCESS MESSAGE
   ============================================ */
.ust-success-message {
    text-align: center;
    padding: 50px 40px;
    border-radius: 16px;
    margin: 20px 0;
    background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
    border: 2px solid #10b981;
    animation: fadeInScale 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.ust-success-animation {
    margin-bottom: 25px;
}

.ust-success-checkmark {
    display: inline-block;
}

.ust-checkmark {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: block;
    stroke-width: 3;
    stroke: #10b981;
    stroke-miterlimit: 10;
    box-shadow: inset 0px 0px 0px #10b981;
    animation: fill 0.4s ease-in-out 0.4s forwards, scale 0.3s ease-in-out 0.9s both;
}

.ust-checkmark-circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-width: 3;
    stroke-miterlimit: 10;
    stroke: #10b981;
    fill: none;
    animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.ust-checkmark-check {
    transform-origin: 50% 50%;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    stroke: #10b981;
    stroke-width: 3;
    animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}

@keyframes stroke {
    100% {
        stroke-dashoffset: 0;
    }
}

@keyframes scale {
    0%, 100% {
        transform: none;
    }
    50% {
        transform: scale3d(1.1, 1.1, 1);
    }
}

@keyframes fill {
    100% {
        box-shadow: inset 0px 0px 0px 30px #10b981;
    }
}

.ust-success-message h3 {
    margin: 0 0 12px 0;
    font-size: 1.875rem;
    font-weight: 700;
    color: #065f46;
}

.ust-success-message > p {
    color: #047857;
    font-size: 1.125rem;
    margin-bottom: 25px;
}

.ust-ticket-info {
    background: rgba(255, 255, 255, 0.8);
    padding: 20px;
    border-radius: 12px;
    margin: 25px 0;
    border: 1px solid #d1fae5;
}

.ust-ticket-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
}

.ust-ticket-info-row:not(:last-child) {
    border-bottom: 1px solid #d1fae5;
}

.ust-info-label {
    font-weight: 600;
    color: #047857;
}

.ust-info-value {
    font-weight: 700;
    color: #065f46;
    font-size: 1.125rem;
}

.ust-status-badge {
    background: #10b981;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.875rem;
}

.ust-success-actions {
    margin-top: 30px;
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ============================================
   ENHANCED ERROR MESSAGE
   ============================================ */
.ust-error-message {
    text-align: center;
    padding: 50px 40px;
    border-radius: 16px;
    margin: 20px 0;
    background: linear-gradient(135deg, #fef2f2 0%, #ffffff 100%);
    border: 2px solid #ef4444;
    animation: fadeInScale 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.ust-error-icon {
    font-size: 64px;
    margin-bottom: 20px;
    display: block;
}

.ust-error-message h3 {
    margin: 0 0 12px 0;
    font-size: 1.875rem;
    font-weight: 700;
    color: #991b1b;
}

.ust-error-message p {
    color: #dc2626;
    font-size: 1.125rem;
    margin-bottom: 25px;
}

.ust-error-actions {
    margin-top: 30px;
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ============================================
   LOGIN REQUIRED
   ============================================ */
.ust-login-required {
    text-align: center;
    padding: 60px 40px;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    border-radius: 16px;
    border: 2px solid #e2e8f0;
}

.ust-login-icon {
    font-size: 64px;
    margin-bottom: 20px;
    display: block;
}

.ust-login-required h3 {
    margin: 0 0 15px 0;
    font-size: 1.875rem;
    color: #1e293b;
    font-weight: 700;
}

.ust-login-required p {
    color: #64748b;
    font-size: 1.125rem;
    max-width: 500px;
    margin: 0 auto 30px;
}

.ust-login-actions {
    margin-top: 30px;
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ============================================
   FORM VALIDATION ERRORS
   ============================================ */
.ust-field-error {
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 6px;
    display: block;
    font-weight: 500;
}

.ust-form-group.has-error .ust-input-wrapper input,
.ust-form-group.has-error .ust-textarea-wrapper textarea {
    border-color: #ef4444;
    background-color: #fef2f2;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 768px) {
    .ust-ticket-form-container.ust-improved {
        padding: 20px 15px;
    }
    
    .ust-form-header {
        padding: 30px 20px;
    }
    
    .ust-form-header h2 {
        font-size: 2rem;
    }
    
    .ust-form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .ust-form-step {
        padding: 30px 20px;
    }
    
    .ust-step-header {
        flex-direction: column;
        text-align: center;
    }
    
    .ust-step-icon {
        margin-right: 0;
        margin-bottom: 15px;
    }
    
    .ust-category-grid {
        grid-template-columns: 1fr;
    }
    
    .ust-priority-selector {
        grid-template-columns: 1fr;
    }
    
    .ust-form-navigation {
        flex-direction: column-reverse;
    }
    
    .ust-progress-steps {
        flex-wrap: wrap;
    }
    
    .ust-step-label {
        font-size: 12px;
    }
    
    .ust-success-actions,
    .ust-error-actions,
    .ust-login-actions {
        flex-direction: column;
    }
    
    .ust-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .ust-form-header h2 {
        font-size: 1.75rem;
    }
    
    .ust-step-circle {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .ust-step-icon {
        font-size: 36px;
    }
    
    .ust-step-title h3 {
        font-size: 1.5rem;
    }
    
    .ust-progress-line {
        margin: 0 5px;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
.ust-btn:focus,
.ust-input-wrapper input:focus,
.ust-textarea-wrapper textarea:focus,
.ust-category-card:focus {
    outline: 3px solid #10b981;
    outline-offset: 2px;
}

.ust-category-card {
    -webkit-tap-highlight-color: transparent;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
