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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 10px;
    /* Responsive height - 450px for iframe, 90vh for browser tab */
    height: 450px;
    overflow-y: auto;
}

/* Check if running in new tab (larger viewport) */
@media (min-height: 500px) {
    body {
        height: 90vh;
    }
}

.container {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr auto;
    gap: 10px;
    max-width: 1200px;
    margin: 0 auto;
}

/* Simulation panel - main visual area */
.simulation-panel {
    grid-column: 1 / -1;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    padding: 15px;
    cursor: help; /* Indicates tooltip availability */
}

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

/* Text labels and styling */
.label {
    font-size: 12px;
    fill: #333;
    font-weight: bold;
}

.ray-label {
    font-size: 11px;
    fill: #333;
    font-weight: bold;
}

.angle-text {
    font-size: 14px;
    fill: #333;
    font-weight: bold;
    text-anchor: middle;
}

.axis-label {
    font-size: 12px;
    fill: #333;
    font-weight: bold;
}

/* Controls panel */
.controls-panel {
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.slider-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.slider-container label {
    font-weight: bold;
    color: #333;
    font-size: 14px;
}

#angleSlider {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

#angleSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
}

#angleSlider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
    border: none;
}

#angleValue {
    font-weight: bold;
    color: #4CAF50;
    font-size: 16px;
    text-align: center;
}

/* Button styling with touch-friendly sizes */
.button-container {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.control-btn {
    flex: 1;
    min-width: 80px;
    min-height: 44px; /* Touch-friendly size */
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

#recordBtn {
    background: #2196F3;
    color: white;
}

#recordBtn:hover {
    background: #1976D2;
    transform: translateY(-2px);
}

#plotBtn {
    background: #FF9800;
    color: white;
}

#plotBtn:hover {
    background: #F57C00;
    transform: translateY(-2px);
}

#resetBtn {
    background: #f44336;
    color: white;
}

#resetBtn:hover {
    background: #d32f2f;
    transform: translateY(-2px);
}

/* Data container */
.data-container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    padding: 15px;
    overflow-y: auto;
}

.data-container h3 {
    margin-bottom: 10px;
    color: #333;
    font-size: 16px;
}

/* Table styling */
.table-container {
    margin-bottom: 20px;
}

#dataTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

#dataTable th,
#dataTable td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: center;
}

#dataTable th {
    background: #f5f5f5;
    font-weight: bold;
    color: #333;
}

#dataTable tr:nth-child(even) {
    background: #f9f9f9;
}

/* Graph container */
.graph-container {
    margin-top: 15px;
}

#graphSvg {
    width: 100%;
    height: 250px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: white;
}

/* Responsive design for mobile devices */
@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }
    
    .simulation-panel {
        grid-column: 1;
    }
    
    .controls-panel,
    .data-container {
        grid-column: 1;
    }
    
    .button-container {
        flex-direction: column;
    }
    
    .control-btn {
        min-height: 48px; /* Larger touch targets on mobile */
    }
    
    #dataTable {
        font-size: 11px;
    }
    
    #dataTable th,
    #dataTable td {
        padding: 6px;
    }
}

/* Animation for smooth transitions */
#incidentRay,
#reflectedRay,
#incidentArc,
#reflectedArc {
    transition: all 0.3s ease;
}

/* Tooltip styling */
.simulation-panel:hover::after {
    content: attr(title);
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
}