/* 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%);
    height: 100vh;
    overflow: hidden;
}

/* Container setup for iframe compatibility */
.container {
    width: 100%;
    height: 450px; /* Default iframe height */
    max-height: 90vh; /* For standalone browser */
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    overflow: hidden;
}

/* When not in iframe, use full viewport height */
@media (min-height: 500px) {
    .container {
        height: 90vh;
    }
}

/* Control Panel Styles */
.control-panel {
    display: flex;
    flex-direction: row;
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
    flex-shrink: 0;
}

.data-section {
    flex: 1;
    min-width: 300px;
}

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

.section-title {
    font-weight: 600;
    color: #495057;
    font-size: 14px;
    cursor: help;
}

.sample-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.sample-btn:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

/* Table Styles */
.table-container {
    background: white;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: #007bff;
    color: white;
    padding: 8px 12px;
    text-align: left;
    font-size: 12px;
    font-weight: 500;
}

.data-table td {
    padding: 6px 12px;
    border-bottom: 1px solid #dee2e6;
}

.data-table input {
    width: 100%;
    border: 1px solid #ced4da;
    border-radius: 3px;
    padding: 4px 8px;
    font-size: 12px;
    transition: border-color 0.2s;
}

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

.add-row-btn {
    width: 100%;
    background: #f8f9fa;
    border: none;
    padding: 8px;
    color: #007bff;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s;
}

.add-row-btn:hover {
    background: #e9ecef;
}

/* Chart Selector Styles */
.chart-selector {
    flex: 1;
    min-width: 250px;
}

.chart-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
}

.chart-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 8px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 60px;
}

.chart-btn:hover {
    border-color: #007bff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.2);
}

.chart-btn.active {
    border-color: #007bff;
    background: #e3f2fd;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.chart-icon {
    font-size: 18px;
    margin-bottom: 4px;
}

.chart-label {
    font-size: 11px;
    font-weight: 500;
    color: #495057;
    text-align: center;
}

/* Chart Area Styles */
.chart-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 15px;
    overflow: hidden;
}

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

.chart-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    position: relative;
    overflow: hidden;
}

.chart-legend {
    margin-top: 10px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

/* Chart-specific styles */
.bar-chart, .pie-chart, .pictogram, .dot-plot {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.bar-chart svg, .pie-chart svg, .dot-plot svg {
    max-width: 100%;
    max-height: 100%;
}

.pictogram-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 10px;
    overflow-y: auto;
}

.pictogram-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 5px 0;
}

.pictogram-label {
    min-width: 80px;
    font-size: 12px;
    font-weight: 500;
}

.pictogram-icons {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}

.pictogram-icon {
    font-size: 16px;
}

/* Help tooltip */
.help-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s;
    max-width: 200px;
    text-align: center;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .control-panel {
        flex-direction: column;
        gap: 10px;
        padding: 10px;
    }
    
    .chart-buttons {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }
    
    .chart-btn {
        padding: 8px 6px;
        min-height: 50px;
    }
    
    .chart-icon {
        font-size: 16px;
    }
    
    .chart-label {
        font-size: 10px;
    }
    
    .data-table th,
    .data-table td {
        padding: 6px 8px;
        font-size: 11px;
    }
}

/* Touch-friendly sizing */
@media (pointer: coarse) {
    .chart-btn {
        min-height: 64px;
        padding: 12px 8px;
    }
    
    .sample-btn, .add-row-btn {
        min-height: 44px;
        padding: 8px 12px;
    }
    
    .data-table input {
        min-height: 36px;
        padding: 6px 10px;
    }
}