/**
 * Open Ticket Wizard - Component Styles
 *
 * Styles for the ticket creation wizard components:
 * - wizard-progress.php
 * - step-issue-form.php
 * - step-deflection.php
 * - step-review.php
 *
 * BEM naming: .wizard-progress, .wizard-step, .form-field, .deflection, .review-card, etc.
 */

/* ===== Progress Indicator ===== */
.wizard-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 1rem 0;
}

.wizard-progress__step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    cursor: default;
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.wizard-progress__step--active,
.wizard-progress__step--completed {
    opacity: 1;
}

.wizard-progress__step--completed {
    cursor: pointer;
}

.wizard-progress__circle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-full);
    background-color: var(--bg-tertiary);
    border: 2px solid var(--border-primary);
    transition: all 0.2s ease;
}

.wizard-progress__step--active .wizard-progress__circle {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.wizard-progress__step--completed .wizard-progress__circle {
    background-color: var(--success-bg);
    border-color: var(--success-border);
}

.wizard-progress__number {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.wizard-progress__step--active .wizard-progress__number {
    color: var(--brand-on-primary);
}

.wizard-progress__check {
    display: none;
    font-size: 1.25rem;
    color: var(--success-icon);
}

.wizard-progress__step--completed .wizard-progress__number {
    display: none;
}

.wizard-progress__step--completed .wizard-progress__check {
    display: block;
}

.wizard-progress__label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}

.wizard-progress__step--active .wizard-progress__label {
    color: var(--text-primary);
    font-weight: 600;
}

.wizard-progress__connector {
    flex: 0 0 4rem;
    height: 2px;
    background-color: var(--border-primary);
    margin: 0 0.5rem;
    margin-bottom: 1.5rem;
}

/* ===== Wizard Step ===== */
.wizard-step {
    display: none;
    flex-direction: column;
    gap: 1.5rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-lg);
    padding: 2rem;
}

.wizard-step--active {
    display: flex;
}

.wizard-step__header {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.wizard-step__header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.wizard-step__description {
    color: var(--text-muted);
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.5;
}

.wizard-step__body {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.wizard-step__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-secondary);
}

.wizard-step__footer-left,
.wizard-step__footer-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* ===== Form Fields ===== */
.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-field__label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-field__required {
    color: var(--danger-icon);
    margin-left: 0.125rem;
}

.form-field__input,
.form-field__select {
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-field__input:focus,
.form-field__select:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-primary-transparent);
}

.form-field__input::placeholder {
    color: var(--text-muted);
}

.form-field__select {
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

/* Dark mode select arrow */
.darkmode .form-field__select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a0a0a0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

/* ===== Issue Form Editor (TinyMCE wrapper) ===== */
.issue-form__editor-wrapper {
    border-radius: var(--radius-md);
    overflow: hidden;
}

.issue-form__editor {
    display: none;
}

/* TinyMCE customizations */
.issue-form__editor-wrapper .tox-tinymce {
    border: 1px solid var(--border-primary) !important;
    border-radius: var(--radius-md) !important;
}

.issue-form__editor-wrapper .tox-editor-header {
    border-bottom: 1px solid var(--border-secondary) !important;
}

/* Dark mode TinyMCE adjustments */
.darkmode .issue-form__editor-wrapper .tox.tox-tinymce {
    border-color: var(--border-primary) !important;
}

.darkmode .issue-form__editor-wrapper .tox .tox-editor-header {
    background-color: var(--bg-tertiary) !important;
    border-bottom-color: var(--border-secondary) !important;
}

.darkmode .issue-form__editor-wrapper .tox .tox-toolbar__primary {
    background-color: var(--bg-tertiary) !important;
}

.darkmode .issue-form__editor-wrapper .tox .tox-tbtn {
    background-color: transparent !important;
    color: var(--text-secondary) !important;
}

.darkmode .issue-form__editor-wrapper .tox .tox-tbtn svg {
    fill: var(--text-secondary) !important;
}

.darkmode .issue-form__editor-wrapper .tox .tox-tbtn:hover {
    background-color: var(--hover-bg) !important;
}

.darkmode .issue-form__editor-wrapper .tox .tox-tbtn--enabled,
.darkmode .issue-form__editor-wrapper .tox .tox-tbtn--enabled:hover {
    background-color: var(--active-bg) !important;
}

.darkmode .issue-form__editor-wrapper .tox .tox-split-button:hover {
    box-shadow: none !important;
}

.darkmode .issue-form__editor-wrapper .tox .tox-toolbar__group:not(:last-of-type) {
    border-right-color: var(--border-secondary) !important;
}

.darkmode .issue-form__editor-wrapper .tox .tox-anchorbar {
    background-color: var(--bg-tertiary) !important;
}

.darkmode .issue-form__editor-wrapper .tox .tox-edit-area__iframe {
    background-color: var(--bg-primary) !important;
}

/* Light mode TinyMCE adjustments */
.lightmode .issue-form__editor-wrapper .tox.tox-tinymce {
    border-color: var(--border-primary) !important;
}

.lightmode .issue-form__editor-wrapper .tox .tox-editor-header {
    background-color: #ffffff !important;
    border-bottom-color: var(--border-secondary) !important;
}

.lightmode .issue-form__editor-wrapper .tox .tox-toolbar__primary {
    background-color: #ffffff !important;
}

.lightmode .issue-form__editor-wrapper .tox .tox-tbtn {
    background-color: transparent !important;
    color: var(--text-secondary) !important;
}

.lightmode .issue-form__editor-wrapper .tox .tox-tbtn svg {
    fill: var(--text-secondary) !important;
}

.lightmode .issue-form__editor-wrapper .tox .tox-tbtn:hover {
    background-color: var(--hover-bg) !important;
}

.lightmode .issue-form__editor-wrapper .tox .tox-tbtn--enabled,
.lightmode .issue-form__editor-wrapper .tox .tox-tbtn--enabled:hover {
    background-color: var(--active-bg) !important;
}

.lightmode .issue-form__editor-wrapper .tox .tox-toolbar__group:not(:last-of-type) {
    border-right-color: var(--border-secondary) !important;
}

.lightmode .issue-form__editor-wrapper .tox .tox-edit-area__iframe {
    background-color: #ffffff !important;
}

/* ===== Issue Form Attachments ===== */
.issue-form__attachments {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.issue-form__attachments-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem;
    border: 2px dashed var(--border-primary);
    border-radius: var(--radius-md);
    background-color: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.issue-form__attachments-zone:hover {
    border-color: var(--brand-primary);
    background-color: var(--bg-secondary);
}

.issue-form__attachments-zone--active {
    border-color: var(--brand-primary);
    background-color: var(--brand-primary-transparent);
}

.issue-form__attachments-zone .material-symbols-outlined {
    font-size: 1.5rem;
    opacity: 0.5;
}

.issue-form__attachments-zone p {
    margin: 0;
    font-size: 0.8125rem;
}

.issue-form__attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.issue-form__attachment-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.625rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
}

.issue-form__attachment-item .material-symbols-outlined {
    font-size: 1rem;
    color: var(--text-muted);
}

.issue-form__attachment-item--uploading {
    opacity: 0.7;
}

.issue-form__attachment-item--uploading .material-symbols-outlined {
    animation: issue-form-pulse 1s ease-in-out infinite;
}

@keyframes issue-form-pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.issue-form__attachment-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.issue-form__attachment-size {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.issue-form__attachment-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.375rem;
    margin-left: 0.25rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.issue-form__attachment-remove:hover {
    color: var(--danger-icon);
    background-color: var(--danger-bg);
}

.issue-form__attachment-remove .material-symbols-outlined {
    font-size: 1rem;
}

/* Inline image upload indicator */
.issue-form__upload-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background-color: var(--info-bg);
    border: 1px solid var(--info-border);
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    color: var(--info-text);
}

.issue-form__spinner {
    display: inline-block;
    width: 0.875rem;
    height: 0.875rem;
    border: 2px solid var(--info-icon);
    border-top-color: transparent;
    border-radius: 50%;
    animation: issue-form-spin 0.8s linear infinite;
}

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

/* ===== Footer Button Layout ===== */
/* Note: Button styles come from .btn, .btn-primary, .btn-secondary in main.css */

.wizard-step__footer .btn .material-symbols-outlined {
    font-size: 1.125rem;
}

/* ===== Deflection (Step 2) ===== */

/* Header state management - show/hide based on parent class */
.deflection__header-loading,
.deflection__header-results,
.deflection__header-empty {
    display: none;
}

/* Loading state (default) */
.deflection--loading .deflection__header-loading {
    display: block;
}

/* Results found state */
.deflection--results .deflection__header-results {
    display: block;
}

/* No results state */
.deflection--empty .deflection__header-empty {
    display: block;
}

.deflection__loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 3rem;
}

.deflection__spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid var(--border-primary);
    border-top-color: var(--brand-primary);
    border-radius: 50%;
    animation: deflection-spin 0.8s linear infinite;
}

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

/* Rotating loading messages - container reserves space, messages stack */
.deflection__loading-messages {
    position: relative;
    min-height: 1.5em;
    display: flex;
    align-items: center;
    justify-content: center;
}

.deflection__loading-message {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9375rem;
    opacity: 0;
    position: absolute;
    transition: opacity 0.3s ease;
    white-space: nowrap;
}

.deflection__loading-message.is-active {
    opacity: 1;
}

.deflection__section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.25rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-lg);
}

.deflection__section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-accent);
}

.deflection__section-header h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.deflection__section-header .material-symbols-outlined {
    font-size: 1.25rem;
    color: var(--brand-primary);
}

.deflection__articles-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.deflection__article-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: all 0.15s ease;
}

.deflection__article-card:hover {
    border-color: var(--brand-primary);
    background-color: var(--bg-primary);
}

.deflection__article-card > .material-symbols-outlined {
    color: var(--text-muted);
    font-size: 1.25rem;
    flex-shrink: 0;
}

.deflection__article-card > .material-symbols-outlined:last-child {
    margin-left: auto;
    font-size: 1rem;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.deflection__article-card:hover > .material-symbols-outlined:last-child {
    opacity: 1;
}

.deflection__article-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    gap: 0.25rem;
}

.deflection__article-title {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.deflection__article-excerpt {
    font-size: 0.8125rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.deflection__no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 3rem;
    text-align: center;
}

.deflection__no-results .material-symbols-outlined {
    font-size: 3rem;
    color: var(--text-muted);
    opacity: 0.5;
}

.deflection__no-results p {
    color: var(--text-muted);
    margin: 0;
    font-size: 0.9375rem;
    max-width: 400px;
}

/* ===== Review Card (Step 3) ===== */
.review-card {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background-color: var(--bg-tertiary);
}

.review-card__row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
}

.review-card__row:last-child {
    border-bottom: none;
}

.review-card__row--header {
    background-color: var(--bg-tertiary);
}

.review-card__label {
    flex: 0 0 120px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.review-card__value {
    flex: 1;
    color: var(--text-primary);
    font-size: 0.9375rem;
}


.review-card__content {
    padding: 1.25rem;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.9375rem;
}

.review-card__content p {
    margin: 0 0 0.75rem 0;
}

.review-card__content p:last-child {
    margin-bottom: 0;
}

.review-card__content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
}

.review-card__attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    background-color: var(--bg-secondary);
}

.review-card__attachment-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    color: var(--text-primary);
}

.review-card__attachment-item .material-symbols-outlined {
    font-size: 1rem;
    color: var(--text-muted);
}

/* Submit button loading state */
.btn-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: btn-spin 0.8s linear infinite;
}

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

#step3-submit.btn--loading .step3-submit__text,
#step3-submit.btn--loading .step3-submit__icon {
    display: none;
}

#step3-submit.btn--loading .step3-submit__loading {
    display: inline-flex !important;
    align-items: center;
    gap: 0.5rem;
}

/* ===== Responsive - Tablet ===== */
@media screen and (max-width: 768px) {
    .wizard-progress__connector {
        flex: 0 0 2rem;
    }

    .wizard-progress__label {
        display: none;
    }

    .wizard-progress__connector {
        margin-bottom: 0;
    }

    .wizard-step {
        padding: 1.5rem;
        gap: 1.25rem;
    }

    .wizard-step__header h1 {
        font-size: 1.25rem;
    }

    .wizard-step__description {
        font-size: 0.875rem;
    }

    .issue-form__attachments-zone {
        padding: 1.25rem;
    }

    .deflection__section {
        padding: 1rem;
    }

    .deflection__article-card {
        padding: 0.75rem;
    }

    .review-card__row {
        padding: 0.875rem 1rem;
    }

    .review-card__label {
        flex: 0 0 100px;
    }

    .review-card__content {
        padding: 1rem;
    }

    .review-card__attachments {
        padding: 0.875rem 1rem;
    }
}

/* ===== Responsive - Mobile ===== */
@media screen and (max-width: 480px) {
    .wizard-progress {
        padding: 0.75rem 0;
    }

    .wizard-progress__circle {
        width: 2rem;
        height: 2rem;
    }

    .wizard-progress__number {
        font-size: 0.75rem;
    }

    .wizard-progress__check {
        font-size: 1rem;
    }

    .wizard-progress__connector {
        flex: 0 0 1.5rem;
        margin: 0 0.25rem;
    }

    .wizard-step {
        padding: 1.25rem;
        gap: 1rem;
    }

    .wizard-step__header h1 {
        font-size: 1.125rem;
    }

    .wizard-step__description {
        font-size: 0.8125rem;
    }

    .wizard-step__body {
        gap: 1rem;
    }

    .wizard-step__footer {
        flex-direction: column;
        gap: 0.75rem;
        padding-top: 1.25rem;
    }

    .wizard-step__footer-left,
    .wizard-step__footer-right {
        width: 100%;
    }

    .wizard-step__footer-left {
        order: 2;
    }

    .wizard-step__footer-right {
        order: 1;
        flex-direction: column;
    }

    .wizard-step__footer .btn {
        width: 100%;
        justify-content: center;
    }

    .form-field__input,
    .form-field__select {
        padding: 0.625rem 0.875rem;
        font-size: 1rem; /* Prevents zoom on iOS */
    }

    .issue-form__attachments-zone {
        padding: 1rem;
    }

    .issue-form__attachments-zone .material-symbols-outlined {
        font-size: 1.25rem;
    }

    .issue-form__attachments-zone p {
        font-size: 0.75rem;
    }

    .deflection__loading {
        padding: 2rem;
    }

    .deflection__section {
        padding: 1rem;
        gap: 0.75rem;
    }

    .deflection__article-card {
        padding: 0.625rem 0.75rem;
    }

    .deflection__article-excerpt {
        display: none;
    }

    .deflection__no-results {
        padding: 2rem;
    }

    .deflection__no-results .material-symbols-outlined {
        font-size: 2.5rem;
    }

    .review-card__row {
        flex-wrap: wrap;
        padding: 0.75rem 1rem;
    }

    .review-card__label {
        flex: 1 1 100%;
        margin-bottom: 0.25rem;
    }

    .review-card__value {
        flex: 1 1 calc(100% - 2.5rem);
    }

    .review-card__content {
        padding: 0.875rem 1rem;
    }

    .review-card__attachments {
        padding: 0.75rem 1rem;
    }

    .issue-form__editor-wrapper .tox .tox-toolbar__primary {
        flex-wrap: wrap !important;
    }

    .issue-form__editor-wrapper .tox .tox-toolbar__group {
        flex-wrap: wrap !important;
    }
}
