/* Algebraic Simplification Steps Styling */
.simplification-steps {
    background: #ffffff;
    border: 1px solid #e0e6ed;
    border-radius: 8px;
    padding: 20px;
    font-family: 'Inter', sans-serif;
    margin-bottom: 20px;
    max-width: 100%;
    overflow-x: auto;
}

.step-item {
    border-bottom: 1px solid #f0f2f5;
    padding: 15px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 100%;
    overflow: hidden;
}

.step-item:last-child {
    border-bottom: none;
}

.law-name {
    color: #64748b;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.expression-text {
    font-size: 1.1rem;
    color: #1e293b;
    font-family: 'Cambria', 'MathJax_Main', serif;
    margin-top: 4px;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    white-space: nowrap;
    padding-bottom: 8px;
}

/* Scrollbar styling for expression overflow */
.expression-text::-webkit-scrollbar {
    height: 6px;
}

.expression-text::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.expression-text::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.expression-text::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.rule-formula {
    display: inline-block;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #475569;
    margin-left: 10px;
    font-family: monospace;
}

/* KaTeX container fix - prevent overflow */
.katex-display {
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    padding: 8px 0;
}

.katex {
    white-space: nowrap;
}

/* Dark Mode Support */
.dark .simplification-steps {
    background: #1f2937;
    border-color: #374151;
}

.dark .step-item {
    border-color: #374151;
}

.dark .law-name {
    color: #9ca3af;
}

.dark .expression-text {
    color: #e5e7eb;
}

.dark .rule-formula {
    background: #374151;
    color: #d1d5db;
}

.dark .expression-text::-webkit-scrollbar-track {
    background: #374151;
}

.dark .expression-text::-webkit-scrollbar-thumb {
    background: #4b5563;
}

.dark .expression-text::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* Virtual Logic Keyboard Buttons */
.keyboard-btn {
    min-width: 44px;
    height: 44px;
    font-size: 1.25rem;
    font-weight: 500;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: linear-gradient(to bottom, #ffffff, #f9fafb);
    color: #374151;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
}

.keyboard-btn:hover {
    background: linear-gradient(to bottom, #3b82f6, #2563eb);
    color: white;
    border-color: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.3);
}

.keyboard-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Dark Mode Keyboard */
.dark .keyboard-btn {
    background: linear-gradient(to bottom, #374151, #1f2937);
    border-color: #4b5563;
    color: #e5e7eb;
}

.dark .keyboard-btn:hover {
    background: linear-gradient(to bottom, #3b82f6, #2563eb);
    color: white;
    border-color: #3b82f6;
}

/* Mobile responsive - slightly smaller buttons */
@media (max-width: 640px) {
    .keyboard-btn {
        min-width: 38px;
        height: 38px;
        font-size: 1.1rem;
    }
}

/* Teaching Mode: Step Highlighting */
.step-before-after {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.step-highlight {
    background-color: #fff3cd;
    border-bottom: 2px solid #ffc107;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
}

.step-arrow {
    font-size: 1.5rem;
    color: #10b981;
    font-weight: bold;
}

/* Dark Mode Step Highlight */
.dark .step-highlight {
    background-color: #4a3f1a;
    border-bottom-color: #ffc107;
}

.dark .step-arrow {
    color: #34d399;
}

/* Mobile: Stack before/after vertically */
@media (max-width: 640px) {
    .step-before-after {
        flex-direction: column;
        align-items: flex-start;
    }

    .step-arrow {
        transform: rotate(90deg);
        margin: 8px 0;
    }
}

/* Truth Table Fixes - Prevent circular borders on values */
table td,
table th {
    border-radius: 0 !important;
}

/* Ensure truth table values display cleanly as plain text */
.truth-table td,
table td {
    text-align: center;
    border-radius: 0 !important;
    background: transparent !important;
}

/* Force all table cell content to be clean text */
table td span,
table td div {
    border-radius: 0 !important;
    background: inherit !important;
}

/* Output column styling - clean consistent numbers */
td:last-child {
    font-weight: 600;
}

/* Green for 1, gray for 0 in output - without circles */
td.output-1 {
    color: #10b981;
    font-weight: 700;
}

td.output-0 {
    color: #6b7280;
}

/* Remove any inherited circular styling from table cells */
table.min-w-full td,
table.min-w-full th {
    border-radius: 0 !important;
}

/* Efficiency Dashboard Styling */
.efficiency-dashboard {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.efficiency-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 600;
    color: #334155;
    margin: 0 0 16px 0;
}

.efficiency-icon {
    color: #3b82f6;
}

.efficiency-grid {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.efficiency-card {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 16px 24px;
    text-align: center;
    min-width: 100px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.efficiency-card.original {
    border-color: #fca5a5;
    background: linear-gradient(to bottom, #fff, #fef2f2);
}

.efficiency-card.simplified {
    border-color: #86efac;
    background: linear-gradient(to bottom, #fff, #f0fdf4);
}

.efficiency-card.result {
    border-width: 3px;
    background: white;
}

.card-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    margin-bottom: 4px;
}

.card-value {
    font-size: 2rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1;
}

.card-unit {
    font-size: 0.7rem;
    color: #94a3b8;
    margin-top: 4px;
}

.efficiency-arrow {
    font-size: 1.5rem;
    color: #94a3b8;
    font-weight: bold;
}

/* Dark Mode Efficiency Dashboard */
.dark .efficiency-dashboard {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    border-color: #374151;
}

.dark .efficiency-title {
    color: #e5e7eb;
}

.dark .efficiency-card {
    background: #1f2937;
    border-color: #374151;
}

.dark .efficiency-card.original {
    border-color: #f87171;
    background: linear-gradient(to bottom, #1f2937, #1c1917);
}

.dark .efficiency-card.simplified {
    border-color: #4ade80;
    background: linear-gradient(to bottom, #1f2937, #0f172a);
}

.dark .card-value {
    color: #f1f5f9;
}

.dark .card-label {
    color: #9ca3af;
}

/* Mobile responsive */
@media (max-width: 640px) {
    .efficiency-grid {
        flex-direction: column;
    }

    .efficiency-arrow {
        transform: rotate(90deg);
    }

    .efficiency-card {
        width: 100%;
        max-width: 200px;
    }
}