/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #e8f5e8 0%, #f0f8f0 100%);
    overflow-x: hidden;
}

/* Main container - responsive height based on environment */
.main-container {
    width: 100%;
    height: 450px; /* Default iframe height */
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
}

/* Full screen mode detection */
@media screen and (min-height: 600px) {
    .main-container {
        height: 90vh;
        padding: 15px;
        gap: 12px;
    }
}

/* Tooltip for header information */
.tooltip {
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
    max-width: 300px;
    text-align: center;
}

.main-container:hover .tooltip {
    opacity: 1;
}

/* Progress bar */
.progress-container {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: var(--progress, 0%);
    background: linear-gradient(90deg, #4CAF50, #66BB6A);
    transition: width 0.5s ease;
}

.progress-text {
    font-size: 12px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

/* Control panel */
.control-panel {
    display: flex;
    gap: 15px;
    background: white;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    align-items: center;
    flex-wrap: wrap;
}

.organism-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 200px;
}

.organism-selector label {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

.organism-selector select {
    flex: 1;
    padding: 6px 10px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.organism-selector select:focus {
    outline: none;
    border-color: #4CAF50;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 200px;
}

.slider-container label {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

.slider {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Food web visualization */
.food-web-container {
    flex: 1;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 10px;
    overflow: hidden;
}

#foodWebSvg {
    width: 100%;
    height: 100%;
    min-height: 200px;
}

/* Make nodes draggable on touch devices without scrolling the page */
.organism {
    touch-action: none;
    user-select: none;
}

/* Organism styling */
.organism-circle {
    stroke-width: 3;
    transition: stroke-width 0.2s ease, filter 0.2s ease;
    cursor: pointer;
}

.organism-circle.producer {
    fill: #8BC34A;
    stroke: #689F38;
}

.organism-circle.primary {
    fill: #FFC107;
    stroke: #F57F17;
}

.organism-circle.secondary {
    fill: #FF9800;
    stroke: #E65100;
}

.organism-circle.tertiary {
    fill: #F44336;
    stroke: #C62828;
.organism-circle:hover {
    stroke-width: 4;
    filter: brightness(1.1);
}
}

.organism-circle.selected {
    stroke-width: 5;
    stroke: #2196F3;
    filter: drop-shadow(0 0 8px rgba(33, 150, 243, 0.5));
}

/* Disable visual transitions while dragging to prevent "slip-away" feel and keep arrows aligned */
.organism.dragging .organism-circle {
    transition: none !important;
    filter: none !important;
}

/* Show grabbing cursor while dragging */
.organism.dragging {
    cursor: grabbing;
}

/* Disable visual transitions while dragging to prevent "slip-away" feel and keep arrows aligned */
.organism.dragging .organism-circle {
    transition: none !important;
    filter: none !important;
}

/* Show grabbing cursor while dragging */
.organism.dragging {
    cursor: grabbing;
}

.organism-text {
    font-size: 20px;
    pointer-events: none;
    user-select: none;
}

.organism-label {
    font-size: 11px;
    font-weight: 600;
    fill: #333;
    pointer-events: none;
    user-select: none;
}

.population-count {
    font-size: 10px;
    font-weight: bold;
    fill: #666;
    pointer-events: none;
    user-select: none;
}

/* Food web arrows */
.food-arrow {
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.food-arrow:hover {
    opacity: 1;
    stroke-width: 3;
}

/* Feedback container */
.feedback-container {
    background: white;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.feedback-message {
    min-height: 20px;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 500;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.feedback-message.success {
    background: #E8F5E8;
    color: #2E7D32;
    border: 1px solid #4CAF50;
}

.feedback-message.error {
    background: #FFEBEE;
    color: #C62828;
    border: 1px solid #F44336;
}

.feedback-message.info {
    background: #E3F2FD;
    color: #1565C0;
    border: 1px solid #2196F3;
}

/* Button container */
.button-container {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.action-button {
    flex: 1;
    min-width: 120px;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    white-space: nowrap;
}

.primary-btn {
    background: #2196F3;
    color: white;
}

.primary-btn:hover {
    background: #1976D2;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(33, 150, 243, 0.3);
}

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

.secondary-btn:hover {
    background: #616161;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(117, 117, 117, 0.3);
}

.success-btn {
    background: #4CAF50;
    color: white;
}

.success-btn:hover {
    background: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.3);
}

.action-button:active {
    transform: translateY(0);
}

/* Observation log */
.observation-log {
    background: white;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    max-height: 120px;
    overflow-y: auto;
}

.observation-log h4 {
    font-size: 13px;
    color: #333;
    margin-bottom: 8px;
}

.observation-log ul {
    list-style: none;
    font-size: 12px;
}

.observation-log li {
    padding: 4px 0;
    border-bottom: 1px solid #eee;
    color: #666;
}

.observation-log li:last-child {
    border-bottom: none;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .control-panel {
        flex-direction: column;
        gap: 10px;
    }
    
    .organism-selector,
    .slider-container {
        width: 100%;
        min-width: auto;
    }
    
    .button-container {
        flex-direction: column;
    }
    
    .action-button {
        min-width: auto;
    }
    
    .organism-text {
        font-size: 16px;
    }
    
    .organism-label {
        font-size: 10px;
    }
    
    .population-count {
        font-size: 9px;
    }
}

/* Touch-friendly interactions */
@media (pointer: coarse) {
    .organism-circle {
        stroke-width: 4;
    }
    
    .slider::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }
    
    .action-button {
        padding: 12px 16px;
        min-height: 44px;
    }
}
