/* ============================================
   FORM WIZARD STYLES
   Multi-step form navigation with progress tracking
   ============================================ */

/* ===== CSS Variables ===== */
:root {
    --wizard-primary: #2563eb;
    --wizard-primary-dark: #1d4ed8;
    --wizard-success: #10b981;
    --wizard-success-dark: #059669;
    --wizard-warning: #f59e0b;
    --wizard-gray: #94a3b8;
    --wizard-gray-light: #e2e8f0;
    --wizard-text: #334155;
    --wizard-bg: #ffffff;
    --wizard-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    --wizard-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Wizard Navigation Container ===== */
.wizard-navigation {
    position: sticky;
    top: 60px;
    z-index: 50;
    /* Lower than tooltips (z-index: 1000+) */
    background: var(--wizard-bg);
    padding: 16px 20px;
    margin: 0 auto 24px auto;
    max-width: 720px;
    border-radius: 16px;
    box-shadow: var(--wizard-shadow);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 16px;
    border: 1px solid var(--wizard-gray-light);
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
}

/* ===== Navigation Buttons ===== */
.wizard-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--wizard-transition);
    min-width: auto;
    white-space: nowrap;
    justify-content: center;
    flex-shrink: 0;
}

.wizard-prev {
    background: var(--wizard-gray-light);
    color: var(--wizard-text);
}

.wizard-prev:hover:not(:disabled) {
    background: #cbd5e1;
    transform: translateX(-2px);
}

.wizard-prev:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.wizard-next {
    background: linear-gradient(135deg, var(--wizard-primary) 0%, var(--wizard-primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}

.wizard-next:hover:not(:disabled) {
    transform: translateX(2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

.wizard-next:active {
    transform: scale(0.98);
}

/* Button icons */
.wizard-btn .icon-left {
    margin-right: 4px;
}

.wizard-btn .icon-right {
    margin-left: 4px;
}

/* ===== Progress Section ===== */
.wizard-progress-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.wizard-step-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    font-size: 0.8125rem;
    color: var(--wizard-gray);
}

.wizard-step-text {
    font-weight: 700;
    color: var(--wizard-text);
}

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

/* Progress Bar */
.wizard-progress {
    width: 100%;
    height: 8px;
    background: var(--wizard-gray-light);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.wizard-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--wizard-primary) 0%, var(--wizard-success) 100%);
    border-radius: 4px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

/* Animated shimmer effect */
.wizard-progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(255, 255, 255, 0.4) 50%,
            transparent 100%);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

/* ===== Step Indicators (Dots) ===== */
.wizard-steps {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-basis: 100%;
    width: 100%;
    margin-top: 4px;
    order: 99;
    position: relative;
}

/* Gray background line behind dots */
.wizard-steps::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 5px;
    right: 5px;
    height: 4px;
    background: var(--wizard-gray-light);
    transform: translateY(-50%);
    z-index: 0;
}

/* Green progress line overlay - width controlled by JS via --wizard-line-progress */
.wizard-steps::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 5px;
    width: calc(var(--wizard-line-progress, 0%) - 5px);
    height: 4px;
    background: var(--wizard-success);
    transform: translateY(-50%);
    z-index: 0;
    transition: width 0.3s ease;
}

.wizard-step-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--wizard-gray-light);
    transition: var(--wizard-transition);
    cursor: pointer;
    position: relative;
    z-index: 1;
    /* Above the connecting line */
}

.wizard-step-dot.completed {
    background: var(--wizard-success);
}

.wizard-step-dot.completed::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 8px;
    color: white;
    font-weight: bold;
}

.wizard-step-dot.active {
    background: var(--wizard-primary);
    transform: scale(1.3);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.wizard-step-dot.pending {
    background: var(--wizard-gray-light);
}

.wizard-step-dot:hover {
    transform: scale(1.2);
}

/* Custom tooltip for step dots - desktop only */
.wizard-step-dot::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: var(--wizard-text);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
    /* Single line */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s, transform 0.2s;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Show tooltip on hover for all dots */
.wizard-step-dot:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-12px);
}

/* Checkmark inside completed dots (using inner content approach) */
.wizard-step-dot.completed {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 6px;
    color: white;
    font-weight: bold;
}

.wizard-step-dot.completed::after {
    content: '';
}

/* Connector lines between dots */
.wizard-step-connector {
    width: 20px;
    height: 2px;
    background: var(--wizard-gray-light);
    transition: var(--wizard-transition);
}

.wizard-step-connector.completed {
    background: var(--wizard-success);
}

/* ===== Progress Sidebar Enhancements ===== */
.progress-indicator.completed {
    background-color: var(--wizard-success) !important;
}

.progress-indicator.completed::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    color: white;
    font-weight: bold;
}

.progress-indicator.completed .progress-indicator-number {
    color: var(--wizard-success) !important;
}

.progress-indicator.pending {
    background-color: var(--wizard-gray-light) !important;
    opacity: 0.6;
}

.progress-indicator.pending .progress-indicator-number {
    color: var(--wizard-gray) !important;
    opacity: 0.5;
}

/* ===== Fieldset Transitions ===== */
fieldset[data-wizard-step] {
    animation: fadeSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ===== Validation Error State ===== */
.validation-error {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2) !important;
}

.validation-error:focus {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3) !important;
}

/* ===== Mobile Responsive ===== */
@media (max-width: 768px) {
    .wizard-navigation {
        flex-direction: column;
        gap: 12px;
        padding: 14px 16px;
        margin: 0 10px 20px 10px;
        max-width: calc(100% - 20px);
        position: sticky;
        top: 50px;
    }

    .wizard-btn {
        width: 100%;
        padding: 12px 16px;
        font-size: 0.875rem;
        min-width: auto;
    }

    .wizard-buttons {
        display: flex;
        width: 100%;
        gap: 10px;
    }

    .wizard-buttons .wizard-btn {
        flex: 1;
    }

    .wizard-progress-section {
        width: 100%;
        order: -1;
    }

    .wizard-step-info {
        font-size: 0.75rem;
    }

    .wizard-steps {
        gap: 6px;
    }

    .wizard-step-dot {
        width: 12px;
        height: 12px;
    }

    .wizard-step-connector {
        width: 12px;
    }
}

/* ===== Extra Small Screens ===== */
@media (max-width: 480px) {
    .wizard-navigation {
        margin: 0 8px 16px 8px;
        padding: 12px;
        border-radius: 12px;
    }

    .wizard-btn {
        padding: 10px 12px;
        font-size: 0.8125rem;
    }

    .wizard-btn .btn-text {
        display: inline;
    }

    /* Keep prev button text visible even on small screens */
    /* The "Xem lại" text is short enough to fit */
}

/* ===== Accessibility ===== */
.wizard-btn:focus-visible,
.wizard-step-dot:focus-visible {
    outline: 2px solid var(--wizard-primary);
    outline-offset: 2px;
}

/* ===== Print Styles ===== */
@media print {
    .wizard-navigation {
        display: none;
    }

    fieldset[data-wizard-step] {
        display: block !important;
    }
}

/* ===== Wizard Mode Toggle ===== */
.wizard-mode-toggle {
    position: fixed;
    bottom: 80px;
    right: 20px;
    background: var(--wizard-bg);
    border: 1px solid var(--wizard-gray-light);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.75rem;
    color: var(--wizard-gray);
    cursor: pointer;
    transition: var(--wizard-transition);
    z-index: 99;
}

.wizard-mode-toggle:hover {
    background: var(--wizard-gray-light);
    color: var(--wizard-text);
}

@media (min-width: 1024px) {
    .wizard-mode-toggle {
        right: 80px;
    }
}

/* ===== Hide wizard elements when disabled ===== */
body:not(.wizard-enabled) .wizard-navigation {
    display: none;
}

body.wizard-enabled .wizard-navigation {
    display: flex;
}