/* 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, #667eea 0%, #764ba2 100%);
    color: #333;
    overflow-x: hidden;
}

/* Container setup for iframe compatibility */
.container {
    width: 100%;
    height: 450px; /* Default iframe height */
    padding: 8px;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

/* Responsive height for full browser */
@media (min-height: 600px) {
    .container {
        height: 90vh;
    }
}

/* Control panel styling */
.control-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

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

.control-group label {
    font-weight: 600;
    color: #555;
    font-size: 14px;
}

/* Button styling optimized for iframe */
.button-group {
    display: flex;
    gap: 4px;
}

.graph-btn, .control-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    background: linear-gradient(145deg, #f0f0f0, #e0e0e0);
    color: #333;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    min-height: 32px;
}

.graph-btn:hover, .control-btn:hover {
    background: linear-gradient(145deg, #e0e0e0, #d0d0d0);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.graph-btn.active {
    background: linear-gradient(145deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.animation-controls {
    display: flex;
    gap: 4px;
}

/* Main content layout */
.main-content {
    display: flex;
    gap: 12px;
    flex: 1;
    min-height: 0;
}

.graph-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 6px;
    padding: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    position: relative;
}

.panel-title {
    font-size: 14px;
    font-weight: 600;
    color: #555;
    text-align: center;
    margin-bottom: 8px;
    cursor: help;
}

/* Graph container and canvas */
.graph-container {
    position: relative;
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fafafa;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}

canvas {
    border-radius: 4px;
    cursor: crosshair;
    max-width: 100%;
    max-height: 100%;
}

/* Axis labels */
.axis-labels {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.y-label {
    position: absolute;
    left: -2px;
    top: 50%;
    transform: rotate(-90deg) translateY(-50%);
    transform-origin: center;
    font-size: 11px;
    color: #666;
    font-weight: 500;
}

.x-label {
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    color: #666;
    font-weight: 500;
}

/* Object animation track */
.object-track {
    position: relative;
    height: 30px;
    margin: 8px 0;
    background: #f0f0f0;
    border-radius: 15px;
    overflow: hidden;
}

.track-line {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: #ccc;
    transform: translateY(-50%);
}

.moving-object {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    font-size: 20px;
    transition: left 0.1s linear;
    cursor: pointer;
}

/* Information display */
.info-display {
    display: flex;
    justify-content: space-around;
    margin-top: 8px;
    padding: 6px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 4px;
}

.info-item {
    font-size: 11px;
    font-weight: 500;
    color: #555;
    cursor: help;
}

.info-item span {
    color: #667eea;
    font-weight: 600;
}

/* Concepts panel */
.concepts-panel {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 8px;
    padding: 6px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 4px;
}

.concept-item {
    font-size: 11px;
    color: #666;
    cursor: help;
    padding: 4px 8px;
    border-radius: 3px;
    background: rgba(102, 126, 234, 0.1);
    transition: background 0.2s ease;
}

.concept-item:hover {
    background: rgba(102, 126, 234, 0.2);
}

/* Tooltip styling */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    max-width: 200px;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.tooltip.show {
    opacity: 1;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }
    
    .control-panel {
        flex-direction: column;
        gap: 8px;
    }
    
    .button-group, .animation-controls {
        flex-wrap: wrap;
    }
    
    .graph-btn, .control-btn {
        font-size: 11px;
        padding: 5px 10px;
        min-height: 28px;
    }
    
    .info-display {
        flex-direction: column;
        gap: 4px;
    }
    
    .concepts-panel {
        flex-direction: column;
        gap: 4px;
    }
}

/* Touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {
    .graph-btn, .control-btn {
        min-height: 36px;
        padding: 8px 12px;
    }
    
    .moving-object {
        font-size: 24px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .container {
        background: white;
        border: 2px solid #000;
    }
    
    .graph-btn, .control-btn {
        border: 1px solid #000;
    }
    
    .graph-btn.active {
        background: #000;
        color: white;
    }
}