/* Implements: REQ-p00006-B */
/* Partial: _card-stack.css.j2 — Card stack panel and requirement cards */

/* --- Card Stack (Center) --- */

.card-stack-panel {
    flex: 1;
    min-width: 350px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--card-stack-bg);
}

.card-stack-header {
    padding: 8px 16px;
    background: var(--card-stack-header-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    font-size: 0.85rem;
    color: var(--secondary-text);
}

.card-stack-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card-stack-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--card-stack-empty);
    gap: 8px;
    padding: 40px;
    text-align: center;
}

.card-stack-empty-icon {
    font-size: 2.5rem;
    opacity: 0.5;
}

/* --- Requirement Card --- */

.req-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.req-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.req-card.focused {
    border-color: var(--card-focused-border);
    box-shadow: 0 0 0 2px rgba(13,110,253,0.15);
}

.req-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--card-header-bg);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    user-select: none;
}

.req-card-header:hover {
    background: var(--card-header-hover-bg);
}

.req-card-expand {
    font-size: 16px;
    color: var(--card-expand);
    transition: transform 0.15s;
    flex-shrink: 0;
}

.req-card.collapsed .req-card-expand {
    transform: rotate(-90deg);
}

.req-card-id {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--card-id);
    flex-shrink: 0;
}

.req-card-title-display {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--card-title);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.req-card-close {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--card-close);
    padding: 0 4px;
    line-height: 1;
    transition: color 0.15s;
    flex-shrink: 0;
}

.req-card-close:hover {
    color: var(--card-close-hover);
}

.req-card-body {
    padding: 14px;
}

.req-card.collapsed .req-card-body {
    display: none;
}

/* Card Sections */
.card-section {
    margin-bottom: 12px;
}

.card-section:last-child {
    margin-bottom: 0;
}

.card-section-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--card-section-label);
    margin-bottom: 4px;
}

.card-dim-badge {
    outline: 1.5px solid var(--impl-yes-border, #0d6efd);
    outline-offset: 1px;
    cursor: pointer;
}

.card-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.card-meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
}

.card-meta-key {
    color: var(--card-meta-key);
    font-weight: 500;
}

.card-meta-value {
    color: var(--card-meta-value);
}

/* Status Badge (in cards) */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.draft { background: var(--status-draft-bg); color: var(--status-draft-text); }
.status-badge.active { background: var(--status-active-bg); color: var(--status-active-text); }
.status-badge.deprecated { background: var(--status-deprecated-bg); color: var(--status-deprecated-text); }
.status-badge.proposed { background: var(--status-proposed-bg); color: var(--status-proposed-text); }

/* Parent Links */
.card-parents {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.card-parents-empty {
    font-size: 0.8rem;
    color: var(--muted-text);
    font-style: italic;
}

.card-parent-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.card-parent-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: var(--card-parent-bg);
    border: 1px solid var(--card-parent-border);
    border-radius: 12px;
    font-size: 0.75rem;
    color: var(--card-parent-text);
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-parent-link:hover {
    background: var(--card-parent-hover-bg);
}

.card-parent-kind {
    font-size: 0.65rem;
    color: var(--card-parent-kind);
    font-weight: 600;
    text-transform: uppercase;
}

/* Hide view-only elements in edit mode */
body.edit-mode .view-only {
    display: none;
}

/* Kind toggle button (edit mode) */
.card-parent-kind-toggle {
    border: 1px solid var(--kind-toggle-border);
    background: var(--kind-toggle-bg);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--kind-toggle-text);
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
    white-space: nowrap;
}

.card-parent-kind-toggle:hover {
    border-color: var(--kind-toggle-hover-border);
    color: var(--kind-toggle-hover-text);
    background: var(--kind-toggle-hover-bg);
}

/* Delete edge button */
.card-parent-delete {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--muted-text);
    padding: 0 4px;
    line-height: 1;
    transition: color 0.15s;
    flex-shrink: 0;
}

.card-parent-delete:hover {
    color: var(--delete-hover);
}

/* Assertion targets display */
.card-parent-targets {
    font-size: 0.7rem;
    color: var(--muted-text);
    margin-left: 4px;
}

/* Assertion targets picker button */
.card-parent-targets-btn {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1.44rem;
    color: var(--edit-pencil);
    padding: 0 4px;
    line-height: 1;
    flex-shrink: 0;
    transition: transform 0.15s;
}
.card-parent-targets-btn:hover {
    transform: scale(1.2);
}

/* Assertion targets picker popup */
.edge-targets-picker {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    padding: 8px;
    margin-top: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.edge-targets-picker-title {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--accent-text);
}
.edge-targets-option {
    display: block;
    font-size: 0.75rem;
    padding: 2px 0;
    cursor: pointer;
}
.edge-targets-option:hover {
    background: var(--row-hover);
}
.edge-targets-actions {
    margin-top: 6px;
    display: flex;
    gap: 4px;
}
.edge-targets-picker-inline {
    flex: 1;
}
.edge-targets-apply, .edge-targets-cancel {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--card-border);
    cursor: pointer;
    background: var(--card-bg);
    color: var(--text-primary);
}
.edge-targets-apply:hover {
    background: var(--accent-text);
    color: var(--card-bg);
}

/* Move to file button */
.card-move-file-btn {
    font-size: 0.65rem;
    padding: 1px 6px;
    border: 1px solid var(--card-border);
    border-radius: 3px;
    background: var(--card-bg);
    color: var(--muted-text);
    cursor: pointer;
    margin-left: 4px;
}
.card-move-file-btn:hover {
    color: var(--accent-text);
    border-color: var(--accent-text);
}

/* Add Relationship button */
.card-add-rel-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: transparent;
    border: 1px dashed var(--card-add-btn-border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--card-add-btn-text);
    transition: all 0.15s;
    margin-top: 6px;
}

.card-add-rel-btn:hover {
    border-color: var(--card-add-btn-hover-border);
    color: var(--card-add-btn-hover-text);
    background: var(--card-add-btn-hover-bg);
}

/* Add Relationship form */
.card-add-rel-form {
    margin-top: 8px;
    padding: 10px;
    background: var(--add-rel-bg);
    border: 1px solid var(--add-rel-border);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.add-rel-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.add-rel-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--add-rel-label);
    width: 65px;
    flex-shrink: 0;
}

.add-rel-select {
    padding: 4px 8px;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    font-size: 0.8rem;
    font-family: inherit;
    outline: none;
}

.add-rel-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.15);
}

.add-rel-picker-container {
    flex: 1;
    min-width: 0;
}

.add-rel-buttons {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.add-rel-add-btn {
    padding: 4px 14px;
    background: var(--add-rel-add-bg);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.add-rel-add-btn:hover:not(:disabled) {
    background: var(--add-rel-add-hover);
}

.add-rel-add-btn:disabled {
    background: var(--add-rel-add-disabled);
    cursor: not-allowed;
}

.add-rel-cancel-btn {
    padding: 4px 14px;
    background: transparent;
    color: var(--add-rel-cancel-text);
    border: 1px solid var(--add-rel-cancel-border);
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
}

.add-rel-cancel-btn:hover {
    background: var(--add-rel-cancel-hover-bg);
    border-color: var(--add-rel-cancel-hover-border);
}

/* Assertion List */
.card-assertions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.card-assertion {
    display: flex;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    background: var(--card-assertion-bg);
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s;
}

.card-assertion-label {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--card-assertion-label-text);
    background: var(--card-assertion-label-bg);
    padding: 2px 6px;
    border-radius: 3px;
    flex-shrink: 0;
    height: fit-content;
}

.card-assertion-text {
    font-size: 0.8rem;
    color: var(--card-assertion-text);
    line-height: 1.5;
}

/* Children List */
.card-children {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.card-child-link {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    background: var(--card-child-bg);
    border: 1px solid var(--card-child-border);
    border-radius: 12px;
    font-size: 0.7rem;
    color: var(--card-child-text);
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none;
}

.card-child-link:hover {
    background: var(--card-child-hover-bg);
    color: var(--card-child-hover-text);
}

.card-child-edge-kind {
    font-size: 0.6rem;
    color: var(--card-child-edge-kind);
    font-weight: 600;
}

/* Add Assertion Button */
.card-add-assertion-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: transparent;
    border: 1px dashed var(--card-add-btn-border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--card-add-btn-text);
    transition: all 0.15s;
    margin-top: 4px;
}

.card-add-assertion-btn:hover {
    border-color: var(--card-add-btn-hover-border);
    color: var(--card-add-btn-hover-text);
    background: var(--card-add-btn-hover-bg);
}

/* --- Body Sections (Complete View) --- */

.card-body-section-wrapper {
    padding: 6px 8px;
    border-radius: 4px;
    background: var(--card-assertion-bg);
    border: 1px solid transparent;
}

.card-body-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--card-section-label);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-body-section-toggle {
    font-size: 0.65rem;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    color: var(--muted-text);
    cursor: pointer;
    user-select: none;
    padding: 0 4px;
}

.card-body-section-toggle:hover {
    color: var(--accent-text);
}

.card-body-section-content {
    font-size: 0.8rem;
    color: var(--text-primary);
    line-height: 1.6;
    white-space: pre-wrap;
    margin-top: 4px;
}

/* --- Journey Card --- */

.journey-card-kind {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    background: var(--journey-kind-bg);
    color: var(--journey-kind-text);
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.journey-card-description {
    font-size: 0.8rem;
    color: var(--journey-card-description);
    line-height: 1.6;
    white-space: pre-wrap;
}

/* --- Requirement Delete Button --- */

.req-card-delete {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--delete-btn);
    opacity: 0;
    transition: opacity 0.2s;
    padding: 2px 6px;
    margin-right: 4px;
}
.req-card-header:hover .req-card-delete {
    opacity: 0.6;
}
.req-card-delete:hover {
    opacity: 1 !important;
}

/* --- Edit Pencil Icons --- */

.edit-pencil {
    display: inline-block;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--edit-pencil);
    font-weight: normal;
    flex-shrink: 0;
    padding: 0 2px;
    transition: transform 0.15s;
}
.card-assertion:hover .edit-pencil,
.card-section.edit-only:hover .edit-pencil,
.edit-pencil:hover {
    transform: scale(1.3);
}

/* --- Assertion Delete Button --- */

.assertion-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--assertion-delete);
    opacity: 0.35;
    transition: opacity 0.2s, color 0.2s;
    padding: 2px 4px;
    margin-left: 4px;
    flex-shrink: 0;
}
.card-assertion:hover .assertion-delete-btn {
    opacity: 0.7;
}
.assertion-delete-btn:hover {
    opacity: 1 !important;
    color: var(--assertion-delete-hover);
}

/* --- Remainder Section Edit Controls --- */

.remainder-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--assertion-delete);
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
    padding: 2px 4px;
    margin-left: 4px;
    flex-shrink: 0;
}
.card-body-section-heading:hover .remainder-delete-btn {
    opacity: 0.7;
}
.remainder-delete-btn:hover {
    opacity: 1 !important;
    color: var(--assertion-delete-hover);
}

.remainder-heading-edit {
    font-size: 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 2px 6px;
}

.card-add-section-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: transparent;
    border: 1px dashed var(--card-add-btn-border);
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    color: var(--card-add-btn-text);
    transition: all 0.15s;
    margin-top: 4px;
    margin-left: 4px;
}
.card-add-section-btn:hover {
    border-color: var(--card-add-btn-hover-border);
    color: var(--card-add-btn-hover-text);
    background: var(--card-add-btn-hover-bg);
}

/* --- Assertion Validation Buttons --- */

.card-assertion-wrapper {
    display: flex;
    flex-direction: column;
}

.card-assertion {
    align-items: flex-start;
}

@keyframes flash-bg {
    0%, 15% { background-color: rgba(13, 110, 253, 0.35) !important; }
    100% { background-color: transparent !important; }
}

.flash-highlight {
    animation: flash-bg 1.5s ease-out !important;
    border-radius: 4px;
}

.assertion-badges-area {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-left: auto;
    max-width: 30%;
    justify-content: flex-end;
    flex-shrink: 0;
}

/* All assertion dimension buttons share base styles */
.assertion-implemented-btn,
.assertion-refined-btn,
.assertion-tested-btn,
.assertion-verified-btn,
.assertion-validated-btn,
.assertion-accepted-btn {
    flex-shrink: 0;
    padding: 2px 8px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border: 1px solid var(--assertion-btn-border);
    border-radius: 10px;
    background: transparent;
    color: var(--assertion-btn-text);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    margin-left: 4px;
}

/* margin-left on badges area handles right-alignment */

.assertion-implemented-btn:hover,
.assertion-refined-btn:hover,
.assertion-tested-btn:hover,
.assertion-verified-btn:hover,
.assertion-validated-btn:hover,
.assertion-accepted-btn:hover {
    background: var(--assertion-btn-hover-bg);
    border-color: var(--assertion-btn-hover-border);
}

/* "Yes/No" states (Implemented, Tested, Validated — existence checks) */
.implemented-yes {
    border-color: var(--impl-yes-border);
    color: var(--impl-yes-text);
}

.implemented-yes:hover {
    background: var(--impl-yes-hover-bg);
}

.implemented-yes.active {
    background: var(--impl-yes-active-bg);
    color: var(--impl-yes-active-text);
}

.implemented-no {
    border-color: var(--impl-no-border);
    color: var(--impl-no-text);
}

.implemented-no:hover {
    background: var(--impl-no-hover-bg);
}

/* "Pass/Partial/Fail" states (Verified, Accepted — result checks) */
.validation-pass {
    border-color: var(--valid-pass-border);
    color: var(--valid-pass-text);
}

.validation-pass:hover {
    background: var(--valid-pass-hover-bg);
}

.validation-pass.active {
    background: var(--valid-pass-active-bg);
    color: var(--valid-pass-active-text);
}

.validation-partial {
    border-color: var(--valid-partial-border);
    color: var(--valid-partial-text);
}

.validation-partial:hover {
    background: var(--valid-partial-hover-bg);
}

.validation-partial.active {
    background: var(--valid-partial-active-bg);
    color: var(--valid-partial-active-text);
}

.validation-fail {
    border-color: var(--valid-fail-border);
    color: var(--valid-fail-text);
}

.validation-fail:hover {
    background: var(--valid-fail-hover-bg);
}

.validation-fail.active {
    background: var(--valid-fail-active-bg);
    color: var(--valid-fail-active-text);
}

.validation-unknown {
    border-color: var(--valid-unknown-border);
    color: var(--valid-unknown-text);
}

.validation-unknown:hover {
    background: var(--valid-unknown-hover-bg);
}

.validation-unknown.active {
    background: var(--valid-unknown-active-bg);
    color: var(--valid-unknown-active-text);
}

.assertion-implemented-btn.active,
.assertion-refined-btn.active,
.assertion-tested-btn.active,
.assertion-verified-btn.active,
.assertion-validated-btn.active,
.assertion-accepted-btn.active {
    font-weight: 700;
}

/* --- Assertion Code Panel --- */

.assertion-code-panel {
    margin: 4px 0 2px 28px;
    padding: 8px 10px;
    background: var(--assertion-code-panel-bg);
    border-radius: 4px;
    border-left: 3px solid var(--assertion-code-panel-border);
    font-size: 0.78rem;
}

/* --- Assertion UAT Panel --- */

.assertion-uat-panel {
    margin: 4px 0 2px 28px;
    padding: 8px 10px;
    background: var(--assertion-tests-panel-bg);
    border-radius: 4px;
    border-left: 3px solid var(--assertion-tests-panel-border);
    font-size: 0.78rem;
}

/* --- Assertion Test Panel --- */

.assertion-tests-panel {
    margin: 4px 0 2px 28px;
    padding: 8px 10px;
    background: var(--assertion-tests-panel-bg);
    border-radius: 4px;
    border-left: 3px solid var(--assertion-tests-panel-border);
    font-size: 0.78rem;
}

.assertion-tests-loading,
.assertion-tests-empty {
    color: var(--secondary-text);
    font-style: italic;
    padding: 4px 0;
}

.assertion-test-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    border-bottom: 1px solid rgba(0,0,0,0.04);
}

.assertion-test-item:last-child {
    border-bottom: none;
}

.assertion-test-item.test-passed { color: var(--assertion-test-passed-text); }
.assertion-test-item.test-failed { color: var(--assertion-test-failed-text); }
.assertion-test-item.test-no-result { color: var(--assertion-test-no-result-text); }

.assertion-test-icon {
    flex-shrink: 0;
    font-size: 0.8rem;
    width: 1.2em;
    text-align: center;
}

.assertion-test-link {
    color: var(--assertion-test-link);
    text-decoration: none;
    cursor: pointer;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
    text-align: left;
}

a.assertion-test-link:hover {
    text-decoration: underline;
    color: var(--assertion-test-link-hover);
}

.assertion-result-file-link {
    font-size: 0.65rem;
    color: var(--assertion-result-file-link);
    text-decoration: none;
    cursor: pointer;
    margin-left: 4px;
}

.assertion-result-file-link:hover {
    color: var(--assertion-result-file-link-hover);
    text-decoration: underline;
}
