/* RESPONSIVE CSS FOR INTEGRATED VISUALIZATION */

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    margin: 0;
    padding: 10px;
    background-color: #f8f9fa;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
    padding: 15px;
}

/* CONTROLS SECTION */
.controls {
    text-align: center;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.dropdown-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.slider-container label,
.dropdown-container label {
    font-size: 14px;
    color: #2c3e50;
    font-weight: 500;
}

.slider-container input[type="range"] {
    width: 150px;
    min-width: 100px;
}

.dropdown-container select {
    padding: 6px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    background: white;
    color: #2c3e50;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.dropdown-container select:hover {
    border-color: #3498db;
}

.dropdown-container select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.slider-value {
    background: #3498db;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    min-width: 20px;
    text-align: center;
}

/* MAIN LAYOUT - RESPONSIVE GRID */
.main-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    align-items: center;
    justify-items: center;
    margin-bottom: 30px;
    width: 100%;
}

/* CHART CONTAINERS - RESPONSIVE */
.chart-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 100%;
}

.chart-title {
    text-align: center;
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: clamp(18px, 4vw, 24px);
    font-weight: 700;
    padding: 12px 15px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 10px;
    border: 1px solid #dee2e6;
    width: 100%;
    max-width: 400px;
}

#circleChart, #treemapChart {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    max-width: 700px;
    max-height: 700px;
    border: 2px solid #ddd;
    border-radius: 10px;
    overflow: hidden;
    background: #ffffff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}

/* LEGEND - RESPONSIVE */
.legend-container {
    width: 100%;
    max-width: 700px;
    max-height: 400px;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 10px;
    border: 2px solid #ddd;
    overflow-y: auto;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}

.legend-title {
    font-size: clamp(14px, 3vw, 16px);
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 15px;
    text-align: center;
    flex-shrink: 0;
}

#legend {
    overflow-y: auto;
}

/* Legend scrollbar styles */
#legend::-webkit-scrollbar {
    width: 6px;
}

#legend::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

#legend::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

#legend::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    padding: 8px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.legend-item:hover {
    background-color: rgba(52, 152, 219, 0.1);
}

.legend-square {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    margin-right: 12px;
    border: 2px solid;
    flex-shrink: 0;
}

.legend-text {
    font-size: clamp(11px, 2.5vw, 13px);
    color: #2c3e50;
    font-weight: 500;
    line-height: 1.3;
    word-wrap: break-word;
}

.legend-count {
    font-size: clamp(10px, 2vw, 11px);
    color: #7f8c8d;
    margin-left: auto;
    flex-shrink: 0;
    background: #ecf0f1;
    padding: 2px 6px;
    border-radius: 3px;
}

/* NODE STYLES FOR BOTH VISUALIZATIONS */
.node {
    cursor: pointer;
    transition: all 0.3s ease;
}

.node:hover {
    stroke-width: 3px;
}

/* Circle packing specific styles */
.node-topic {
    fill: #3498db;
    stroke: #2980b9;
    stroke-width: 2px;
    fill-opacity: 0.7;
}

.node-keyword {
    fill: #e74c3c;
    stroke: #c0392b;
    stroke-width: 1px;
    fill-opacity: 0.8;
}

.node-keyword.selected {
    stroke: #ff0000 !important;
    stroke-width: 3px !important;
}

.node-root {
    fill: none;
    stroke: none;
}

/* Treemap specific hover effects */
.node:hover {
    stroke-width: 4px !important;
    filter: brightness(1.1);
}

/* Treemap rectangles */
rect.node-keyword {
    stroke-width: 2px;
    rx: 2px;
    ry: 2px;
}

rect.node-keyword.selected {
    stroke: #e74c3c !important;
    stroke-width: 4px !important;
    filter: brightness(1.15);
}

/* TEXT LABELS */
.label {
    font-size: clamp(10px, 1.5vw, 12px);
    font-weight: bold;
    text-anchor: middle;
    pointer-events: none;
    fill: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    dominant-baseline: middle;
}

.label-keyword {
    font-size: clamp(9px, 1.4vw, 11px);
    font-weight: 600;
    text-anchor: middle;
    pointer-events: none;
    fill: white;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.9);
    dominant-baseline: middle;
}

/* TOOLTIP */
.tooltip {
    position: absolute;
    text-align: left;
    padding: 10px;
    font-size: clamp(11px, 2vw, 12px);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    border-radius: 6px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    max-width: 250px;
    line-height: 1.4;
    z-index: 1000;
}

/* RESPONSES SECTION */
.responses-container {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
    border: 2px solid #ddd;
    min-height: 150px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.responses-title {
    font-size: clamp(18px, 4vw, 22px);
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 20px;
    text-align: center;
}

.responses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    max-height: 600px;
    overflow-y: auto;
    padding: 10px;
}

.response-card {
    background: white;
    border: 2px solid #ddd;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.12);
    transition: all 0.3s ease;
    cursor: pointer;
    user-select: text;
    min-height: 100px;
    display: flex;
    align-items: flex-start;
}

.response-card:hover {
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.18);
    border-color: #3498db;
    transform: translateY(-2px);
}

.response-text {
    font-size: clamp(14px, 2.5vw, 16px);
    line-height: 1.6;
    color: #2c3e50;
    margin: 0;
    user-select: text;
    cursor: text;
    font-weight: 500;
}

.no-responses {
    text-align: center;
    color: #7f8c8d;
    font-style: italic;
    padding: 20px;
}

/* SCROLLBAR STYLES */
.responses-grid::-webkit-scrollbar {
    width: 8px;
}

.responses-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.responses-grid::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.responses-grid::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* CONTEXT MENU */
.context-menu {
    position: absolute;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 4px 0;
    min-width: 140px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.9);
    transition: all 0.2s ease;
}

.context-menu.show {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: clamp(12px, 2.5vw, 14px);
    color: #2c3e50;
    cursor: pointer;
    transition: background-color 0.2s ease;
    user-select: none;
}

.context-menu-item:hover {
    background-color: #f8f9fa;
}

.context-menu-item:active {
    background-color: #e9ecef;
}

.context-menu-item svg {
    width: 16px;
    height: 16px;
    color: #6c757d;
}

/* TABLET RESPONSIVE - 768px and up */
@media (min-width: 768px) {
    body {
        padding: 20px;
    }
    
    .container {
        padding: 25px;
        border-radius: 15px;
    }
    
    .controls {
        gap: 30px;
    }
    
    .slider-container input[type="range"] {
        width: 200px;
    }
    
    .legend-container {
        max-height: 500px;
    }
    
    .responses-container {
        padding: 25px;
    }
    
    .responses-grid {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
        gap: 20px;
        max-height: 700px;
    }
    
    .response-card {
        padding: 20px;
        min-height: 120px;
    }
}

/* DESKTOP RESPONSIVE - 1024px and up */
@media (min-width: 1024px) {
    .container {
        padding: 30px;
    }
    
    .controls {
        gap: 50px;
    }
    
    /* 2-column layout for smaller desktops */
    .main-content {
        grid-template-columns: 1fr 300px;
        gap: 30px;
    }
    
    .legend-container {
        max-height: 700px;
        height: auto;
    }
    
    .responses-grid {
        grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    }
}

/* LARGE DESKTOP - 1400px and up */
@media (min-width: 1400px) {
    /* 3-column layout: Circle | Legend | Treemap */
    .main-content {
        grid-template-columns: 1fr 300px 1fr;
        gap: 40px;
    }
    
    .legend-container {
        height: 680px;
        margin-top: 108px;
        align-self: flex-start;
    }
    
    #circleChart, #treemapChart {
        width: 700px;
        height: 700px;
    }
    
    .chart-container {
        min-width: 700px;
        max-width: 700px;
    }
}

/* MOBILE LANDSCAPE OPTIMIZATION */
@media (max-width: 768px) and (orientation: landscape) {
    #circleChart, #treemapChart {
        max-height: 60vh;
    }
    
    .legend-container {
        max-height: 300px;
    }
    
    .responses-grid {
        max-height: 400px;
    }
}

/* PRINT STYLES */
@media print {
    body {
        background: white;
    }
    
    .container {
        box-shadow: none;
    }
    
    .controls {
        display: none;
    }
    
    .context-menu {
        display: none;
    }
}