/* Dev Panel - Floating panel for feature flag control */

.dev-panel {
    position: fixed;
    bottom: 1.5rem;
    right: 1rem;
    z-index: 9999;
    width: 240px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-float);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition:
        opacity var(--transition-base),
        transform var(--transition-base),
        visibility var(--transition-base);
}

.dev-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.dev-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 0.875rem;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-primary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.dev-panel-title {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    letter-spacing: var(--tracking-wide);
}

.dev-panel-close {
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast);
}

.dev-panel-close:hover {
    color: var(--text-primary);
}

.dev-panel-body {
    padding: 0.5rem 0.875rem;
}

.dev-flag-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-subtle);
}

.dev-flag-row:last-child {
    border-bottom: none;
}

.dev-flag-label {
    font-size: var(--text-sm);
    color: var(--text-primary);
}

/* Toggle switch */
.dev-flag-toggle {
    position: relative;
    width: 40px;
    height: 22px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
    flex-shrink: 0;
}

.dev-flag-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: transform var(--transition-bounce), background var(--transition-fast);
}

.dev-flag-toggle.active {
    background: var(--nhs-green-light, #e6f4ea);
    border-color: var(--nhs-green, #007f3b);
}

.dev-flag-toggle.active::after {
    transform: translateX(18px);
    background: var(--nhs-green, #007f3b);
}

.dev-panel-footer {
    padding: 0.5rem 0.875rem 0.625rem;
    border-top: 1px solid var(--border-subtle);
}

.dev-panel-reset {
    width: 100%;
    padding: 0.375rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.dev-panel-reset:hover {
    background: rgba(220, 38, 38, 0.1);
    border-color: rgba(220, 38, 38, 0.4);
    color: #dc2626;
}

/* Floating toggle button (FAB) to re-open panel */
.dev-panel-fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1rem;
    z-index: 9998;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-fast), visibility var(--transition-fast);
}

.dev-panel-fab.visible {
    opacity: 0.5;
    visibility: visible;
}

.dev-panel-fab:hover {
    opacity: 1;
}

.dev-panel-fab svg {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

/* Hide in patient mode */
.patient-mode .dev-panel,
.patient-mode .dev-panel-fab {
    display: none;
}

@media print {
    .dev-panel,
    .dev-panel-fab {
        display: none !important;
    }
}

/* === Parity Testing Section === */

.dev-panel-section {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-subtle);
}

.dev-panel-section:last-child {
    border-bottom: none;
}

.dev-panel-section h4 {
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    margin: 0 0 0.5rem 0;
}

.parity-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-indicator.has-baseline {
    background: var(--nhs-green, #007f3b);
}

.status-indicator.no-baseline {
    background: var(--text-muted);
}

.parity-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-bottom: 0.5rem;
}

.dev-parity-btn {
    flex: 1 1 45%;
    padding: 0.375rem 0.5rem;
    background: var(--nhs-blue, #005EB8);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    cursor: pointer;
    transition: background var(--transition-fast), opacity var(--transition-fast);
}

.dev-parity-btn:hover {
    opacity: 0.9;
}

.dev-parity-btn.secondary {
    flex: 1 1 100%;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.dev-parity-btn.secondary:hover {
    background: var(--bg-secondary);
}

.parity-results {
    font-size: var(--text-xs);
    max-height: 200px;
    overflow-y: auto;
}

.parity-loading {
    color: var(--text-muted);
    font-style: italic;
}

.parity-success {
    color: var(--nhs-green, #007f3b);
    padding: 0.375rem;
    background: var(--nhs-green-light, #e6f4ea);
    border-radius: var(--radius-sm);
}

.parity-success code,
.parity-error code,
.parity-info code {
    display: block;
    margin-top: 0.25rem;
    padding: 0.25rem 0.375rem;
    background: rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-xs, 2px);
    font-family: monospace;
    font-size: 0.75rem;
    word-break: break-all;
}

.parity-error {
    color: #dc2626;
    padding: 0.375rem;
    background: #fef2f2;
    border-radius: var(--radius-sm);
}

.parity-info {
    color: var(--text-secondary);
    padding: 0.375rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.parity-summary {
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.parity-summary.success {
    background: var(--nhs-green-light, #e6f4ea);
    color: var(--nhs-green, #007f3b);
}

.parity-summary.failure {
    background: #fef2f2;
    color: #dc2626;
}

.parity-stats {
    font-size: var(--text-xs);
    margin-top: 0.25rem;
    opacity: 0.8;
}

.parity-failures {
    max-height: 150px;
    overflow-y: auto;
}

.parity-failure {
    padding: 0.375rem;
    background: #fef2f2;
    border-radius: var(--radius-sm);
    margin-bottom: 0.25rem;
}

.parity-failure strong {
    display: block;
    color: #dc2626;
}

.parity-diff-list {
    margin: 0.25rem 0 0 0;
    padding-left: 1rem;
    font-size: 10px;
    color: var(--text-secondary);
}

.parity-diff-list li {
    margin-bottom: 0.125rem;
}

/* Wider panel for parity testing */
.dev-panel {
    width: 280px;
}

/* === Test Tabs === */

.test-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

.test-tab {
    flex: 1;
    padding: 0.375rem 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.test-tab:hover {
    background: var(--bg-primary);
}

.test-tab.active {
    background: var(--nhs-blue, #005EB8);
    border-color: var(--nhs-blue, #005EB8);
    color: white;
}

.test-content {
    margin-top: 0.5rem;
}

/* Parity module selector */
.parity-module-select {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.parity-module-select label {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.parity-module-select select {
    flex: 1;
    padding: 0.375rem 1.5rem 0.375rem 0.5rem;
    background-color: var(--bg-elevated);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: var(--text-xs);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

.parity-module-select select:hover {
    background-color: var(--bg-primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
}

.parity-module-select select:focus {
    outline: none;
    border-color: var(--nhs-blue, #005EB8);
    background-color: var(--bg-elevated);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
}

.parity-module-select select option {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

/* === Unit Test Results === */

.unit-test-info {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-style: italic;
}

.unit-test-results {
    font-size: var(--text-xs);
    max-height: 200px;
    overflow-y: auto;
}

.unit-test-summary {
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.unit-test-summary.success {
    background: var(--nhs-green-light, #e6f4ea);
    color: var(--nhs-green, #007f3b);
}

.unit-test-summary.failure {
    background: #fef2f2;
    color: #dc2626;
}

.unit-test-stats {
    font-size: var(--text-xs);
    margin-top: 0.25rem;
    opacity: 0.8;
}

.unit-test-suites {
    max-height: 150px;
    overflow-y: auto;
}

.unit-test-suite {
    margin-bottom: 0.375rem;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.unit-test-suite.has-failures {
    background: #fef2f2;
}

.unit-test-suite.all-passed {
    background: var(--nhs-green-light, #e6f4ea);
}

.suite-header {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem;
}

.suite-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.unit-test-suite.has-failures .suite-indicator {
    background: #dc2626;
}

.unit-test-suite.all-passed .suite-indicator {
    background: var(--nhs-green, #007f3b);
}

.suite-name {
    flex: 1;
    font-weight: var(--font-medium);
    color: var(--text-primary);
}

.suite-count {
    color: var(--text-muted);
    font-size: 10px;
}

.suite-tests {
    padding: 0 0.375rem 0.375rem;
}

.unit-test {
    display: flex;
    align-items: flex-start;
    gap: 0.25rem;
    padding: 0.125rem 0;
    font-size: 10px;
}

.test-indicator {
    flex-shrink: 0;
    width: 12px;
    text-align: center;
}

.unit-test.pass .test-indicator {
    color: var(--nhs-green, #007f3b);
}

.unit-test.fail .test-indicator {
    color: #dc2626;
}

.test-name {
    color: var(--text-primary);
}

.test-error {
    margin-top: 0.125rem;
    margin-left: 12px;
    padding: 0.25rem;
    background: rgba(220, 38, 38, 0.1);
    border-radius: var(--radius-xs, 2px);
    color: #dc2626;
    font-family: monospace;
    font-size: 9px;
    word-break: break-word;
}
