/* Trail Navigation Styles - Nordic Design System */

/* ============================================
   CONTAINER - Sticky below header
   ============================================ */
.trail-navigation-wrapper {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-surface);
    padding: 0.5rem 0;
    margin: -1rem -1rem 1rem -1rem;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border-light);
}

.trail-navigation-container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 0.5rem;
    background: linear-gradient(180deg,
        var(--trail-sky-top, #b8d4e8) 0%,
        var(--trail-sky-bottom, #d4e8d4) 100%);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow-x: auto;
    overflow-y: hidden;
}

/* Light mode trail colors */
:root {
    --trail-sky-top: #b8d4e8;
    --trail-sky-bottom: #c8dcc8;
    --trail-grass: #5a8a5e;
    --trail-grass-dark: #4a7a4e;
    --trail-path: #c4a574;
    --trail-path-dark: #a08060;
    --trail-wood: #8B4513;
    --trail-wood-light: #A0522D;
    --trail-wood-dark: #654321;
    --trail-label-bg: #f9f6f0;
    --trail-label-bg-active: #e8f4e8;
    --trail-label-text: #4a5a4a;
    --trail-label-text-active: #2a4a2a;
    --trail-lock-metal: #666666;
    --trail-lock-metal-dark: #444444;
    --trail-collie-body: #2d2d2d;
    --trail-collie-chest: #f5f5f5;
    --trail-dot-completed: var(--success);
    --trail-dot-current: var(--primary);
    --trail-dot-unlocked: var(--warning);
    --trail-dot-locked: #999999;
}

/* Dark mode trail colors */
[data-theme="dark"] {
    --trail-sky-top: #2a3a4a;
    --trail-sky-bottom: #1a2a32;
    --trail-grass: #3a5a3e;
    --trail-grass-dark: #2a4a2e;
    --trail-path: #6a5a44;
    --trail-path-dark: #5a4a34;
    --trail-wood: #5a3a2a;
    --trail-wood-light: #6a4a3a;
    --trail-wood-dark: #3a2a1a;
    --trail-label-bg: var(--bg-elevated);
    --trail-label-bg-active: rgba(143, 181, 146, 0.2);
    --trail-label-text: var(--text-secondary);
    --trail-label-text-active: var(--text-primary);
    --trail-lock-metal: #888888;
    --trail-lock-metal-dark: #666666;
    --trail-collie-body: #4a4a4a;
    --trail-collie-chest: #e0e0e0;
    --trail-dot-completed: var(--success);
    --trail-dot-current: var(--primary);
    --trail-dot-unlocked: var(--warning);
    --trail-dot-locked: #555555;
}

.trail-navigation {
    width: 100%;
    min-width: 1000px;
    height: auto;
    display: block;
}

/* ============================================
   SEGMENT INTERACTIONS
   ============================================ */
.trail-segment {
    cursor: pointer;
    transition: all var(--transition-fast);
}

.trail-segment:hover .segment-label {
    filter: brightness(1.05);
}

.trail-segment.active .segment-label {
    stroke-width: 3;
    filter: drop-shadow(0 0 6px var(--success));
}

.trail-segment.locked {
    cursor: not-allowed;
    opacity: 0.6;
}

.trail-segment.locked:hover .segment-label {
    filter: none;
}

/* Completed stages - enhanced interactivity for backward navigation */
.trail-segment.completed:not(.active) {
    cursor: pointer;
}

.trail-segment.completed:not(.active):hover .segment-label {
    filter: brightness(1.1);
    transform: scale(1.03);
    transition: all 0.2s ease;
}

/* Clickable hint animation for backward navigation */
.trail-segment.clickable-hint .segment-label {
    animation: stageClickableHint 2s ease-out infinite;
}

@keyframes stageClickableHint {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(90, 138, 94, 0.4);
        filter: brightness(1);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(90, 138, 94, 0);
        filter: brightness(1.1);
    }
}

/* Dark mode version of the clickable hint */
[data-theme="dark"] .trail-segment.clickable-hint .segment-label {
    animation: stageClickableHintDark 2s ease-out infinite;
}

@keyframes stageClickableHintDark {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(143, 181, 146, 0.4);
        filter: brightness(1);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(143, 181, 146, 0);
        filter: brightness(1.2);
    }
}

/* ============================================
   GATE ANIMATIONS
   ============================================ */
.gate {
    transition: all 0.5s ease;
}

.gate .gate-bars {
    transition: transform 0.6s ease-out;
    transform-origin: left center;
}

.gate.unlocked .gate-bars {
    transform: rotate(-60deg);
}

.gate .lock-body {
    transition: opacity 0.3s ease;
}

.gate.unlocked .lock-body {
    opacity: 0;
}

.gate .lock-shackle {
    transition: all 0.3s ease;
}

.gate.unlocked .lock-shackle {
    transform: translateY(-3px) rotate(15deg);
    opacity: 0;
}

/* ============================================
   COLLIE ANIMATION
   ============================================ */
.collie-container {
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.collie {
    animation: collieIdle 2s ease-in-out infinite;
}

@keyframes collieIdle {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-2px);
    }
}

.collie-container.walking .collie {
    animation: collieWalk 0.3s steps(2) infinite;
}

@keyframes collieWalk {
    0% {
        transform: translateY(0) rotate(-2deg);
    }
    50% {
        transform: translateY(-3px) rotate(2deg);
    }
    100% {
        transform: translateY(0) rotate(-2deg);
    }
}

/* New collie animations for speech bubble interactions */
.collie-container.collie-sniff .collie {
    animation: collieSniff 0.8s ease-in-out 3;
}

@keyframes collieSniff {
    0%, 100% {
        transform: scaleY(1) translateY(0);
    }
    50% {
        transform: scaleY(0.98) translateY(1px);
    }
}

.collie-container.collie-dig .collie {
    animation: collieDig 0.5s ease-in-out 4;
}

@keyframes collieDig {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    25% {
        transform: translateY(2px) rotate(-5deg);
    }
    75% {
        transform: translateY(2px) rotate(5deg);
    }
}

.collie-container.collie-tail-wag .collie {
    animation: collieTailWag 0.6s ease-in-out 4;
}

@keyframes collieTailWag {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(-3deg);
    }
    75% {
        transform: rotate(3deg);
    }
}

.collie-container.collie-head-turn .collie {
    animation: collieHeadTurn 1.5s ease-in-out;
}

@keyframes collieHeadTurn {
    0%, 100% {
        transform: rotate(0deg);
    }
    30%, 70% {
        transform: rotate(-8deg);
    }
}

.collie-container.collie-celebrate .collie {
    animation: collieCelebrate 0.8s ease-in-out;
}

@keyframes collieCelebrate {
    0%, 100% {
        transform: translateY(0) scale(1);
    }
    25% {
        transform: translateY(-8px) scale(1.05);
    }
    50% {
        transform: translateY(-4px) scale(1.03) rotate(-5deg);
    }
    75% {
        transform: translateY(-6px) scale(1.04) rotate(5deg);
    }
}

.collie-container.collie-focused .collie {
    animation: collieFocused 2s ease-in-out;
}

@keyframes collieFocused {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.collie-container.collie-alert .collie {
    animation: collieAlert 0.5s ease-in-out 2;
}

@keyframes collieAlert {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-4px);
    }
}

/* Reduced motion support for collie animations */
@media (prefers-reduced-motion: reduce) {
    .collie,
    .collie-container.walking .collie,
    .collie-container.collie-sniff .collie,
    .collie-container.collie-dig .collie,
    .collie-container.collie-tail-wag .collie,
    .collie-container.collie-head-turn .collie,
    .collie-container.collie-celebrate .collie,
    .collie-container.collie-focused .collie,
    .collie-container.collie-alert .collie {
        animation: none;
    }
}

/* ============================================
   PROGRESS DOTS
   ============================================ */
.progress-dot {
    transition: all var(--transition-fast);
}

.progress-dot.completed {
    fill: var(--trail-dot-completed);
    stroke: var(--trail-dot-completed);
    filter: brightness(0.9);
}

.progress-dot.current {
    fill: var(--trail-dot-current);
    stroke: var(--trail-dot-current);
    animation: pulseDot 1.5s ease-in-out infinite;
}

.progress-dot.unlocked {
    fill: var(--trail-dot-unlocked);
    stroke: var(--trail-dot-unlocked);
    filter: brightness(0.9);
}

.progress-dot.locked {
    fill: var(--trail-dot-locked);
    stroke: var(--trail-dot-locked);
    filter: brightness(0.8);
}

@keyframes pulseDot {
    0%, 100% {
        r: 6;
        filter: none;
    }
    50% {
        r: 8;
        filter: drop-shadow(0 0 4px var(--primary));
    }
}

/* ============================================
   STAGE CONTENT AREA
   ============================================ */
.stage-content-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    transition: opacity var(--transition-fast);
}

.stage-content-container.transitioning {
    opacity: 0.5;
    pointer-events: none;
}

/* ============================================
   BACK NAVIGATION HINT
   ============================================ */
.back-nav-hint {
    text-align: center;
    padding: 0.75rem 1rem;
    background: var(--warning-bg);
    border: 1px dashed var(--warning-border);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.back-nav-hint strong {
    color: var(--warning);
}

/* ============================================
   RE-EXTRACTION NOTIFICATION
   ============================================ */
.reextraction-notification {
    background: var(--info-bg);
    border: 1px solid var(--info-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1rem;
}

.reextraction-notification h5 {
    color: var(--info);
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.reextraction-notification ul {
    margin-bottom: 0.5rem;
    padding-left: 1.5rem;
}

.reextraction-notification .actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* ============================================
   STAGE LABELS
   ============================================ */
.stage-label-text {
    font-family: var(--font-sans);
    font-weight: 600;
    pointer-events: none;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1200px) {
    .trail-navigation-container {
        border-radius: var(--radius-md);
    }
}

@media (max-width: 768px) {
    .trail-navigation-wrapper {
        margin: -0.5rem -0.5rem 0.5rem -0.5rem;
        padding: 0.25rem 0.5rem;
    }

    .trail-navigation-container {
        padding: 0.25rem;
    }

    .trail-navigation {
        min-width: 800px;
    }
}

/* ============================================
   APPROVED STAGE SUMMARY
   ============================================ */
.approved-stage-summary {
    padding: 1rem;
}

.approved-stage-summary .alert h5 {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.approved-stage-summary .alert p {
    margin-bottom: 0;
    font-size: 0.9rem;
}

/* ============================================
   APPROVED CONTENT VIEWER
   ============================================ */
.approved-content-viewer {
    padding: 1rem;
}

.stage-content-header {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-light);
}

.stage-content-header h5 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.no-data-placeholder {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 2rem;
    color: var(--text-muted);
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    justify-content: center;
}

.no-data-placeholder i {
    font-size: 1.25rem;
}

/* Q&A Answers */
.qa-answers-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.qa-item {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 1rem;
    border-left: 3px solid var(--primary);
}

.qa-question {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.qa-answer {
    color: var(--text-secondary);
}

/* Fields Table */
.fields-list .table {
    margin-bottom: 0;
}

.fields-list .table code {
    background: var(--bg-elevated);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
}

/* Scenarios */
.scenarios-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.scenario-card {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 1rem;
    border: 1px solid var(--border-light);
}

.scenario-header {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.scenario-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.scenario-steps {
    margin: 0;
    padding-left: 1.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.scenario-steps li {
    margin-bottom: 0.25rem;
}

/* Gherkin Steps */
.gherkin-steps-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.gherkin-card {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 1rem;
    border: 1px solid var(--border-light);
}

.gherkin-header {
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.gherkin-code {
    background: var(--bg-elevated);
    padding: 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    overflow-x: auto;
    margin: 0;
}

.gherkin-feature {
    background: var(--bg-elevated);
    padding: 1rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    overflow-x: auto;
    margin: 0;
    max-height: 500px;
    overflow-y: auto;
}

/* Domain Knowledge */
.knowledge-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.knowledge-card {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 1rem;
    border: 1px solid var(--border-light);
}

.knowledge-category {
    margin-bottom: 0.5rem;
}

.knowledge-content {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Concerns */
.concerns-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.concern-card {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 1rem;
    border: 1px solid var(--border-light);
}

.concern-header {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
}

.concern-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.concern-resolution,
.concern-dismissal {
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-light);
}

/* Edit mode styles */
.field-edit-card,
.scenario-edit-card,
.gherkin-edit-card,
.knowledge-edit-card,
.concern-edit-card,
.qa-edit-card {
    background: var(--bg-surface);
    transition: all var(--transition-fast);
}

.field-edit-card:hover,
.scenario-edit-card:hover,
.gherkin-edit-card:hover,
.knowledge-edit-card:hover,
.concern-edit-card:hover,
.qa-edit-card:hover {
    background: var(--bg-elevated);
}

/* Dark mode form controls within edit cards */
[data-theme="dark"] .approved-content-viewer .form-control,
[data-theme="dark"] .approved-content-viewer .form-select {
    background-color: var(--bg-elevated, #2a2a2a);
    border-color: var(--border-medium, #444);
    color: var(--text-primary, #e0e0e0);
}

[data-theme="dark"] .approved-content-viewer .form-control:focus,
[data-theme="dark"] .approved-content-viewer .form-select:focus {
    background-color: var(--bg-elevated, #2a2a2a);
    border-color: var(--primary, #8fb592);
    color: var(--text-primary, #e0e0e0);
    box-shadow: 0 0 0 0.2rem rgba(143, 181, 146, 0.25);
}

[data-theme="dark"] .approved-content-viewer .form-control::placeholder {
    color: var(--text-muted, #888);
}

[data-theme="dark"] .approved-content-viewer .form-label {
    color: var(--text-secondary, #b0b0b0);
}

[data-theme="dark"] .approved-content-viewer .form-check-label {
    color: var(--text-secondary, #b0b0b0);
}

/* Ensure table text is visible in dark mode */
[data-theme="dark"] .approved-content-viewer .table {
    color: var(--text-primary, #e0e0e0);
}

[data-theme="dark"] .approved-content-viewer .table code {
    background: var(--bg-elevated, #2a2a2a);
    color: var(--text-primary, #e0e0e0);
}

.fields-list.editable,
.scenarios-list.editable,
.gherkin-steps-list.editable,
.knowledge-list.editable,
.concerns-list.editable,
.qa-answers-list.editable {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.edit-mode-notice {
    font-size: 0.875rem;
}

.edit-actions {
    border-top: 1px solid var(--border-light);
    padding-top: 1rem;
    margin-top: 1rem;
}

/* Gherkin step drag-and-drop */
.gherkin-step-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    margin-bottom: 0.25rem;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    transition: all 0.15s ease;
}

.gherkin-step-row:hover {
    background: var(--bg-elevated);
}

.gherkin-step-row.drop-target {
    border-top: 2px solid var(--primary);
    background: var(--bg-elevated);
}

.gherkin-step-row[draggable="true"] {
    cursor: grab;
}

.gherkin-step-row[draggable="true"]:active {
    cursor: grabbing;
    opacity: 0.8;
}

.drag-handle {
    color: var(--text-muted);
    cursor: grab;
    padding: 0.25rem;
    display: flex;
    align-items: center;
}

.drag-handle:hover {
    color: var(--text-secondary);
}

.drag-handle:active {
    cursor: grabbing;
}

.gherkin-step-row .form-control {
    flex: 1;
}

/* Dark mode adjustments for drag rows */
[data-theme="dark"] .gherkin-step-row {
    background: var(--bg-elevated, #2a2a2a);
}

[data-theme="dark"] .gherkin-step-row:hover {
    background: var(--bg-surface, #333);
}

[data-theme="dark"] .gherkin-step-row.drop-target {
    background: rgba(143, 181, 146, 0.15);
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */
.trail-navigation-container::-webkit-scrollbar {
    height: 6px;
}

.trail-navigation-container::-webkit-scrollbar-track {
    background: var(--bg-surface);
    border-radius: 3px;
}

.trail-navigation-container::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 3px;
}

.trail-navigation-container::-webkit-scrollbar-thumb:hover {
    background: var(--border-dark);
}
