* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.95;
}

.main-content {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
    padding: 20px;
}

.control-panel {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    height: fit-content;
    position: sticky;
    top: 20px;
}

.control-panel h2 {
    margin-bottom: 20px;
    color: #667eea;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.control-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #dee2e6;
}

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

.control-section h3 {
    font-size: 1.1em;
    margin-bottom: 10px;
    color: #495057;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s ease;
    width: 100%;
    margin-bottom: 10px;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

input[type="text"],
textarea {
    width: 100%;
    padding: 10px;
    border: 2px solid #dee2e6;
    border-radius: 5px;
    font-size: 1em;
    margin-bottom: 10px;
    font-family: inherit;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

.large-textarea {
    min-height: 350px;
    font-size: 1em;
    line-height: 1.5;
}

.slider-container {
    margin-top: 15px;
}

.slider-container label {
    display: block;
    margin-bottom: 8px;
    color: #495057;
    font-weight: 500;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #dee2e6;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
}

.status {
    margin-top: 10px;
    padding: 8px;
    border-radius: 5px;
    font-size: 0.9em;
}

.status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.visualization-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.viz-section {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: visible;
}

.viz-section h2 {
    color: #667eea;
    margin-bottom: 15px;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.feature-selector {
    margin-bottom: 15px;
}

.feature-selector label {
    margin-right: 10px;
    font-weight: 500;
    color: #495057;
}

.feature-selector select {
    padding: 8px 15px;
    border: 2px solid #dee2e6;
    border-radius: 5px;
    font-size: 1em;
    background: white;
    cursor: pointer;
}

.plot-container {
    background: white;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-height: 400px;
}

.bayes-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.bayes-step {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.bayes-step h3 {
    font-size: 1em;
    margin-bottom: 10px;
    color: #667eea;
}

/* Step-by-Step Visualization Styles */
.animation-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.animation-controls .btn {
    width: auto;
    padding: 10px 20px;
}

.step-indicator {
    margin-left: auto;
    font-weight: 600;
    color: #667eea;
    font-size: 1.1em;
}

.formula-display {
    margin-bottom: 20px;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.formula-box {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-bottom: 30px;
    overflow-x: auto;
    overflow-y: visible;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

.formula-box h3 {
    margin: 0 0 20px 0;
    font-size: 1.4em;
    color: white;
    border: none;
    padding: 0;
}

.formula-text {
    font-size: 1.8em;
    font-family: 'Courier New', monospace;
    text-align: center;
    margin-bottom: 15px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    overflow-wrap: break-word;
    word-break: break-word;
    overflow: hidden;
}

.formula-fraction {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 5px;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.formula-numerator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.5);
    min-width: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    flex-wrap: wrap;
    overflow: hidden;
}


.formula-denominator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    flex-wrap: wrap;
    overflow: hidden;
}

.formula-part {
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    transition: all 0.3s ease;
    cursor: pointer;
    max-width: 100%;
    box-sizing: border-box;
    overflow-wrap: break-word;
    word-break: break-word;
    flex-shrink: 1;
}

.formula-part.active {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.05);
    transform-origin: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 1;
    position: relative;
}

.formula-part.highlighted {
    background: #ffc107;
    color: #333;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.formula-explanation {
    font-size: 1.1em;
    opacity: 0.95;
    text-align: center;
    font-style: italic;
    margin-top: 15px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    max-width: 100%;
    box-sizing: border-box;
    overflow-wrap: break-word;
    word-break: break-word;
}

.bayes-step-by-step {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.step-container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: all 0.3s ease;
    display: none;
    opacity: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

.step-container.active {
    display: block;
    opacity: 1;
    transform: translateX(0);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
    border-left: 5px solid #667eea;
    margin-top: 20px;
    animation: slideIn 0.5s ease-out;
}

.step-container.completed {
    display: none;
    opacity: 0;
}

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

.step-header {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    max-width: 100%;
    box-sizing: border-box;
    overflow-wrap: break-word;
    word-break: break-word;
}

.step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: #667eea;
    color: white;
    border-radius: 50%;
    font-weight: bold;
    font-size: 1.2em;
    flex-shrink: 0;
}

.step-container.active .step-number {
    background: #667eea;
    animation: stepPulse 1s ease-in-out infinite;
}

.step-container.completed .step-number {
    background: #28a745;
}

@keyframes stepPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.step-header h3 {
    flex: 1;
    margin: 0;
    color: #667eea;
    font-size: 1.2em;
    border: none;
    padding: 0;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-word;
}

.step-status {
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
    background: #6c757d;
    color: white;
}

.step-container.active .step-status {
    background: #667eea;
    animation: statusPulse 1s ease-in-out infinite;
}

.step-container.completed .step-status {
    background: #28a745;
}

.step-container.completed .step-status::after {
    content: " ✓";
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.step-content {
    padding: 20px;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: visible;
}

.step-description {
    color: #6c757d;
    margin-bottom: 15px;
    line-height: 1.6;
    font-size: 0.95em;
}

.visualization-chart {
    min-height: 200px;
    margin: 15px 0;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 10px;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: visible;
    position: relative;
}

.visualization-chart .js-plotly-plot,
.visualization-chart > div {
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.visualization-chart svg {
    max-width: 100% !important;
    height: auto !important;
}

.feature-likelihoods-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.feature-likelihood-item {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 5px;
    border-left: 3px solid #667eea;
}

.feature-likelihood-item h4 {
    margin: 0 0 8px 0;
    font-size: 0.9em;
    color: #495057;
}

.feature-likelihood-values {
    display: flex;
    justify-content: space-between;
    font-size: 0.85em;
}

.calculation-flow, .normalization-flow {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.calc-step, .norm-step {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    margin: 8px 0;
    background: white;
    border-radius: 5px;
    border-left: 4px solid #667eea;
}

.calc-label, .norm-label {
    font-weight: 500;
    color: #495057;
}

.calc-value, .norm-value {
    font-weight: bold;
    color: #667eea;
    font-family: 'Courier New', monospace;
    font-size: 1.1em;
}

.probability-display {
    font-size: 1.1em;
    max-width: 100%;
    box-sizing: border-box;
    overflow-wrap: break-word;
    word-break: break-word;
}

.prob-item {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    margin: 5px 0;
    border-radius: 5px;
    background: #f8f9fa;
    max-width: 100%;
    box-sizing: border-box;
    overflow-wrap: break-word;
    word-break: break-word;
}

.prob-item > span {
    max-width: 50%;
    overflow-wrap: break-word;
    word-break: break-word;
}

.prob-item.spam {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
}

.prob-item.ham {
    background: #d1ecf1;
    border-left: 4px solid #17a2b8;
}

.prob-value {
    font-weight: bold;
    color: #667eea;
}

.prediction-display {
    text-align: center;
    padding: 20px;
    font-size: 1.5em;
    font-weight: bold;
    border-radius: 8px;
}

.prediction-display.spam {
    background: #f8d7da;
    color: #721c24;
}

.prediction-display.ham {
    background: #d4edda;
    color: #155724;
}

.features-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 0;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

/* Base features section - two column grid */
.base-features-section {
    width: 100%;
    margin-bottom: 0;
}

.base-features-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    width: 100%;
}

@media (max-width: 768px) {
    .base-features-grid {
        grid-template-columns: 1fr;
    }
}

.stats-container {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.stats-placeholder {
    text-align: center;
    color: #6c757d;
    padding: 40px;
    font-style: italic;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.stat-card {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.stat-card h4 {
    margin: 0 0 10px 0;
    color: #667eea;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 2em;
    font-weight: bold;
    color: #495057;
    margin: 5px 0;
}

.stat-label {
    font-size: 0.9em;
    color: #6c757d;
}

.stats-plot {
    margin-top: 20px;
    min-height: 300px;
}

.feature-comparison-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    font-size: 0.9em;
}

.feature-comparison-table th,
.feature-comparison-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

.feature-comparison-table th {
    background: #667eea;
    color: white;
    font-weight: 600;
}

.feature-comparison-table tr:hover {
    background: #f8f9fa;
}

.stat-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 600;
    margin-left: 8px;
}

.stat-badge.spam {
    background: #fff3cd;
    color: #856404;
}

.stat-badge.ham {
    background: #d1ecf1;
    color: #0c5460;
}

.feature-card {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.feature-card h4 {
    color: #667eea;
    margin-bottom: 8px;
    font-size: 0.9em;
}

.feature-value {
    font-size: 1.3em;
    font-weight: bold;
    color: #495057;
}

/* TF-IDF Features Collapsible Section */
.tfidf-features-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
}

.tfidf-header {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    margin-bottom: 15px;
    user-select: none;
    padding: 10px;
    border-radius: 8px;
    transition: background-color 0.2s ease;
}

.tfidf-header:hover {
    background-color: #f8f9fa;
}

.tfidf-header h3 {
    margin: 0;
    color: #667eea;
    flex: 1;
}

.tfidf-toggle-btn {
    background: transparent;
    border: 2px solid #667eea;
    font-size: 1em;
    color: #667eea;
    cursor: pointer;
    padding: 0;
    transition: transform 0.3s ease, background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    flex-shrink: 0;
    font-weight: bold;
}

.tfidf-toggle-btn:hover {
    background-color: rgba(102, 126, 234, 0.1);
    border-color: #5568d3;
}

.tfidf-content {
    overflow: hidden;
    transition: opacity 0.3s ease;
}

.tfidf-content.collapsed {
    display: none;
}

.tfidf-content.expanded {
    display: block;
    opacity: 1;
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .control-panel {
        position: static;
    }
}

