/**
 * Wizard Validation Styles
 *
 * Styles for step completion indicators, badges, and validation states
 * in the DienstAssistent evaluation wizard.
 */

/* ===== Sidenav Step States ===== */

/* Incomplete step: grey text (lighter, faded appearance) */
.wizard-sidenav a.step-incomplete {
    color: rgba(var(--bs-body-color-rgb), 0.5);
}

.wizard-sidenav a.step-incomplete:hover {
    opacity: 0.8 !important;
}

/* Complete step: bright text (fully visible) */
.wizard-sidenav a.step-complete {
    color: rgba(var(--bs-body-color-rgb), 1) !important;
    opacity: 1 !important;
    font-weight: 500;
}

/* Active step with complete status */
.wizard-sidenav a.active.step-complete {
    color: rgba(var(--bs-body-color-rgb), 1) !important;
    opacity: 1 !important;
    font-weight: 600;
    border-left: 5px solid #83da42;
}

/* Active step with incomplete status (should still show as grey/faded) */
.wizard-sidenav a.active.step-incomplete {
    color: rgba(var(--bs-body-color-rgb), 0.5);
    opacity: 0.8 !important;
    font-weight: 500;
    background-color: transparent;
    border-left: 5px solid #83da42;  /* Red border for incomplete active step */
}

/* Default active step styling (fallback) */
.wizard-sidenav a.active {
    font-weight: 600;
    border-left: 3px solid #83da42;
    opacity: 1 !important;
}

/* Preserve active state styling during HTMX requests (prevent flicker) */
.wizard-sidenav a[hx-boost].active,
.wizard-sidenav a[hx-boost].active:hover,
.wizard-sidenav a[hx-boost].active:active {
    border-left: 5px solid #83da42 !important;
    font-weight: 600 !important;
}

/* Remove blue focus border on all sidenav links */
.wizard-sidenav a:focus,
.wizard-sidenav a:focus-visible,
.wizard-sidenav .nav-link:focus,
.wizard-sidenav .nav-link:focus-visible,
.wizard-sidenav .sb-sidenav-menu-heading:focus,
.wizard-sidenav .sb-sidenav-menu-heading:focus-visible {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

/* ===== Step Badge (Red Dot for Incomplete Visited Steps) ===== */

.step-badge {
    display: inline-block;
    margin-left: 8px;
    font-size: 1em;
    line-height: 1;
    vertical-align: middle;
    animation: pulseBadge 2s ease-in-out infinite;
    width: 0.8em;
    height: 0.8em;
    background-color: #83da42;
    border-radius: 2px;
    color: transparent; /* verhindert schwarze Kreise durch Textfarbe */
}

@keyframes pulseBadge {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Remove badge animation on hover to make it less distracting */
.wizard-sidenav a:hover .step-badge {
    animation: none;
    opacity: 1;
}

/* ===== Field Validation States ===== */

/* Invalid field styling (Bootstrap override for better visibility) */
.form-control.is-invalid,
.form-select.is-invalid {
    border-color: #dc3545;
    padding-right: calc(1.5em + 0.75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25);
}

/* Invalid feedback message */
.invalid-feedback {
    display: none;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: #dc3545;
}

.invalid-feedback.d-block {
    display: block !important;
}

/* Checkboxes and radios validation */
.form-check-input.is-invalid {
    border-color: #dc3545;
}

.form-check-input.is-invalid:checked {
    background-color: #dc3545;
    border-color: #dc3545;
}

/* ===== Modal Styling ===== */

/* Modal body text styling for consistency */
#wizardNavigationModal .modal-body {
    color: #6c757d;
}

/* ===== Wizard Progress Indicator ===== */

.wizard-progress {
    margin-bottom: 2rem;
}

.wizard-progress-bar {
    height: 8px;
    background-color: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.wizard-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #0d6efd 0%, #0b5ed7 100%);
    transition: width 0.3s ease;
}

.wizard-progress-text {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: #6c757d;
    text-align: center;
}

/* ===== Required Field Indicator ===== */

label.required::after,
.form-label.required::after,
span.required::after {
    content: " *";
    color: var(--bs-body-color);
    font-weight: bold;
}

/* ===== Form Group Spacing ===== */

.form-group {
    margin-bottom: 1.5rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

/* ===== Wizard Buttons ===== */

.wizard-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #dee2e6;
}

.wizard-buttons .btn {
    min-width: 120px;
}

/* ===== Responsive Adjustments ===== */

@media (max-width: 768px) {
    .wizard-sidenav a {
        font-size: 0.9rem;
        padding: 0.5rem;
    }

    .step-badge {
        font-size: 1em;
        margin-left: 4px;
    }

    .wizard-buttons {
        flex-direction: column;
        gap: 1rem;
    }

    .wizard-buttons .btn {
        width: 100%;
    }
}

/* ===== Loading State ===== */

.wizard-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.wizard-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2rem;
    height: 2rem;
    margin-top: -1rem;
    margin-left: -1rem;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0d6efd;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== Accessibility ===== */

.step-badge[aria-label]::before {
    content: attr(aria-label);
    position: absolute;
    left: -9999px;
}

/* Focus states for keyboard navigation */
.wizard-sidenav a:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

.form-control:focus,
.form-select:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* ===== Persistent Placeholder Styles ===== */

/* Style for textarea with placeholder text that hasn't been edited yet */
textarea.placeholder-active {
    color: #6c757d;
    font-style: italic;
}

/* When textarea is focused, remove placeholder styling */
textarea.placeholder-active:focus {
    color: inherit;
    font-style: normal;
}

/* ===== AI Generation Overlay ===== */

/* Overlay that covers the textarea before initial text generation */
.ai-generate-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Use color-mix to make theme variable semi-transparent (works in light/dark mode) */
    background-color: color-mix(in srgb, var(--bs-body-bg-2) 25%, transparent) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    /* NO opacity property here - button needs to be fully opaque */
    visibility: visible;
    pointer-events: none; /* Allow hover/click to pass through to button */
}

/* Disable textarea when overlay is visible to prevent editing before generation */
.position-relative:has(.ai-generate-overlay:not(.hidden)) .ai-text-output {
    pointer-events: none;
    user-select: none;
}

/* Button inside overlay should be interactive */
.ai-generate-overlay .ai-generate-btn {
    pointer-events: auto; /* Re-enable pointer events for the button */
}

/* Button state classes for validation feedback */
.ai-generate-btn.btn-disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

.ai-generate-btn.btn-enabled {
    opacity: 1 !important;
    cursor: pointer !important;
}

/* Hidden state for overlay (when text exists) */
.ai-generate-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* ===== Print Styles ===== */

@media print {
    .wizard-sidenav,
    .wizard-buttons,
    .step-badge {
        display: none !important;
    }

    .wizard-progress {
        display: none !important;
    }

    .ai-generate-overlay {
        display: none !important;
    }
}
