/* Visualization Panel */
.visualization-panel {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.visualization-panel h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

/* Log Visualization */
.log-visualization {
    min-height: 400px;
    background: var(--bg-color);
    border-radius: 0.5rem;
    padding: 1rem;
    overflow-x: auto;
}

.log-viz-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: var(--text-secondary);
}

.log-viz-empty svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* D3 Log Column */
.log-column {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
}

.log-column .axis {
    font-size: 11px;
}

.log-column .axis path,
.log-column .axis line {
    stroke: var(--border-color);
    shape-rendering: crispEdges;
}

.log-column .axis text {
    fill: var(--text-primary);
}

.log-column .grid line {
    stroke: var(--border-color);
    stroke-opacity: 0.3;
    shape-rendering: crispEdges;
}

.log-column .grid path {
    stroke-width: 0;
}

/* Interval Rectangles */
.interval-rect {
    stroke: #333;
    stroke-width: 1.5;
    transition: all 0.2s ease;
    cursor: pointer;
}

.interval-rect:hover {
    stroke: var(--primary-color);
    stroke-width: 2.5;
    filter: brightness(1.1);
}

/* Interval Labels */
.interval-label {
    font-size: 11px;
    font-weight: 500;
    fill: var(--text-primary);
    pointer-events: none;
}

.interval-label.depth {
    font-size: 10px;
    fill: var(--text-secondary);
}

/* Legend */
.legend {
    font-size: 11px;
}

.legend-item {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.legend-item:hover {
    opacity: 0.8;
}

.legend-item rect {
    stroke: #333;
    stroke-width: 1;
}

.legend-item text {
    fill: var(--text-primary);
}

/* Tooltip */
.d3-tooltip {
    position: absolute;
    background: var(--text-primary);
    color: white;
    padding: 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    max-width: 250px;
}

.d3-tooltip.show {
    opacity: 0.95;
}

.d3-tooltip h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: white;
}

.d3-tooltip .tooltip-row {
    display: flex;
    justify-content: space-between;
    margin: 0.25rem 0;
}

.d3-tooltip .tooltip-label {
    color: rgba(255, 255, 255, 0.8);
    margin-right: 1rem;
}

.d3-tooltip .tooltip-value {
    font-weight: 500;
}

/* Zoom Controls */
.zoom-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.5rem;
    box-shadow: var(--shadow-md);
}

.zoom-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--surface-color);
    border-radius: 0.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.zoom-btn:hover {
    background: var(--bg-color);
}

.zoom-btn:active {
    background: var(--border-color);
}

.zoom-btn svg {
    width: 20px;
    height: 20px;
}

/* Cross Section Visualization */
.cross-section-viz svg {
    width: 100%;
    height: 100%;
}

.cross-section-svg {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
}

.cross-section-svg .axis path,
.cross-section-svg .axis line {
    stroke: var(--border-color);
    shape-rendering: crispEdges;
}

.cross-section-svg .axis text {
    fill: var(--text-secondary);
    font-size: 11px;
}

.cross-section-svg .grid line {
    stroke: var(--border-color);
    stroke-dasharray: 2, 2;
    stroke-opacity: 0.4;
}

.cross-section-interval {
    stroke: #1e293b;
    stroke-width: 1.2;
    cursor: pointer;
    transition: filter 0.2s ease, stroke-width 0.2s ease;
}

.cross-section-interval:hover {
    filter: brightness(1.08);
    stroke-width: 1.8;
}

.cross-section-interval.primary-highlight {
    stroke-width: 2.6;
    filter: brightness(1.15);
    box-shadow: 0 0 8px rgba(15, 23, 42, 0.35);
}

.cross-section-interval.secondary-highlight {
    stroke-width: 2;
    stroke-dasharray: 4, 2;
    filter: brightness(1.05);
}

.cross-section-hole-label {
    font-size: 0.75rem;
    fill: var(--text-primary);
    font-weight: 600;
}

.cross-section-depth-label {
    font-size: 0.75rem;
    fill: var(--text-secondary);
}

.plane-svg text {
    fill: var(--text-secondary);
}

/* Visualization Toolbar */
.viz-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.viz-toolbar-left {
    display: flex;
    gap: 0.5rem;
}

.viz-toolbar-right {
    display: flex;
    gap: 0.5rem;
}

.viz-btn {
    padding: 0.5rem 0.875rem;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    border-radius: 0.375rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.viz-btn:hover {
    background: var(--bg-color);
    border-color: var(--primary-color);
}

.viz-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.viz-btn svg {
    width: 14px;
    height: 14px;
}

/* Scale Selector */
.scale-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.scale-selector label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.scale-selector select {
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.75rem;
    background: var(--surface-color);
    cursor: pointer;
}

/* Pattern Fills for Lithology */
.lithology-pattern {
    stroke: none;
}

/* Cross-section View */
.cross-section {
    display: flex;
    gap: 2rem;
    margin-top: 1rem;
}

.log-column-wrapper {
    flex: 1;
    min-width: 200px;
}

.log-column-header {
    background: var(--bg-color);
    padding: 0.75rem;
    border-radius: 0.5rem 0.5rem 0 0;
    border-bottom: 2px solid var(--border-color);
}

.log-column-header h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.log-column-header .meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Statistics Panel */
.stats-panel {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-top: 1rem;
}

.stats-panel h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.stat-item {
    text-align: center;
}

.stat-item .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-item .label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Loading Animation */
.viz-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

.viz-loading .spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.viz-loading p {
    margin-top: 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Export Preview */
.export-preview {
    background: white;
    padding: 2rem;
    border-radius: 0.5rem;
}

.export-preview .log-header {
    border-bottom: 2px solid #333;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.export-preview .log-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.export-preview .log-meta {
    font-size: 0.875rem;
    color: #666;
}

/* Responsive Visualization */
@media (max-width: 768px) {
    .log-visualization {
        padding: 0.5rem;
    }

    .cross-section {
        flex-direction: column;
    }

    .viz-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .viz-toolbar-left,
    .viz-toolbar-right {
        width: 100%;
        justify-content: space-between;
    }

    .zoom-controls {
        flex-direction: row;
    }

    .d3-tooltip {
        max-width: 200px;
        font-size: 0.7rem;
    }
}

/* Print Styles */
@media print {
    .visualization-panel {
        border: none;
        box-shadow: none;
    }

    .viz-toolbar,
    .zoom-controls {
        display: none;
    }

    .log-visualization {
        background: white;
    }
}

/* SVG Specific Styles */
svg.log-viz-svg {
    display: block;
    margin: 0 auto;
}

svg.log-viz-svg text {
    user-select: none;
}

/* Color Scale Legend */
.color-scale {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--bg-color);
    border-radius: 0.375rem;
}

.color-scale-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
}

.color-scale-swatch {
    width: 20px;
    height: 20px;
    border-radius: 0.25rem;
    border: 1px solid var(--border-color);
}

/* Depth Markers */
.depth-marker {
    stroke: var(--text-secondary);
    stroke-width: 1;
    stroke-dasharray: 2, 2;
}

.depth-marker-label {
    font-size: 10px;
    fill: var(--text-secondary);
    font-weight: 500;
}

/* Minimap */
.minimap {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    width: 80px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    padding: 0.5rem;
    box-shadow: var(--shadow-md);
}

.minimap svg {
    width: 100%;
    height: auto;
}

.minimap-viewport {
    fill: rgba(37, 99, 235, 0.2);
    stroke: var(--primary-color);
    stroke-width: 1;
    cursor: move;
}
