/* 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 */
    max-height: 90vh; /* For standalone browser */
    padding: 10px;
    display: grid;
    grid-template-columns: 1fr 2fr;
    grid-template-rows: 1fr auto;
    gap: 10px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Control Panel Styles */
.control-panel {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.fraction-inputs {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.fraction-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.fraction-group label {
    font-weight: 600;
    font-size: 12px;
    color: #495057;
}

.fraction-input {
    display: flex;
    align-items: center;
    gap: 5px;
    justify-content: center;
}

.fraction-input input {
    width: 50px;
    height: 35px;
    text-align: center;
    border: 2px solid #dee2e6;
    border-radius: 4px;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.fraction-input input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

.fraction-line {
    width: 30px;
    height: 2px;
    background: #333;
    margin: 0 5px;
}

.operation-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: center;
}

.operation-group select {
    width: 100%;
    height: 35px;
    border: 2px solid #dee2e6;
    border-radius: 4px;
    font-size: 14px;
    padding: 5px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.operation-group select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

/* Button Styles */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.primary-btn, .secondary-btn {
    padding: 10px 15px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    min-height: 40px;
}

.primary-btn {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.4);
}

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

.secondary-btn:hover {
    background: #545b62;
    transform: translateY(-1px);
}

/* Toggle Switch */
.toggle-group {
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.toggle-label input {
    display: none;
}

.toggle-slider {
    width: 40px;
    height: 20px;
    background: #ccc;
    border-radius: 20px;
    position: relative;
    transition: all 0.3s ease;
}

.toggle-slider::after {
    content: '';
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: all 0.3s ease;
}

.toggle-label input:checked + .toggle-slider {
    background: #007bff;
}

.toggle-label input:checked + .toggle-slider::after {
    transform: translateX(20px);
}

/* Display Area */
.display-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.fraction-visual {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    flex: 1;
}

.visual-title {
    font-size: 14px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 10px;
    text-align: center;
}

.fraction-circles {
    display: flex;
    align-items: center;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 10px;
}

.circle-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.circle-label {
    font-size: 10px;
    font-weight: 600;
    color: #6c757d;
}

.fraction-display {
    font-size: 14px;
    font-weight: bold;
    color: #007bff;
    background: #e3f2fd;
    padding: 4px 8px;
    border-radius: 4px;
}

.operation-symbol, .equals-symbol {
    font-size: 24px;
    font-weight: bold;
    color: #007bff;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Steps Container */
.steps-container {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.steps-title {
    font-size: 14px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 10px;
    text-align: center;
}

.steps-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.step {
    padding: 8px 12px;
    background: #f8f9fa;
    border-left: 4px solid #007bff;
    border-radius: 4px;
    font-size: 12px;
    transition: all 0.3s ease;
}

.step:hover {
    background: #e3f2fd;
    transform: translateX(5px);
}

/* Analytics Panel */
.analytics-panel {
    grid-column: 1 / -1;
    background: #2c3e50;
    color: white;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

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

.analytics-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    font-size: 11px;
}

.stat-label {
    font-weight: 600;
}

.stat-value {
    color: #3498db;
    font-weight: bold;
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1000;
    max-width: 200px;
    text-align: center;
}

.tooltip.show {
    opacity: 1;
}

/* Canvas styling */
canvas {
    border: 2px solid #dee2e6;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

canvas:hover {
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        height: auto;
        min-height: 450px;
    }
    
    .fraction-circles {
        flex-direction: column;
        gap: 15px;
    }
    
    .analytics-content {
        grid-template-columns: 1fr;
    }
}

/* Animation classes */
.highlight {
    animation: highlight 0.6s ease-in-out;
}

@keyframes highlight {
    0% { background-color: transparent; }
    50% { background-color: #fff3cd; }
    100% { background-color: transparent; }
}

.pulse {
    animation: pulse 1s infinite;
}

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