/* Thread Contention Visualization Styles */
/* Styling handled in main styles.css */
/*.contention-section {
    grid-area: contention;
}*/

.section-description {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}

.problem-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.problem-card {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 1.75rem;
    box-shadow: var(--card-shadow);
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.problem-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.demo-btn {
    background-color: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border: none;
    border-radius: 8px;
    padding: 0.85rem 1.5rem;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 1.25rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.demo-btn:before {
    content: "\f04b";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    margin-right: 10px;
}

.demo-btn:hover {
    background-color: var(--accent-primary);
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.demo-features {
    list-style-type: none;
    padding-left: 0.5rem;
    margin: 0.75rem 0;
    color: #555;
    font-size: 0.9rem;
}

.demo-features li {
    position: relative;
    padding-left: 1.5rem;
    margin-bottom: 0.5rem;
}

.demo-features li:before {
    content: "\f00c";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    color: #4caf50;
    position: absolute;
    left: 0;
}

.problem-card h4 {
    color: var(--color-header);
    margin-bottom: 0.8rem;
    font-size: 1.2rem;
}

.problem-card p {
    margin-bottom: 1.2rem;
    color: #555;
    font-size: 0.9rem;
}

.demo-btn {
    background-color: var(--color-header);
    color: white;
    border: none;
    padding: 0.6rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s;
}

.demo-btn:hover {
    background-color: #0d47a1;
}

/* Resource locks styling */
.resource-locks {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.resource-lock {
    background-color: #f5f5f5;
    border-radius: 6px;
    padding: 1rem;
    border: 1px solid #eee;
    transition: all 0.3s ease;
}

.resource-lock.locked {
    border-color: var(--color-blocked);
    box-shadow: 0 0 0 1px var(--color-blocked);
}

.resource-lock h4 {
    margin-bottom: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.lock-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.lock-status i {
    font-size: 1rem;
}

/* Demo explanation and results */
.demo-explanation {
    background-color: #f0f8ff;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2rem 0;
    border-left: 6px solid #1565c0;
    animation: slideIn 0.5s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.demo-result {
    background-color: #f5f5f5;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2rem 0;
    border-left: 4px solid #43a047;
    animation: slideIn 0.5s ease;
}

.explanation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.explanation-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.3rem;
}

.demo-badge {
    background-color: #ff9800;
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    animation: pulse 1.5s infinite;
}

.demo-explanation h3, .demo-result h3 {
    margin-top: 0;
    color: #333;
}

.demo-explanation.race-condition {
    border-left-color: #f57c00;
}

.demo-explanation.deadlock {
    border-left-color: #d32f2f;
}

.demo-explanation.livelock {
    border-left-color: #7b1fa2;
}

.demo-animation {
    height: 6px;
    background-color: #e0e0e0;
    border-radius: 3px;
    margin: 1rem 0;
    overflow: hidden;
    position: relative;
}

.demo-animation::after {
    content: '';
    position: absolute;
    left: -50%;
    width: 50%;
    height: 100%;
    background-color: #2196f3;
    animation: loading 1.5s infinite ease;
}

.wait-indicator {
    padding: 0.5rem;
    background-color: #ffecb3;
    border: 1px dashed #ffa000;
    border-radius: 4px;
    font-size: 0.85rem;
    margin: 0.5rem 0;
    text-align: center;
    animation: pulse 1s infinite;
}

.reset-btn {
    margin: 1rem 0;
    background-color: #f44336;
}

.reset-btn:hover {
    background-color: #d32f2f;
}

.resource-value {
    margin-top: 0.5rem;
    font-family: monospace;
    font-size: 0.9rem;
}

/* Animations */
@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

@keyframes loading {
    0% { left: -50%; }
    100% { left: 100%; }
}

@keyframes slideIn {
    0% { transform: translateY(-20px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

/* Step-by-step visualization styles */
.demo-step-tracker {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin: 1.5rem 0;
    overflow: hidden;
    max-height: 300px;
    display: flex;
    flex-direction: column;
}

.tracker-header {
    background: #f5f5f5;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #ddd;
}

.tracker-header h4 {
    margin: 0;
    color: #333;
    font-size: 1rem;
}

.tracker-steps {
    overflow-y: auto;
    padding: 0.5rem;
    flex-grow: 1;
}

.tracker-step {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    border-left: 3px solid transparent;
    transition: all 0.3s ease;
}

.tracker-step.active {
    background: #e3f2fd;
    border-left: 3px solid #1976d2;
}

.step-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1rem;
    font-weight: bold;
    font-size: 0.8rem;
    color: #555;
}

.tracker-step.active .step-number {
    background: #1976d2;
    color: white;
}

.step-text {
    font-size: 0.9rem;
    color: #555;
}

.tracker-step.active .step-text {
    color: #333;
    font-weight: 500;
}

/* Timeline visualization */
.demo-timeline {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin: 1.5rem 0;
    overflow: hidden;
    max-height: 250px;
    display: flex;
    flex-direction: column;
}

.timeline-header {
    background: #f5f5f5;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #ddd;
}

.timeline-header h4 {
    margin: 0;
    color: #333;
    font-size: 1rem;
}

.timeline-events {
    overflow-y: auto;
    padding: 0.5rem;
    flex-grow: 1;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
}

.timeline-event {
    padding: 0.4rem 0.75rem;
    border-radius: 4px;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.event-time {
    color: #666;
    margin-right: 0.75rem;
    font-size: 0.75rem;
}

.timeline-event.thread-1 {
    background: rgba(25, 118, 210, 0.1);
    border-left: 3px solid #1976d2;
}

.timeline-event.thread-2 {
    background: rgba(156, 39, 176, 0.1);
    border-left: 3px solid #9c27b0;
}

.timeline-event.system-event {
    background: rgba(0, 0, 0, 0.05);
    border-left: 3px solid #616161;
}

.timeline-event.error-event {
    background: rgba(244, 67, 54, 0.1);
    border-left: 3px solid #f44336;
    font-weight: 600;
}

.timeline-event.warning {
    background: rgba(255, 152, 0, 0.1);
    border-left: 3px solid #ff9800;
}

.timeline-event.success {
    background: rgba(76, 175, 80, 0.1);
    border-left: 3px solid #4caf50;
}

/* Memory access visualization */
.memory-access {
    position: absolute;
    z-index: 10;
    transition: all 0.5s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.access-arrow {
    width: 10px;
    height: 10px;
    border-left: 2px solid;
    border-bottom: 2px solid;
    transform: rotate(-45deg);
}

.access-info {
    background: white;
    padding: 0.3rem 0.75rem;
    border-radius: 4px;
    font-size: 0.85rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    margin-top: 0.5rem;
}

.read-access .access-arrow {
    border-color: #1976d2;
}

.read-access .access-info {
    border-left: 3px solid #1976d2;
}

.write-access .access-arrow {
    border-color: #f44336;
}

.write-access .access-info {
    border-left: 3px solid #f44336;
}

/* Results diagrams */
.deadlock-diagram, .livelock-diagram {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, auto);
    gap: 0.5rem;
    margin: 1.5rem auto;
    max-width: 400px;
    text-align: center;
}

.deadlock-node {
    padding: 0.75rem;
    border-radius: 4px;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
}

.thread-node {
    background: rgba(25, 118, 210, 0.1);
    border: 1px solid #1976d2;
    color: #1976d2;
}

.resource-node {
    background: rgba(156, 39, 176, 0.1);
    border: 1px solid #9c27b0;
    color: #9c27b0;
}

.deadlock-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #616161;
    font-size: 0.8rem;
}

.deadlock-arrow.right::after {
    content: "→";
    margin-left: 0.3rem;
}

.deadlock-arrow.left::before {
    content: "←";
    margin-right: 0.3rem;
}

.deadlock-arrow.down::after {
    content: "↓";
    margin-top: 0.3rem;
}

.deadlock-arrow.up::before {
    content: "↑";
    margin-bottom: 0.3rem;
}

/* Step explanation box styles */
.step-explanation-box {
    margin: 1rem 0;
    padding: 1rem;
    border-radius: 8px;
    background-color: #f8f9fa;
    border-left: 4px solid #2196f3;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    max-width: 95%;
}

.explanation-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #1976d2;
    font-size: 0.95rem;
}

.explanation-content {
    color: #333;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Animation for highlighting new explanation */
.highlight-pulse {
    animation: explanation-pulse 1s ease;
}

@keyframes explanation-pulse {
    0% {
        background-color: #f8f9fa;
        transform: translateY(0);
    }
    50% {
        background-color: rgba(33, 150, 243, 0.1);
        transform: translateY(-2px);
    }
    100% {
        background-color: #f8f9fa;
        transform: translateY(0);
    }
}

/* Livelock cycle */
.livelock-cycle {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 1.5rem 0;
}

.cycle-step {
    background: #f5f5f5;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    width: 80%;
    text-align: center;
    border-left: 3px solid #9c27b0;
}

.cycle-arrow {
    font-size: 1.5rem;
    margin: 0.5rem 0;
    color: #616161;
}

/* Solution box */
.solution-box {
    background: #e8f5e9;
    border: 1px solid #c8e6c9;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1.5rem;
}

.solution-box h4 {
    color: #2e7d32;
    margin-top: 0;
    margin-bottom: 0.75rem;
}

.solution-box pre {
    background: white;
    padding: 0.75rem;
    border-radius: 4px;
    border-left: 3px solid #4caf50;
}

.lock-owner {
    margin-top: 0.8rem;
    margin-bottom: 1rem;
}

.owner-label {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 0.3rem;
}

.owner-thread {
    display: inline-block;
    background-color: var(--color-running);
    color: white;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: bold;
}

.waiting-threads {
    margin-top: 1rem;
}

.waiting-threads-label {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.thread-queue {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.queue-thread {
    background-color: var(--color-blocked);
    color: white;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: bold;
}

/* Animations for concurrency problems */
.race-condition-animation,
.deadlock-animation,
.livelock-animation {
    height: 200px;
    background-color: #f5f5f5;
    border-radius: 8px;
    margin-top: 1rem;
    position: relative;
    overflow: hidden;
}

.resource-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    font-weight: bold;
    transition: all 0.3s ease;
}

.animation-thread {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.5s ease;
}

.result-panel {
    margin-top: 1rem;
    background-color: #fff;
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 1rem;
}

.result-title {
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: var(--color-header);
}

.animation-controls {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Modal for detailed explanations */
.explanation-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.close-modal {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
}

.close-modal:hover {
    color: #333;
}

.modal-title {
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: var(--color-header);
}

.modal-section {
    margin-bottom: 2rem;
}

.modal-section h3 {
    margin-bottom: 1rem;
    color: var(--color-header);
}

.code-example {
    background-color: #f5f5f5;
    padding: 1rem;
    border-radius: 4px;
    font-family: monospace;
    white-space: pre;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.solution-tag {
    display: inline-block;
    background-color: #4caf50;
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}
