/* Global styles and reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

/* Main container - adapts to iframe or standalone */
.container {
    width: 100%;
    min-height: 450px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 20px 0;
}

/* Adjust height for standalone browser tab */
@media (min-width: 768px) and (min-height: 600px) {
    body:not(.iframe) .container {
        min-height: 90vh;
    }
}

/* Tooltip for header information - appears on hover */
.tooltip {
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
    white-space: nowrap;
}

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

/* Main content area */
.content {
    width: 95%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

/* Modified: New container for side-by-side layout of temperature panel and strip */
.main-display-area {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 100%;
    max-width: 800px;
    justify-content: center;
}

/* Modified: Temperature display panel - now positioned to the side */
.temperature-panel {
    background: white;
    border-radius: 12px;
    padding: 12px 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    flex-shrink: 0;
}

.temperature-panel:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.temp-display {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 4px;
}

.temp-value {
    font-size: 36px;
    font-weight: bold;
    color: #1976d2;
}

.temp-unit {
    font-size: 20px;
    color: #1976d2;
}

.temp-label {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
}

/* Modified: Bimetallic strip visualization container - now flexible width */
.strip-container {
    flex: 1;
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 600px;
}

#stripSvg {
    width: 100%;
    height: auto;
}

/* MODIFIED: Brass layer styling - removed transition to allow manual animation control */
.brass-layer {
    fill: none;
    stroke: #e89b4e;
    stroke-linecap: round;
}

/* MODIFIED: Iron layer styling - removed transition to allow manual animation control */
.iron-layer {
    fill: none;
    stroke: #9e9e9e;
    stroke-linecap: round;
}

/* Modified: Metal labels - reduced font size from 14px to 11px */
.metal-label {
    font-size: 11px;
    font-weight: 500;
    fill: #333;
}

.brass-text {
    fill: #d68a3d;
}

.iron-text {
    fill: #757575;
}

/* MODIFIED: Information panel with state description - fixed height to ensure all boxes are same size */
.info-panel {
    border-radius: 10px;
    padding: 15px 20px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 90%;
    transition: all 0.3s ease;
    min-height: 80px;
}

.info-number {
    background: #ffd54f;
    color: #333;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    flex-shrink: 0;
}

.info-text {
    font-size: 14px;
    color: #333;
    line-height: 1.5;
    flex: 1;
}

/* NEW: Temperature slider control styling */
.slider-control {
    width: 90%;
    max-width: 600px;
    background: white;
    border-radius: 10px;
    padding: 15px 20px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.slider-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 14px;
    color: #333;
}

.slider-title {
    font-weight: 600;
}

.slider-value {
    font-weight: bold;
    color: #1976d2;
    font-size: 16px;
}

.temp-slider {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: linear-gradient(to right, #0288d1 0%, #ffd54f 50%, #d32f2f 100%);
    outline: none;
    -webkit-appearance: none;
    margin-bottom: 8px;
}

.temp-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 3px solid #1976d2;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.temp-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 3px 10px rgba(25, 118, 210, 0.4);
}

.temp-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 3px solid #1976d2;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.temp-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 3px 10px rgba(25, 118, 210, 0.4);
}

.slider-markers {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #666;
    padding: 0 5px;
}

/* Control buttons container */
.controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    max-width: 700px;
    padding: 0 10px;
}

/* Individual control button styling */
.control-btn {
    background: white;
    border: 2px solid #1976d2;
    border-radius: 8px;
    padding: 10px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #1976d2;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    min-height: 44px;
}

.control-btn:hover {
    background: #1976d2;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(25, 118, 210, 0.3);
}

.control-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.control-btn:disabled:hover {
    background: white;
    color: #1976d2;
    transform: none;
}

/* Specific button color variations */
.increase-btn {
    border-color: #d32f2f;
    color: #d32f2f;
}

.increase-btn:hover {
    background: #d32f2f;
    color: white;
}

.decrease-btn {
    border-color: #0288d1;
    color: #0288d1;
}

.decrease-btn:hover {
    background: #0288d1;
    color: white;
}

.reset-btn {
    border-color: #388e3c;
    color: #388e3c;
}

.reset-btn:hover {
    background: #388e3c;
    color: white;
}

.btn-icon {
    font-size: 18px;
}

.btn-text {
    font-size: 13px;
}

/* NEW: Analytics Container - Collapsible panel at bottom */
.analytics-container {
    width: 90%;
    max-width: 900px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-top: 10px;
    overflow: hidden;
}

.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%);
    color: white;
    cursor: pointer;
    user-select: none;
}

.analytics-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 16px;
}

.analytics-icon {
    font-size: 20px;
}

.toggle-analytics {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    transition: transform 0.3s ease;
}

.toggle-analytics .toggle-icon {
    display: inline-block;
    transition: transform 0.3s ease;
}

.analytics-container.collapsed .toggle-analytics .toggle-icon {
    transform: rotate(-90deg);
}

.analytics-content {
    max-height: 600px;
    overflow-y: auto;
    transition: max-height 0.3s ease, padding 0.3s ease;
    padding: 20px;
}

.analytics-container.collapsed .analytics-content {
    max-height: 0;
    padding: 0 20px;
    overflow: hidden;
}

/* Analytics Stats Cards */
.analytics-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.stat-value {
    font-size: 28px;
    font-weight: bold;
    color: #1976d2;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 12px;
    color: #666;
    font-weight: 500;
}

/* Activity Log Section */
.activity-log-section {
    margin-bottom: 20px;
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.log-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.clear-log-btn {
    background: #f44336;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
}

.clear-log-btn:hover {
    background: #d32f2f;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(244, 67, 54, 0.3);
}

.activity-log {
    background: #fafafa;
    border-radius: 8px;
    padding: 12px;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
}

.log-entry {
    padding: 8px 10px;
    margin-bottom: 6px;
    border-radius: 6px;
    font-size: 13px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.log-time {
    font-weight: 600;
    color: #666;
    min-width: 65px;
}

.log-message {
    flex: 1;
    color: #333;
}

.log-info {
    background: #e3f2fd;
    border-left: 3px solid #1976d2;
}

.log-heating {
    background: #ffebee;
    border-left: 3px solid #d32f2f;
}

.log-cooling {
    background: #e1f5fe;
    border-left: 3px solid #0288d1;
}

.log-reset {
    background: #e8f5e9;
    border-left: 3px solid #388e3c;
}

.log-slider {
    background: #fff3e0;
    border-left: 3px solid #f57c00;
}

/* Temperature Range Exploration */
.exploration-section {
    background: #f5f5f5;
    border-radius: 8px;
    padding: 15px;
}

.exploration-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
}

.temp-range-bar {
    background: #e0e0e0;
    height: 30px;
    border-radius: 15px;
    position: relative;
    overflow: hidden;
    margin-bottom: 8px;
}

.temp-range-fill {
    background: linear-gradient(to right, #0288d1, #1976d2, #d32f2f);
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 15px;
}

.temp-range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #666;
    margin-bottom: 10px;
}

.exploration-stats {
    display: flex;
    justify-content: space-around;
    font-size: 13px;
    color: #555;
}

.exploration-stats strong {
    color: #1976d2;
}

/* Modified: Responsive design for smaller screens - stack temperature panel on top */
@media (max-width: 600px) {
    .main-display-area {
        flex-direction: column;
    }
    
    .strip-container {
        width: 100%;
    }
    
    .temp-value {
        font-size: 28px;
    }
    
    .temp-unit {
        font-size: 16px;
    }
    
    .control-btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .btn-text {
        font-size: 11px;
    }
    
    .info-text {
        font-size: 13px;
    }
    
    .strip-container {
        padding: 15px;
    }

    .analytics-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-value {
        font-size: 22px;
    }

    .exploration-stats {
        flex-direction: column;
        gap: 5px;
    }
}

/* Animation for temperature changes */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.temp-display.animate {
    animation: pulse 0.5s ease;
}

/* MODIFIED: Enhanced glow animation for strip bending with more vibrant effect */
@keyframes stripBendGlow {
    0% {
        filter: drop-shadow(0 0 0px rgba(255, 152, 0, 0));
    }
    50% {
        filter: drop-shadow(0 0 12px rgba(255, 152, 0, 0.8));
    }
    100% {
        filter: drop-shadow(0 0 0px rgba(255, 152, 0, 0));
    }
}

/* MODIFIED: Enhanced class to trigger strip animation with glow effect */
.strip-container.animating #brassStrip,
.strip-container.animating #ironStrip {
    animation: stripBendGlow 1.0s ease-in-out;
}