:root {
    --primary-red: #e63946;
    --primary-blue: #457b9d;
    --primary-yellow: #fca311; /* Plasma/Anti-B */
    --bg-color: #f8f9fa;
    --text-color: #212529;
    --panel-bg: #ffffff;
    --border-color: #dee2e6;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --radius-md: 12px;
    --radius-lg: 16px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    height: 100vh;
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: 1200px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.app-header {
    text-align: center;
    margin-bottom: 20px;
}

.app-header h1 {
    font-weight: 700;
    color: var(--primary-red);
}

.subtitle {
    color: #6c757d;
    font-size: 0.9rem;
}

/* Navigation Tabs */
.tab-nav {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    background: var(--panel-bg);
    padding: 10px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.tab-btn {
    background: none;
    border: none;
    padding: 10px 20px;
    font-family: inherit;
    font-weight: 600;
    color: #6c757d;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    background-color: #f1f3f5;
    color: var(--text-color);
}

.tab-btn.active {
    background-color: var(--primary-red);
    color: white;
}

/* Tab Content */
.tab-content {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--panel-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 20px;
}

.tab-pane {
    display: none;
    height: 100%;
    animation: fadeIn 0.3s ease;
}

.tab-pane.active {
    display: block;
}

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

/* Tab 1: RBC View */
.panel-container {
    display: flex;
    height: 100%;
    gap: 20px;
}

.controls {
    width: 250px;
    border-right: 1px solid var(--border-color);
    padding-right: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.type-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.type-btn {
    padding: 15px;
    border: 2px solid var(--border-color);
    background: white;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.type-btn.active {
    border-color: var(--primary-red);
    background-color: #fff5f5;
    color: var(--primary-red);
}

.visualization-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #f8f9fa;
    border-radius: var(--radius-md);
    position: relative;
}

/* Tab 2: Blood Typing Game */
.lab-bench {
    display: flex;
    flex-direction: column;
    height: 100%;
    align-items: center;
    gap: 30px;
}

.slide-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.microscope-slide {
    width: 400px;
    height: 150px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ccc;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-radius: 4px;
}

.well {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: #f0f0f0;
    border: 1px solid #ddd;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.well .label {
    position: absolute;
    top: -25px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #666;
}

.tools {
    display: flex;
    gap: 20px;
}

.tool {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: grab;
}

.dropper-icon {
    width: 40px;
    height: 80px;
    background: #ccc; /* Placeholder */
    margin-bottom: 5px;
    border-radius: 4px;
}

.dropper-icon.anti-a { background: var(--primary-blue); }
.dropper-icon.anti-b { background: var(--primary-yellow); }

.result-panel {
    width: 100%;
    text-align: center;
    padding: 20px;
    background: #f1f3f5;
    border-radius: var(--radius-md);
}

.options {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

.guess-btn {
    padding: 10px 20px;
    border: none;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.guess-btn:hover {
    transform: translateY(-2px);
}

/* Tab 3: Transfusion */
.hospital-room {
    display: flex;
    height: 100%;
    gap: 20px;
}

.patient-card {
    width: 250px;
    background: white;
    padding: 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.blood-bank {
    flex: 1;
    background: #fff5f5;
    border-radius: var(--radius-md);
    padding: 20px;
}

.blood-bags {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 15px;
}

.blood-bag {
    width: 60px;
    height: 80px;
    background: var(--primary-red);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px 8px 12px 12px;
    font-weight: 700;
    cursor: grab;
    box-shadow: var(--shadow-sm);
}

.transfusion-area {
    width: 300px;
    background: #e9ecef;
    border-radius: var(--radius-md);
    display: flex;
    justify-content: center;
    align-items: center;
}

.iv-stand {
    width: 10px;
    height: 80%;
    background: #adb5bd;
    position: relative;
}

.hook {
    position: absolute;
    top: 20px;
    left: -45px;
    width: 100px;
    height: 100px;
    border: 2px dashed #999;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-size: 0.8rem;
    color: #666;
}

.action-btn {
    background: var(--primary-red);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}

.action-btn:hover {
    background: #c92a2a;
}

/* Animation for floating antibodies */
@keyframes float {
    0% { transform: translate(0, 0) rotate(0deg); }
    50% { transform: translate(5px, 5px) rotate(5deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

.floating {
    animation: float 3s ease-in-out infinite;
    transform-origin: center;
}


/* Blood Typing Game Styles */
.liquid {
    width: 80px;
    height: 80px;
    background: radial-gradient(circle at 30% 30%, #ff4d4d, #cc0000);
    border-radius: 50%;
    transition: all 0.5s ease;
    opacity: 0.9;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.2);
}

.liquid.agglutinated {
    background-color: #ffcccc;
    background-image: 
        radial-gradient(#8a0000 20%, transparent 20%),
        radial-gradient(#660000 20%, transparent 20%);
    background-size: 12px 12px, 15px 15px;
    background-position: 0 0, 6px 6px;
    animation: clump 0.5s ease-in-out;
}

@keyframes clump {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

.well.drag-over {
    border-color: var(--primary-blue);
    background-color: #e7f5ff;
}

.feedback {
    margin-top: 15px;
    font-weight: 600;
    min-height: 24px;
}

.feedback.success { color: #2b8a3e; }
.feedback.error { color: #c92a2a; }


/* Transfusion Sim Styles */
.hidden {
    filter: blur(5px);
    user-select: none;
}

.patient-blood-type {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-red);
    transition: all 0.5s;
}

.patient-blood-type.revealed {
    filter: none;
}

.feedback-overlay {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.feedback-overlay.show {
    opacity: 1;
}

.feedback-overlay.success {
    background-color: #d3f9d8;
    color: #2b8a3e;
    border: 1px solid #b2f2bb;
}

.feedback-overlay.error {
    background-color: #ffe3e3;
    color: #c92a2a;
    border: 1px solid #ffc9c9;
}

.transfusion-area.drag-over {
    background-color: #e7f5ff;
    border: 2px dashed var(--primary-blue);
}


/* Final Polish */
body {
    background-image: radial-gradient(#dee2e6 1px, transparent 1px);
    background-size: 20px 20px;
}

.tab-content {
    min-height: 500px;
    display: flex;
    flex-direction: column;
}

.tab-pane {
    flex: 1;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .panel-container {
        flex-direction: column;
    }
    .controls {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding-bottom: 20px;
    }
    .hospital-room {
        flex-direction: column;
    }
    .patient-card {
        width: 100%;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}


/* Feedback Improvements */
.result-panel {
    order: -1; /* Move to top */
    margin-bottom: 20px;
    border: 2px solid var(--border-color);
    background: #fff;
}

.feedback {
    font-size: 1.2rem;
    padding: 10px;
    border-radius: 8px;
    transition: all 0.3s;
}

.feedback.success {
    background-color: #d3f9d8;
    border: 1px solid #b2f2bb;
}

.feedback.error {
    background-color: #ffe3e3;
    border: 1px solid #ffc9c9;
}

/* Mini Lab for Transfusion */
.mini-lab {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mini-slide {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.mini-well {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid #ccc;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.mini-well .label {
    position: absolute;
    top: -20px;
    font-size: 0.7rem;
    color: #666;
}

.mini-well .liquid {
    width: 40px;
    height: 40px;
}

.patient-sample {
    width: 40px;
    height: 60px;
    background: var(--primary-red);
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 0.8rem;
    cursor: grab;
    margin: 0 auto;
}


/* Debugging Fixes */
.mini-well {
    z-index: 10; /* Ensure it's on top */
}

.patient-sample, .tool.dropper, .blood-bag {
    cursor: grab;
    z-index: 20; /* Draggables on top */
}

.patient-sample:active, .tool.dropper:active, .blood-bag:active {
    cursor: grabbing;
}


/* Fix Drag and Drop Targets */
.well *, .mini-well *, .iv-stand * {
    pointer-events: none; /* Ensure drag events trigger on the container */
}

/* Ensure Mini Lab is visible */
.mini-lab {
    scroll-margin-top: 20px;
}

