/* Custom styles for the AI Security Lab - Security Hardened Version 1.2 */

/* Responsive container - removed problematic max-width override */
.app-container {
    width: 100%;
    margin: 0 auto;
}

/* Example list styling with accessibility improvements */
.example-item {
    border-left: 4px solid transparent;
    transition: all 0.3s ease;
    position: relative;
}

.example-item:hover {
    border-left-color: var(--bs-primary);
    background-color: var(--bs-secondary-bg);
    color: var(--bs-body-color);
}

.example-item:focus {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
    border-left-color: var(--bs-primary);
}

.example-item.active {
    border-left-color: var(--bs-primary);
    background-color: var(--bs-primary-bg-subtle);
    color: var(--bs-emphasis-color);
}

.example-item.active::before {
    content: "► ";
    position: absolute;
    left: 0.5rem;
    font-weight: bold;
    color: var(--bs-primary);
}

/* Code blocks in tutorial */
.tutorial-content pre {
    background-color: var(--bs-gray-900);
    color: var(--bs-gray-100);
    padding: 1rem;
    border-radius: 0.375rem;
    overflow-x: auto;
    font-size: 0.875rem;
}

.tutorial-content code {
    background-color: var(--bs-gray-800);
    color: var(--bs-info);
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
}

/* Results styling */
#ai-response {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    min-height: 2rem;
    color: var(--bs-body-color);
    background-color: var(--bs-body-bg);
}

/* Ensure proper contrast in all themes */
.card-body #ai-response {
    background-color: var(--bs-secondary-bg);
    color: var(--bs-body-color);
    border: 1px solid var(--bs-border-color);
}

/* Pattern badges */
.pattern-badge {
    display: inline-block;
    margin: 0.2rem 0.2rem 0.2rem 0;
}

/* Demo containers */
.demo-result {
    border-top: 1px solid var(--bs-border-color);
    padding-top: 1rem;
}

/* Tutorial navigation */
.tutorial-nav.active {
    background-color: var(--bs-primary-bg-subtle);
    border-color: var(--bs-primary);
    color: var(--bs-primary);
}

/* Progress bar styling */
.progress {
    height: 8px;
}

/* Alert improvements */
.alert h5, .alert h6 {
    color: inherit;
}

/* Card hover effects */
.card {
    transition: box-shadow 0.15s ease-in-out;
}

.card:hover {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

/* Loading spinner container */
#loading {
    padding: 2rem 0;
}

/* Risk level badges */
.badge {
    font-size: 0.75em;
}

/* Enhanced responsive design with multiple breakpoints */
@media (max-width: 1200px) {
    .container-xl {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

@media (max-width: 992px) {
    .tutorial-sidebar {
        margin-bottom: 1.5rem;
    }
    
    .lab-controls {
        flex-direction: column;
        gap: 1rem;
    }
}

@media (max-width: 768px) {
    .display-4 {
        font-size: 2rem;
    }
    
    .responsive-flex {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .responsive-flex .btn {
        width: 100%;
    }
    
    .example-item {
        padding: 0.75rem;
    }
}

@media (max-width: 576px) {
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .btn {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }
    
    .card-body {
        padding: 1rem;
    }
}

/* Dark theme adjustments - comprehensive visibility fixes */
[data-bs-theme="dark"] .bg-light {
    background-color: var(--bs-secondary-bg) !important;
    color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] .text-muted {
    color: var(--bs-secondary-color) !important;
}

/* Additional dark theme contrast fixes */
[data-bs-theme="dark"] .bg-body-secondary {
    background-color: var(--bs-secondary-bg) !important;
    color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] .text-body {
    color: var(--bs-body-color) !important;
}

/* Ensure example details are visible */
[data-bs-theme="dark"] .border {
    border-color: var(--bs-border-color) !important;
}

[data-bs-theme="dark"] small {
    color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] strong {
    color: var(--bs-emphasis-color) !important;
}

/* Fix navigation item active state in dark theme */
[data-bs-theme="dark"] .example-item.active {
    background-color: var(--bs-secondary-bg) !important;
    color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] .example-item.active h6 {
    color: var(--bs-emphasis-color) !important;
}

[data-bs-theme="dark"] .example-item.active .text-muted {
    color: var(--bs-secondary-color) !important;
}

[data-bs-theme="dark"] .example-item:hover {
    background-color: var(--bs-secondary-bg) !important;
    color: var(--bs-body-color) !important;
}

/* Override Bootstrap list-group-item-action in dark theme */
[data-bs-theme="dark"] .list-group-item-action.active {
    background-color: var(--bs-secondary-bg) !important;
    color: var(--bs-body-color) !important;
    border-color: var(--bs-border-color) !important;
}

[data-bs-theme="dark"] .list-group-item-action:hover {
    background-color: var(--bs-secondary-bg) !important;
    color: var(--bs-body-color) !important;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .example-item:focus {
        outline: 3px solid;
        outline-color: Highlight;
    }
    
    .btn:focus {
        outline: 3px solid;
        outline-color: Highlight;
    }
}

/* Security-conscious styling - less obvious to potential attackers */
.security-test-code {
    background-color: var(--bs-secondary-bg-subtle);
    border: 1px solid var(--bs-secondary-border-subtle);
    color: var(--bs-body-color);
    padding: 0.5rem;
    border-radius: 0.375rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Enhanced accessibility for success/failure indicators */
.test-result-success {
    color: var(--bs-danger);
    font-weight: bold;
}

.test-result-success::before {
    content: "⚠ ";
    speak: literal;
}

.test-result-failed {
    color: var(--bs-success);
    font-weight: bold;
}

.test-result-failed::before {
    content: "✓ ";
    speak: literal;
}

/* Screen reader only text for better accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Tooltip improvements */
.tooltip {
    font-size: 0.875rem;
}

/* Form improvements */
textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

/* Enhanced focus indicators for accessibility */
.btn:focus {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.25);
}

.form-control:focus {
    border-color: var(--bs-primary);
    outline: 2px solid transparent;
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.25);
}

/* Improved button spacing */
.btn-group-responsive .btn + .btn {
    margin-left: 0.5rem;
}

@media (max-width: 576px) {
    .btn-group-responsive {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .btn-group-responsive .btn + .btn {
        margin-left: 0;
    }
}

/* Print styles for security documentation */
@media print {
    .security-test-code,
    .injection-code {
        background: white;
        color: black;
        border: 1px solid black;
        break-inside: avoid;
    }
    
    .test-result-success::before,
    .test-result-failed::before {
        font-weight: bold;
    }
    
    .btn {
        display: none;
    }
    
    .no-print {
        display: none;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .example-item,
    .card {
        transition: none;
    }
    
    .progress-bar {
        transition: none;
    }
}

/* Enhanced risk level indicators with better accessibility */
.risk-level-high {
    background-color: var(--bs-danger);
    color: white;
}

.risk-level-high::after {
    content: " (High Risk)";
    font-size: 0.75em;
}

.risk-level-medium {
    background-color: var(--bs-warning);
    color: var(--bs-dark);
}

.risk-level-medium::after {
    content: " (Medium Risk)";
    font-size: 0.75em;
}

.risk-level-low {
    background-color: var(--bs-info);
    color: white;
}

.risk-level-low::after {
    content: " (Low Risk)";
    font-size: 0.75em;
}
