/* ===================================
   RF ANIMATOR - Complete Styles
   1:1 Port from React/Tailwind
   =================================== */

/* === Base Reset & Variables === */
:root {
    --rf-emerald-50: #ecfdf5;
    --rf-emerald-500: #10b981;
    --rf-emerald-600: #059669;
    --rf-rose-50: #fff1f2;
    --rf-rose-500: #f43f5e;
    --rf-rose-600: #e11d48;
    --rf-blue-50: #eff6ff;
    --rf-blue-500: #3b82f6;
    --rf-blue-600: #2563eb;
    --rf-amber-50: #fffbeb;
    --rf-amber-500: #f59e0b;
    --rf-amber-600: #d97706;
    --rf-indigo-50: #eef2ff;
    --rf-indigo-500: #6366f1;
    --rf-indigo-600: #4f46e5;
    --rf-slate-50: #f8fafc;
    --rf-slate-100: #f1f5f9;
    --rf-slate-200: #e2e8f0;
    --rf-slate-300: #cbd5e1;
    --rf-slate-400: #94a3b8;
    --rf-slate-500: #64748b;
    --rf-slate-600: #475569;
    --rf-slate-700: #334155;
    --rf-slate-800: #1e293b;
    --rf-slate-900: #0f172a;
}

/* === Mode Selection Screen === */
.rf-mode-selection {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, var(--rf-slate-100) 0%, var(--rf-slate-200) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
}

.rf-mode-selection-header {
    text-align: center;
    margin-bottom: 48px;
}

.rf-mode-selection-header .rf-logo {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--rf-blue-500), var(--rf-indigo-500));
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    box-shadow: 0 10px 40px -10px rgba(99, 102, 241, 0.5);
}

.rf-mode-selection-header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--rf-slate-800);
    margin: 0 0 8px;
    letter-spacing: -0.03em;
}

.rf-mode-selection-header p {
    font-size: 1rem;
    color: var(--rf-slate-500);
    margin: 0;
}

.rf-mode-buttons {
    display: flex;
    gap: 24px;
}

.rf-mode-btn {
    width: 280px;
    padding: 32px;
    background: white;
    border: 2px solid var(--rf-slate-200);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
}

.rf-mode-btn:hover {
    border-color: var(--rf-blue-500);
    transform: translateY(-4px);
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.15);
}

.rf-mode-btn h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--rf-slate-800);
    margin: 0 0 8px;
}

.rf-mode-btn p {
    font-size: 0.875rem;
    color: var(--rf-slate-500);
    margin: 0;
}

/* === Main Animator Container === */
.rf-animator-container {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, var(--rf-slate-50), var(--rf-slate-100), var(--rf-slate-200));
    display: none;
    flex-direction: row;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    z-index: 9998;
    overflow: hidden;
}

.rf-animator-container.active {
    display: flex;
}

/* === Header Bar === */
.rf-header-bar {
    position: absolute;
    top: 0;
    left: 350px;
    right: 0;
    height: 64px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--rf-slate-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
}

.rf-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.rf-header-logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--rf-blue-500), var(--rf-indigo-500));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-size: 14px;
}

.rf-header-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--rf-slate-800);
    margin: 0;
}

.rf-header-subtitle {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--rf-slate-500);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 2px 0 0;
}

.rf-header-stats {
    display: flex;
    align-items: center;
    gap: 24px;
}

.rf-stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--rf-slate-600);
}

.rf-stat-value {
    font-weight: 700;
    color: var(--rf-slate-700);
}

.rf-back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--rf-slate-100);
    border: 1px solid var(--rf-slate-200);
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--rf-slate-600);
    cursor: pointer;
    transition: all 0.2s;
}

.rf-back-btn:hover {
    background: white;
    border-color: var(--rf-slate-300);
    color: var(--rf-slate-800);
}

/* === Left Sidebar === */
.rf-sidebar {
    width: 350px;
    height: 100%;
    background: var(--rf-slate-50);
    border-right: 1px solid var(--rf-slate-200);
    padding: 24px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 50;
}

.rf-sidebar-section {
    margin-bottom: 24px;
}

.rf-sidebar-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--rf-slate-700);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 12px;
}

/* Sample Buttons */
.rf-sample-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rf-sample-btn {
    width: 100%;
    padding: 12px 16px;
    background: white;
    border: 1px solid var(--rf-slate-200);
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.rf-sample-btn:hover:not(.disabled):not(.active) {
    border-color: var(--rf-slate-300);
    background: var(--rf-slate-50);
}

.rf-sample-btn.active {
    background: var(--rf-slate-800);
    border-color: var(--rf-slate-800);
    color: white;
}

.rf-sample-btn.active:hover {
    background: var(--rf-slate-700);
    border-color: var(--rf-slate-700);
    color: white;
}

.rf-sample-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.rf-sample-label {
    font-size: 0.875rem;
    font-weight: 600;
}

.rf-sample-class-pill {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 100px;
}

/* Run Button */
.rf-run-btn {
    width: 100%;
    padding: 14px 20px;
    background: var(--rf-slate-800);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s;
    margin-top: 16px;
}

.rf-run-btn:hover:not(:disabled) {
    background: var(--rf-slate-700);
    transform: translateY(-1px);
}

.rf-run-btn:disabled {
    background: var(--rf-slate-400);
    cursor: not-allowed;
}

/* Features Preview */
.rf-features-panel {
    background: white;
    border: 1px solid var(--rf-slate-200);
    border-radius: 12px;
    padding: 16px;
    margin-top: 16px;
}

.rf-features-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--rf-slate-600);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.rf-feature-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--rf-slate-100);
}

.rf-feature-row:last-child {
    border-bottom: none;
}

.rf-feature-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--rf-slate-700);
}

.rf-feature-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--rf-slate-700);
}

/* === Main Content Area === */
.rf-main-content {
    flex: 1;
    margin-top: 64px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-y: auto;
}

/* Grid Info Bar */
.rf-grid-info {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--rf-slate-600);
}

/* === Mini Tree Grid === */
.rf-tree-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.rf-tree-card {
    background: #f8fafc;
    border: 2px solid #94a3b8;
    border-radius: 16px;
    height: 150px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.rf-tree-card:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 25px -8px rgba(0, 0, 0, 0.15);
}

.rf-tree-card.predicted {
    border-width: 2px;
}

.rf-tree-card.class-Approved { border-color: var(--rf-emerald-500); background: var(--rf-emerald-50); }
.rf-tree-card.class-Rejected { border-color: var(--rf-rose-500); background: var(--rf-rose-50); }
.rf-tree-card.class-Kama { border-color: var(--rf-blue-500); background: var(--rf-blue-50); }
.rf-tree-card.class-Rosa { border-color: var(--rf-amber-500); background: var(--rf-amber-50); }
.rf-tree-card.class-Canadian { border-color: var(--rf-indigo-500); background: var(--rf-indigo-50); }

.rf-tree-id {
    position: absolute;
    top: 8px;
    left: 10px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--rf-slate-600);
}

.rf-tree-svg-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 10px 10px;
}

.rf-tree-svg-container svg {
    width: 100%;
    height: 100%;
}

.rf-tree-prediction-chip {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 800;
    color: white;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.rf-tree-prediction-chip.visible {
    opacity: 1;
    transform: scale(1);
}

.rf-tree-prediction-chip.class-Approved { background: var(--rf-emerald-500); }
.rf-tree-prediction-chip.class-Rejected { background: var(--rf-rose-500); }
.rf-tree-prediction-chip.class-Kama { background: var(--rf-blue-500); }
.rf-tree-prediction-chip.class-Rosa { background: var(--rf-amber-500); }
.rf-tree-prediction-chip.class-Canadian { background: var(--rf-indigo-500); }

/* Empty State Overlay */
.rf-tree-card-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    color: var(--rf-slate-500);
    background: rgba(255, 255, 255, 0.85);
}

/* === Aggregation Panel === */
.rf-aggregation-panel {
    background: white;
    border: 1px solid var(--rf-slate-200);
    border-radius: 20px;
    padding: 24px 32px;
    box-shadow: 0 4px 16px -4px rgba(0, 0, 0, 0.05);
}

.rf-aggregation-header {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--rf-slate-600);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rf-aggregation-content {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 40px;
    align-items: center;
}

@media (max-width: 1024px) {
    .rf-aggregation-content {
        grid-template-columns: 1fr;
    }
}

/* Vote Bars */
.rf-vote-bars {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.rf-vote-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.rf-vote-label {
    width: 100px;
    text-align: right;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--rf-slate-600);
    text-transform: uppercase;
}

.rf-vote-bar-container {
    flex: 1;
    height: 14px;
    background: var(--rf-slate-100);
    border-radius: 100px;
    overflow: hidden;
    border: 1px solid var(--rf-slate-200);
}

.rf-vote-bar-fill {
    height: 100%;
    width: 0%;
    transition: width 0.4s ease-out;
    border-radius: 100px;
}

.rf-vote-bar-fill.class-Approved { background: var(--rf-emerald-500); }
.rf-vote-bar-fill.class-Rejected { background: var(--rf-rose-500); }
.rf-vote-bar-fill.class-Kama { background: var(--rf-blue-500); }
.rf-vote-bar-fill.class-Rosa { background: var(--rf-amber-500); }
.rf-vote-bar-fill.class-Canadian { background: var(--rf-indigo-500); }

.rf-vote-count {
    min-width: 80px;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--rf-slate-600);
    white-space: nowrap;
}

/* Final Prediction Card */
.rf-final-prediction {
    text-align: center;
    padding-left: 32px;
    border-left: 1px solid var(--rf-slate-100);
}

@media (max-width: 1024px) {
    .rf-final-prediction {
        border-left: none;
        padding-left: 0;
        border-top: 1px solid var(--rf-slate-100);
        padding-top: 24px;
    }
}

.rf-final-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--rf-slate-600);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 8px;
}

.rf-final-value {
    font-size: 2.5rem;
    font-weight: 900;
    letter-spacing: -0.03em;
    line-height: 1;
    margin-bottom: 12px;
}

.rf-final-value.class-Approved { color: var(--rf-emerald-500); }
.rf-final-value.class-Rejected { color: var(--rf-rose-500); }
.rf-final-value.class-Kama { color: var(--rf-blue-500); }
.rf-final-value.class-Rosa { color: var(--rf-amber-500); }
.rf-final-value.class-Canadian { color: var(--rf-indigo-500); }

.rf-final-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.rf-final-status.visible {
    opacity: 1;
    transform: translateY(0);
}

.rf-final-status.correct {
    background: var(--rf-emerald-50);
    color: var(--rf-emerald-600);
}

.rf-final-status.incorrect {
    background: var(--rf-rose-50);
    color: var(--rf-rose-600);
}

/* === Tree Detail Modal === */
.rf-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.rf-modal-overlay.active {
    display: flex;
}

.rf-modal-container {
    width: 90%;
    height: 90%;
    max-width: 1400px;
    background: white;
    border-radius: 24px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* Modal Header */
.rf-modal-header {
    padding: 20px 32px;
    border-bottom: 1px solid var(--rf-slate-100);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rf-modal-back-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--rf-slate-600);
    transition: color 0.2s;
}

.rf-modal-back-btn:hover {
    color: var(--rf-slate-800);
}

.rf-modal-back-icon {
    width: 36px;
    height: 36px;
    background: var(--rf-slate-100);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.rf-modal-back-btn:hover .rf-modal-back-icon {
    background: var(--rf-slate-200);
}

.rf-modal-back-text {
    text-align: left;
}

.rf-modal-back-label {
    font-size: 0.8rem;
    color: var(--rf-slate-500);
    font-weight: 600;
}

.rf-modal-back-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--rf-slate-800);
}

/* Modal Tabs */
.rf-modal-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--rf-slate-100);
    border-radius: 12px;
}

.rf-modal-tab {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--rf-slate-500);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.rf-modal-tab:hover {
    color: var(--rf-slate-700);
}

.rf-modal-tab.active {
    background: white;
    color: var(--rf-slate-800);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.rf-modal-close-btn {
    width: 40px;
    height: 40px;
    background: var(--rf-slate-100);
    border: none;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--rf-slate-500);
    transition: all 0.2s;
}

.rf-modal-close-btn:hover {
    background: var(--rf-rose-50);
    color: var(--rf-rose-500);
}

/* Modal Body */
.rf-modal-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Prediction Path View */
.rf-path-view {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    max-width: 900px;
    margin: 0 auto;
}

/* Features Grid */
.rf-path-features {
    background: white;
    border: 1px solid var(--rf-slate-200);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
}

.rf-path-features-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--rf-slate-600);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 16px;
}

.rf-path-features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.rf-path-feature-item {
    background: var(--rf-slate-50);
    border: 1px solid var(--rf-slate-100);
    border-radius: 10px;
    padding: 12px;
}

.rf-path-feature-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--rf-slate-600);
    margin-bottom: 4px;
}

.rf-path-feature-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--rf-slate-700);
    word-break: break-all;
}

/* Decision Steps */
.rf-path-steps {
    position: relative;
}

.rf-path-steps::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 32px;
    bottom: 32px;
    width: 2px;
    background: var(--rf-slate-100);
}

.rf-path-step {
    position: relative;
    padding-left: 48px;
    margin-bottom: 20px;
}

.rf-path-step-badge {
    position: absolute;
    left: 0;
    top: 0;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 800;
    color: white;
    z-index: 10;
    box-shadow: 0 0 0 4px white;
}

.rf-path-step-badge.decision { background: var(--rf-slate-600); }
.rf-path-step-badge.leaf-Approved { background: var(--rf-emerald-500); }
.rf-path-step-badge.leaf-Rejected { background: var(--rf-rose-500); }
.rf-path-step-badge.leaf-Kama { background: var(--rf-blue-500); }
.rf-path-step-badge.leaf-Rosa { background: var(--rf-amber-500); }
.rf-path-step-badge.leaf-Canadian { background: var(--rf-indigo-500); }

.rf-path-step-content {
    background: white;
    border: 1px solid var(--rf-slate-200);
    border-radius: 16px;
    padding: 20px;
    transition: box-shadow 0.2s;
}

.rf-path-step-content:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.rf-path-step-content.leaf {
    border-style: dashed;
    background: var(--rf-slate-50);
}

.rf-path-step-type {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--rf-slate-600);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.rf-path-step-condition {
    font-size: 1rem;
    color: var(--rf-slate-600);
    margin-bottom: 12px;
}

.rf-path-step-condition b {
    color: var(--rf-slate-800);
}

.rf-path-step-result {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.875rem;
    font-weight: 700;
}

.rf-path-step-result.left { color: var(--rf-emerald-600); }
.rf-path-step-result.right { color: #dc2626; }

.rf-path-step-leaf-result {
    display: flex;
    align-items: center;
    gap: 12px;
}

.rf-path-step-leaf-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rf-path-step-leaf-icon.class-Approved { background: var(--rf-emerald-50); color: var(--rf-emerald-500); }
.rf-path-step-leaf-icon.class-Rejected { background: var(--rf-rose-50); color: var(--rf-rose-500); }
.rf-path-step-leaf-icon.class-Kama { background: var(--rf-blue-50); color: var(--rf-blue-500); }
.rf-path-step-leaf-icon.class-Rosa { background: var(--rf-amber-50); color: var(--rf-amber-500); }
.rf-path-step-leaf-icon.class-Canadian { background: var(--rf-indigo-50); color: var(--rf-indigo-500); }

.rf-path-step-leaf-class {
    font-size: 1.25rem;
    font-weight: 800;
}

.rf-path-step-leaf-class.class-Approved { color: var(--rf-emerald-500); }
.rf-path-step-leaf-class.class-Rejected { color: var(--rf-rose-500); }
.rf-path-step-leaf-class.class-Kama { color: var(--rf-blue-500); }
.rf-path-step-leaf-class.class-Rosa { color: var(--rf-amber-500); }
.rf-path-step-leaf-class.class-Canadian { color: var(--rf-indigo-500); }

.rf-path-step-leaf-meta {
    font-size: 0.8rem;
    color: var(--rf-slate-500);
    margin-top: 4px;
}

/* Visual Tree View */
.rf-visual-tree-view {
    flex: 1;
    display: none;
    position: relative;
    background: radial-gradient(var(--rf-slate-200) 1px, transparent 1px);
    background-size: 20px 20px;
    cursor: grab;
    overflow: hidden;
}

.rf-visual-tree-view.active {
    display: block;
}

.rf-visual-tree-view:active {
    cursor: grabbing;
}

.rf-visual-tree-controls {
    position: absolute;
    top: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
}

.rf-visual-tree-control-btn {
    width: 40px;
    height: 40px;
    background: white;
    border: 1px solid var(--rf-slate-200);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--rf-slate-600);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
}

.rf-visual-tree-control-btn:hover {
    background: var(--rf-slate-50);
    border-color: var(--rf-slate-300);
}

.rf-visual-tree-canvas {
    width: 100%;
    height: 100%;
    transform-origin: 0 0;
    transition: transform 0.1s ease-out;
}

/* SVG Nodes and Edges */
.rf-tree-node {
    cursor: pointer;
    transition: all 0.3s;
}

.rf-tree-node-circle {
    transition: fill 0.2s ease, stroke 0.2s ease, stroke-width 0.2s ease;
}

.rf-tree-node-circle.active {
    stroke: var(--rf-blue-500);
    stroke-width: 3;
}

.rf-tree-edge {
    fill: none;
    stroke: #475569;
    stroke-width: 2.5;
    opacity: 1;
    transition: stroke 0.2s ease, stroke-width 0.2s ease, opacity 0.2s ease, filter 0.2s ease;
}

.rf-tree-edge.bg {
    stroke: #cbd5e1;
    stroke-width: 1.5;
    opacity: 0.6;
}

.rf-tree-edge.active {
    stroke: #2563eb;
    stroke-width: 4;
    opacity: 1;
    filter: drop-shadow(0 0 6px rgba(37, 99, 235, 0.6));
}

.rf-tree-edge.rejected {
    stroke: #dc2626;
    stroke-width: 3;
    opacity: 1;
    filter: drop-shadow(0 0 4px rgba(220, 38, 38, 0.45));
}

/* === Guidance Banner === */
.rf-guidance-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.4;
    animation: rf-guidance-fade 0.4s ease;
    margin-bottom: 4px;
}

@keyframes rf-guidance-fade {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.rf-guidance-banner.phase-waiting {
    background: linear-gradient(135deg, #eff6ff, #e0f2fe);
    border: 1.5px solid #93c5fd;
    color: #1e40af;
}

.rf-guidance-banner.phase-ready {
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    border: 1.5px solid #6ee7b7;
    color: #065f46;
}

.rf-guidance-banner.phase-running {
    background: linear-gradient(135deg, #fefce8, #fef3c7);
    border: 1.5px solid #fcd34d;
    color: #92400e;
}

.rf-guidance-banner.phase-done {
    background: linear-gradient(135deg, #f5f3ff, #ede9fe);
    border: 1.5px solid #a78bfa;
    color: #5b21b6;
}

.rf-guidance-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rf-guidance-text {
    flex: 1;
}

.rf-guidance-text strong {
    display: block;
    font-size: 1rem;
    margin-bottom: 2px;
}

.rf-guidance-text span {
    font-size: 0.875rem;
    opacity: 0.9;
    font-weight: 500;
}

/* Pulse animation for interactive hints */
@keyframes rf-pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5); }
    70% { box-shadow: 0 0 0 8px rgba(59, 130, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

.rf-pulse-hint {
    animation: rf-pulse-ring 1.5s ease infinite;
}

/* Criterion Badge in Sidebar */
.rf-criterion-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f5f3ff, #ede9fe);
    border: 1.5px solid var(--rf-indigo-500);
    border-radius: 12px;
    margin-bottom: 16px;
}

.rf-criterion-badge-icon {
    width: 32px;
    height: 32px;
    background: var(--rf-indigo-500);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-size: 0.85rem;
}

.rf-criterion-badge-text {
    flex: 1;
}

.rf-criterion-badge-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--rf-slate-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.rf-criterion-badge-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--rf-indigo-600);
}

/* === Loading Spinner === */
@keyframes rf-spin {
    to { transform: rotate(360deg); }
}

.rf-spinner {
    animation: rf-spin 1s linear infinite;
}

/* === Utilities === */
.rf-hidden {
    display: none !important;
}

/* === Node Popup (for Visual Tree view) === */
.rf-node-popup {
    position: absolute;
    z-index: 1000;
    display: none;
    pointer-events: none;
    max-width: min(320px, calc(100% - 24px));
}

.rf-popup-content {
    background: var(--rf-slate-800);
    color: white;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 0.85rem;
    min-width: 140px;
    width: max-content;
    max-width: 100%;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.rf-popup-arrow {
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid var(--rf-slate-800);
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
}

.rf-node-popup.rf-popup-above .rf-popup-arrow {
    top: auto;
    bottom: -8px;
    border-bottom: none;
    border-top: 8px solid var(--rf-slate-800);
}

.rf-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--rf-slate-600);
    padding-bottom: 8px;
    margin-bottom: 8px;
}

.rf-popup-node-id {
    font-weight: 700;
}

.rf-popup-samples {
    color: var(--rf-slate-400);
    font-size: 0.8rem;
}

.rf-popup-feature {
    color: var(--rf-blue-300);
    font-weight: 600;
    text-align: center;
    margin-bottom: 4px;
    line-height: 1.35;
}

.rf-popup-threshold {
    font-size: 1.125rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 6px;
}

.rf-popup-class {
    font-size: 1rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 6px;
}

.rf-popup-impurity {
    font-size: 0.8rem;
    color: var(--rf-slate-400);
    text-align: center;
}

/* Visual node hover effect */
.rf-visual-node {
    cursor: pointer;
}

.rf-visual-node:hover .rf-node-circle {
    stroke-width: 4;
    filter: drop-shadow(0 0 6px rgba(59, 130, 246, 0.5));
}

/* Visual Tree Color Legend */
.rf-visual-tree-legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: white;
    border: 1px solid var(--rf-slate-200);
    border-radius: 12px;
    padding: 14px 18px;
    font-size: 0.8rem;
    color: var(--rf-slate-700);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    z-index: 100;
    line-height: 1.5;
}

.rf-legend-title {
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 8px;
    color: var(--rf-slate-800);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rf-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    font-size: 0.8rem;
}

.rf-legend-line {
    width: 24px;
    height: 3px;
    border-radius: 2px;
    flex-shrink: 0;
}

.rf-legend-line.rf-legend-dashed {
    background: transparent !important;
    border-top: 3px dashed #dc2626;
    height: 0;
}

/* Prediction Path Guide Banner */
.rf-path-guide {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    background: linear-gradient(135deg, #eff6ff, #e0f2fe);
    border: 1.5px solid #93c5fd;
    border-radius: 12px;
    margin-bottom: 20px;
    color: #1e40af;
    font-size: 0.85rem;
    line-height: 1.5;
}

.rf-path-guide svg {
    flex-shrink: 0;
    margin-top: 2px;
}

.rf-path-guide strong {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.rf-path-guide span {
    font-size: 0.8rem;
    font-weight: 500;
    opacity: 0.9;
}

/* ==========================================
   CONTROLS BAR: Speed, n_estimators, Pagination
   ========================================== */
.rf-controls-bar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 10px 16px;
    background: var(--rf-slate-50, #f8fafc);
    border: 1px solid var(--rf-slate-200, #e2e8f0);
    border-radius: 12px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.rf-control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rf-control-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--rf-slate-700, #334155);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

/* Speed Buttons */
.rf-speed-btns {
    display: flex;
    gap: 4px;
}

.rf-speed-btn {
    padding: 4px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid var(--rf-slate-200, #e2e8f0);
    border-radius: 6px;
    background: white;
    color: var(--rf-slate-600, #475569);
    cursor: pointer;
    transition: all 0.15s;
}

.rf-speed-btn:hover {
    border-color: var(--rf-blue-400, #60a5fa);
    color: var(--rf-blue-600, #2563eb);
}

.rf-speed-btn.active {
    background: var(--rf-blue-600, #2563eb);
    color: white;
    border-color: var(--rf-blue-600, #2563eb);
}

/* n_estimators Slider */
.rf-nestimators-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rf-nestimators-slider {
    width: 120px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--rf-slate-200, #e2e8f0);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}

.rf-nestimators-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--rf-blue-600, #2563eb);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.rf-nestimators-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--rf-blue-600, #2563eb);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.rf-nestimators-value {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--rf-blue-600, #2563eb);
    min-width: 32px;
    text-align: center;
}

/* Pagination Buttons */
.rf-pagination-btns {
    display: flex;
    gap: 4px;
}

.rf-page-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--rf-slate-200, #e2e8f0);
    border-radius: 6px;
    background: white;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--rf-slate-600, #475569);
}

.rf-page-btn:hover:not(:disabled) {
    border-color: var(--rf-blue-400, #60a5fa);
    color: var(--rf-blue-600, #2563eb);
    background: var(--rf-blue-50, #eff6ff);
}

.rf-page-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* Vote Percentage Display */
.rf-vote-pct {
    font-size: 0.8rem;
    color: var(--rf-slate-500, #64748b);
    font-weight: 500;
}

/* ======================================== */
/* GUIDANCE HINTS - Throughout Animation    */
/* ======================================== */

/* Sample list inline hint */
.rf-sample-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--rf-slate-500, #64748b);
    padding: 6px 10px;
    margin-bottom: 6px;
    background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
    border-radius: 8px;
    border: 1px dashed var(--rf-blue-300, #93c5fd);
    letter-spacing: 0.01em;
    animation: rf-hint-breathe 3s ease-in-out infinite;
}
.rf-sample-hint svg {
    flex-shrink: 0;
    color: var(--rf-blue-500, #3b82f6);
}

@keyframes rf-hint-breathe {
    0%, 100% { opacity: 0.85; }
    50% { opacity: 1; }
}

/* Aggregation panel explanation hint */
.rf-aggregation-hint {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--rf-slate-600, #475569);
    padding: 8px 12px;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #faf5ff 0%, #eff6ff 100%);
    border-radius: 8px;
    border: 1px solid #e9d5ff;
    line-height: 1.45;
}
.rf-aggregation-hint svg {
    flex-shrink: 0;
    margin-top: 1px;
    color: var(--rf-indigo-500, #6366f1);
}
.rf-aggregation-hint b {
    color: var(--rf-indigo-600, #4f46e5);
}

/* Visual tree interaction hint overlay (pan/zoom/click) */
.rf-tree-interaction-hint {
    position: absolute;
    top: 14px;
    right: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 15;
    background: rgba(15, 23, 42, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    transition: opacity 0.8s ease, transform 0.8s ease;
    pointer-events: none;
}
.rf-tree-interaction-hint.fade-out {
    opacity: 0;
    transform: translateY(-8px);
}

.rf-interaction-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    white-space: nowrap;
}
.rf-interaction-row svg {
    flex-shrink: 0;
    color: #93c5fd;
}

/* Tree card clickable hover effect enhancement */
.rf-tree-card {
    position: relative;
}
.rf-tree-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 2px solid transparent;
    transition: border-color 0.2s ease;
    pointer-events: none;
}
.rf-tree-card:hover::after {
    border-color: var(--rf-blue-400, #60a5fa);
}
.rf-tree-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}
