/* 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%);
    overflow: auto; /* MODIFIED: Changed from hidden to allow scrolling for table */
}

/* Main container - adapts to iframe or full window */
.container {
    width: 100%;
    min-height: 450px; /* MODIFIED: Changed from height to min-height to accommodate table */
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: white;
    position: relative;
}

/* Adjust height for full browser tab view */
@media (min-height: 500px) and (min-width: 800px) {
    .container {
        min-height: 90vh; /* MODIFIED: Changed from height to min-height */
        padding: 20px;
        gap: 15px;
    }
}

/* Header tooltip - shows on hover over simulation area */
.header-tooltip {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    text-align: center;
    max-width: 80%;
    line-height: 1.4;
}

.simulation-area:hover ~ .header-tooltip {
    opacity: 1;
}

/* Main simulation area */
.simulation-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    background: linear-gradient(to bottom, #e3f2fd 0%, #bbdefb 100%);
    border-radius: 12px;
    padding: 20px;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.1);
    position: relative;
}

/* Glass container wrapper */
.glass-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

/* NEW: Glass cover element - sits on top of glass */
.glass-cover {
    width: 130px; /* Slightly wider than glass */
    height: 20px;
    background: linear-gradient(to bottom, 
        rgba(180, 180, 180, 0.8) 0%, 
        rgba(150, 150, 150, 0.7) 100%);
    border: 2px solid rgba(100, 100, 100, 0.6);
    border-radius: 8px 8px 0 0;
    position: relative;
    box-shadow: 
        0 2px 8px rgba(0,0,0,0.3),
        inset 0 1px 3px rgba(255,255,255,0.5);
    z-index: 10;
    margin-bottom: -5px; /* Overlap with glass slightly */
}

/* NEW: Droplets container for underside of cover */
.droplets-container.cover-underside {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100%;
    pointer-events: none;
}

/* NEW: Droplets on cover underside have different appearance */
.droplets-container.cover-underside .droplet {
    background: radial-gradient(circle at 30% 30%, 
        rgba(255, 255, 255, 0.7) 0%, 
        rgba(200, 220, 255, 0.6) 50%, 
        rgba(150, 180, 220, 0.4) 100%);
    box-shadow: 
        inset -1px -1px 2px rgba(255,255,255,0.7),
        1px 1px 3px rgba(0,0,0,0.3);
}

/* Glass visualization */
.glass {
    width: 120px;
    height: 180px;
    background: linear-gradient(to right, 
        rgba(200, 230, 255, 0.3) 0%, 
        rgba(200, 230, 255, 0.1) 50%, 
        rgba(200, 230, 255, 0.3) 100%);
    border: 3px solid rgba(100, 150, 200, 0.5);
    border-radius: 8px 8px 15px 15px;
    position: relative;
    overflow: hidden;
    box-shadow: 
        0 4px 15px rgba(0,0,0,0.2),
        inset -2px 0 8px rgba(255,255,255,0.5),
        inset 2px 0 8px rgba(0,0,0,0.1);
    transition: all 0.5s ease;
}

/* Water inside glass */
.water {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 0;
    background: linear-gradient(to bottom, 
        rgba(100, 150, 255, 0.6) 0%, 
        rgba(50, 100, 200, 0.7) 100%);
    transition: all 1s ease;
    border-radius: 0 0 12px 12px;
}

/* MODIFIED: Water animation when pouring - cold and room temp fill to 75%, hot water fills to 90% */
.water.filling {
    animation: fillWater 1s ease-out forwards;
}

/* MODIFIED: Hot water fills to higher level (90%) */
.water.hot.filling {
    animation: fillWaterHot 1s ease-out forwards;
}

@keyframes fillWater {
    from {
        height: 0;
    }
    to {
        height: 75%;
    }
}

/* NEW: Animation for hot water - fills to 90% */
@keyframes fillWaterHot {
    from {
        height: 0;
    }
    to {
        height: 90%;
    }
}

/* Cold water color */
.water.cold {
    background: linear-gradient(to bottom, 
        rgba(100, 200, 255, 0.7) 0%, 
        rgba(50, 150, 255, 0.8) 100%);
}

/* Room temperature water color */
.water.room {
    background: linear-gradient(to bottom, 
        rgba(100, 180, 255, 0.6) 0%, 
        rgba(70, 140, 220, 0.7) 100%);
}

/* Hot water color */
.water.hot {
    background: linear-gradient(to bottom, 
        rgba(255, 180, 100, 0.6) 0%, 
        rgba(255, 140, 70, 0.7) 100%);
    animation: steam 2s ease-in-out infinite;
}

/* Steam effect for hot water */
@keyframes steam {
    0%, 100% {
        filter: brightness(1);
    }
    50% {
        filter: brightness(1.2);
    }
}

/* NEW: Water level indicator - shows the top surface of hot water with steam effect */
.water-level-indicator {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(to right, 
        rgba(255, 255, 255, 0.8) 0%, 
        rgba(255, 200, 100, 0.9) 50%, 
        rgba(255, 255, 255, 0.8) 100%);
    box-shadow: 
        0 0 8px rgba(255, 200, 100, 0.8),
        0 -2px 6px rgba(255, 150, 50, 0.6);
    opacity: 0;
    transition: opacity 0.5s ease;
}

/* NEW: Show water level indicator only for hot water */
.water.hot .water-level-indicator {
    opacity: 1;
    animation: steamRise 2s ease-in-out infinite;
}

/* NEW: Animation for steam rising from water surface */
@keyframes steamRise {
    0%, 100% {
        box-shadow: 
            0 0 8px rgba(255, 200, 100, 0.8),
            0 -2px 6px rgba(255, 150, 50, 0.6);
    }
    50% {
        box-shadow: 
            0 0 12px rgba(255, 200, 100, 1),
            0 -4px 10px rgba(255, 150, 50, 0.8);
    }
}

/* NEW: Text label on water level indicator */
.level-text {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    font-weight: 700;
    color: #ff5722;
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    pointer-events: none;
}

/* Droplets container - base styles for both inside and outside */
.droplets-container {
    position: absolute;
    pointer-events: none;
}

/* Outside droplets container (for cold water) - positioned on the outer surface */
.droplets-container.outside {
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
}

/* MODIFIED: Inside droplets container (for hot water) - positioned ABOVE water level only */
.droplets-container.inside {
    top: 3px;
    left: 3px;
    right: 3px;
    bottom: 3px;
    /* Droplets will be positioned only in the upper portion above water */
}

/* Individual water droplet */
.droplet {
    position: absolute;
    background: radial-gradient(circle at 30% 30%, 
        rgba(255, 255, 255, 0.8) 0%, 
        rgba(150, 200, 255, 0.6) 50%, 
        rgba(100, 150, 200, 0.4) 100%);
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    box-shadow: 
        inset -1px -1px 2px rgba(255,255,255,0.8),
        1px 1px 3px rgba(0,0,0,0.3);
    animation: dropletForm 0.5s ease-out;
}

/* Inside droplets have slightly different appearance */
.droplets-container.inside .droplet {
    background: radial-gradient(circle at 30% 30%, 
        rgba(255, 255, 255, 0.6) 0%, 
        rgba(200, 220, 255, 0.5) 50%, 
        rgba(150, 180, 220, 0.3) 100%);
    box-shadow: 
        inset -1px -1px 1px rgba(255,255,255,0.6),
        1px 1px 2px rgba(0,0,0,0.2);
}

@keyframes dropletForm {
    from {
        transform: rotate(-45deg) scale(0);
        opacity: 0;
    }
    to {
        transform: rotate(-45deg) scale(1);
        opacity: 1;
    }
}

/* Temperature label */
.temp-label {
    font-size: 13px;
    font-weight: 600;
    color: #1976d2;
    background: white;
    padding: 5px 12px;
    border-radius: 20px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

/* Information panel */
.info-panel {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    min-width: 200px;
}

/* Individual info box */
.info-box {
    background: white;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.info-box:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transform: translateY(-2px);
}

/* Highlighted info boxes */
.info-box.highlight {
    background: linear-gradient(135deg, #fff9e6 0%, #fff3cc 100%);
    border: 2px solid #ffd54f;
}

.info-label {
    font-size: 12px;
    color: #666;
    margin-bottom: 5px;
    font-weight: 500;
}

.info-value {
    font-size: 20px;
    font-weight: 700;
    color: #1976d2;
}

.info-box.highlight .info-value {
    color: #f57c00;
}

/* Control buttons container */
.controls {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* Control button base styles */
.control-btn {
    flex: 1;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 8px rgba(0,0,0,0.2);
    color: white;
    white-space: nowrap;
    min-height: 45px;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

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

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

/* Cold water button */
.control-btn.cold {
    background: linear-gradient(135deg, #00bcd4 0%, #0097a7 100%);
}

.control-btn.cold:hover {
    background: linear-gradient(135deg, #00acc1 0%, #00838f 100%);
}

/* Room temperature button */
.control-btn.room {
    background: linear-gradient(135deg, #4caf50 0%, #388e3c 100%);
}

.control-btn.room:hover {
    background: linear-gradient(135deg, #43a047 0%, #2e7d32 100%);
}

/* Hot water button */
.control-btn.hot {
    background: linear-gradient(135deg, #ff5722 0%, #d84315 100%);
}

.control-btn.hot:hover {
    background: linear-gradient(135deg, #f4511e 0%, #bf360c 100%);
}

/* Reset button container */
.reset-container {
    display: flex;
    justify-content: center;
}

.reset-btn {
    padding: 10px 30px;
    font-size: 13px;
    font-weight: 600;
    background: linear-gradient(135deg, #9e9e9e 0%, #616161 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.reset-btn:hover {
    background: linear-gradient(135deg, #757575 0%, #424242 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

/* NEW: Results table styling */
.results-table-container {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-top: 10px;
}

.table-title {
    font-size: 16px;
    font-weight: 700;
    color: #1976d2;
    margin-bottom: 12px;
    text-align: center;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.results-table thead {
    background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%);
    color: white;
}

.results-table th {
    padding: 12px;
    text-align: center;
    font-weight: 600;
    border: 1px solid #0d47a1;
}

.results-table td {
    padding: 10px;
    text-align: center;
    border: 1px solid #ddd;
    background: white;
}

.results-table tbody tr:nth-child(even) {
    background: #f5f5f5;
}

.results-table tbody tr:hover {
    background: #e3f2fd;
    transition: background 0.3s ease;
}

/* NEW: Highlight cells based on content */
.results-table td.temp-cold {
    color: #00bcd4;
    font-weight: 600;
}

.results-table td.temp-room {
    color: #4caf50;
    font-weight: 600;
}

.results-table td.temp-hot {
    color: #ff5722;
    font-weight: 600;
}

.results-table td.droplets-high {
    color: #f57c00;
    font-weight: 600;
}

.results-table td.droplets-none {
    color: #757575;
    font-weight: 600;
}

/* Explanation text area */
.explanation {
    background: #e8f5e9;
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid #4caf50;
    font-size: 13px;
    line-height: 1.5;
    display: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.explanation.show {
    display: block;
    animation: slideIn 0.5s ease-out;
}

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

/* Responsive adjustments for smaller screens */
@media (max-width: 600px) {
    .simulation-area {
        flex-direction: column;
        gap: 15px;
    }
    
    .info-panel {
        grid-template-columns: 1fr 1fr;
        width: 100%;
    }
    
    .controls {
        flex-direction: column;
    }
    
    .control-btn {
        width: 100%;
    }
    
    /* Make table scrollable on small screens */
    .results-table-container {
        overflow-x: auto;
    }
    
    .results-table {
        font-size: 11px;
    }
    
    .results-table th,
    .results-table td {
        padding: 8px 6px;
    }
}

/* Touch device optimization */
@media (hover: none) and (pointer: coarse) {
    .control-btn {
        min-height: 50px;
        font-size: 14px;
    }
    
    .info-box:hover {
        transform: none;
    }
}