/* ==================== COMPONENT & DIAGRAM STYLES ==================== */

/* Diagram Container */
.diagram-container {
    min-width: 10000px;  /* Large canvas for zooming out */
    min-height: 8000px;  /* Large canvas for zooming out */
    position: relative;
    transform-origin: 0 0;
    z-index: 3; /* Above bus bars (2), connection lines (1), and white background (0) */
    pointer-events: none; /* Allow clicks to pass through to bus bars below */
    
    /* NO background on this element - white background is a separate sibling SVG */
}

/* Component Groups */
.component-group {
    position: absolute;
    cursor: move;
    user-select: none;
    z-index: 5; /* Above connection lines (z-index: 1) */
    pointer-events: auto; /* Re-enable pointer events for components */
    /* No flexbox - using absolute positioning for precise control */
    /* No fixed width/height - let it be determined by symbol size */
}

/* Conduit and Cable components should appear above all other components */
.component-group[data-component-type="conduit"],
.component-group[data-component-type="cable"] {
    z-index: 10; /* Higher than regular components */
}

.component-group[data-component-type="from-street-utility"] {
    z-index: 3; /* Below regular components (z-index: 5) but above connection lines (z-index: 1) */
}

.component-group.dragging {
    opacity: 0.7;
    cursor: grabbing;
    z-index: 1000;
}

.component-group.selected .component-symbol {
    /* Clear yellow highlight like PDF text selection */
    filter: drop-shadow(0 0 10px rgb(255, 230, 0)) 
            drop-shadow(0 0 20px rgba(255, 235, 59, 0.6));
    background: rgba(255, 235, 59, 0.25);
    border-radius: 4px;
}

/* Drop target highlight - shown when dragging a component over another */
.component-group.drop-target-highlight {
    animation: pulse-yellow 0.6s ease-in-out infinite;
}

.component-group.drop-target-highlight .component-symbol {
    filter: drop-shadow(0 0 12px rgb(255, 230, 0)) 
            drop-shadow(0 0 24px rgba(255, 235, 59, 0.8));
    background: rgba(255, 235, 59, 0.35);
    border-radius: 4px;
}

.component-group.drop-target-highlight .component-info-box {
    background: rgba(255, 235, 59, 0.15);
    border-color: rgba(255, 230, 0, 0.5);
}

@keyframes pulse-yellow {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

/* Component Mask - Hides connection lines behind components (invisible to user) */
.component-mask {
    position: absolute;
    left: 30px;  /* Center of 60px symbol */
    top: 30px;   /* Center of 60px symbol */
    transform: translate(-50%, -50%);
    background-color: white;
    z-index: 1;
    pointer-events: none; /* Don't interfere with component interactions */
}

/* Component Symbols */
.component-symbol {
    position: absolute; /* Absolute positioning at (0,0) of component group */
    left: 0;
    top: 0;
    z-index: 2; /* Above mask */
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter 0.3s;
}

.component-symbol svg {
    width: 100%;
    height: 100%;
}

/* Component Info Box */
.component-info-box {
    background: transparent;
    border: none;
    padding: 0;
    font-size: 11px;
    line-height: 1.6;
    /* No min-width - let it size to content for proper centering */
    position: absolute; /* Absolute positioning for precise gap control */
    z-index: 3; /* Above symbol and mask */
    transition: opacity 0.3s ease, visibility 0.3s ease;
    cursor: context-menu; /* Show context menu cursor on hover */
    white-space: nowrap; /* Prevent line breaks */
    /* Position is set dynamically via JavaScript based on actual symbol dimensions */
}

/* Hide info boxes when toggle is off */
.diagram-container.hide-info-boxes .component-info-box {
    opacity: 0;
    visibility: hidden;
}

.component-info-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.component-info-title {
    display: inline-block;
    font-weight: 400;
    color: #000000;
    background: white;
    border: 2px solid #000000;
    padding: 1px 12px;
    border-radius: 20px;
    font-size: 11px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.component-type-label {
    font-size: 11px;
    color: #000000;
    font-weight: 400;
}

.component-info-line {
    color: #000000;
    margin: 2px 0;
    font-weight: 400;
    display: block;
    font-size: 11px;
}

.component-info-label {
    font-weight: 400;
    color: #000000;
}

/* Conduit formatted info box */
.conduit-info-formatted {
    color: #000000;
    font-weight: 400;
    font-size: 11px;
    padding: 4px 0;
}

/* Conduit info line (1st line in conduit info box) */
.conduit-info-line {
    color: #000000;
    font-weight: 400;
    font-size: 11px;
    padding: 2px 0;
}

/* Cable info line (1st line in cable info box) */
.cable-info-line {
    color: #000000;
    font-weight: 400;
    font-size: 11px;
    padding: 2px 0;
}

/* Conductor info line (2nd line in conduit/cable info box) */
.conductor-info-line {
    color: #000000;
    font-weight: 400;
    font-size: 11px;
    padding: 2px 0;
}

/* Breaker info box - compact 2-line format */
.breaker-info-box {
    color: #000000;
    font-weight: 400;
    font-size: 11px;
}

/* Breaker info lines */
.breaker-info-line {
    color: #000000;
    font-weight: 400;
    font-size: 11px;
    padding: 1px 0;
    white-space: nowrap;
}

/* Line 1: Ampacity / Poles (e.g., "100A / 2P") */
.breaker-line-1 {
    font-weight: 500;
}

/* Line 2: kAIC rating (e.g., "18 kAIC") */
.breaker-line-2 {
    font-weight: 400;
}


/* Connection Lines (SVG) */
.connection-line {
    position: absolute;
    stroke: #2c3e50;
    stroke-width: 2;
    fill: none;
    pointer-events: none;
}

.connection-arrow {
    fill: #2c3e50;
}

/* White background SVG - sits behind all other layers */
svg#whiteBackgroundSvg {
    position: absolute;
    top: 0;
    left: 0;
    width: 10000px;  /* Fixed size for active area */
    height: 8000px;
    pointer-events: none;
    z-index: 0; /* Behind everything else */
    overflow: visible;
}

svg#connectionsSvg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Don't block clicks on components/conduits */
    z-index: 1; /* Above white background (0), behind bus bars (2) and components (3) */
    overflow: visible;
}

/* Dedicated SVG layer for bus bars - below components so masks work correctly */
svg#busBarsSvg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2; /* Above connections (1) and white background (0), below components (3) - masks will hide lines */
    overflow: visible;
    pointer-events: none; /* SVG itself doesn't block, only children with pointer-events: auto */
}

/* Dedicated SVG layer for FSU lines and arrows - same level as connection lines */
svg#fsuLinesSvg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1; /* Same as connection lines - will be masked by component symbols */
    overflow: visible;
    pointer-events: none; /* Don't block mouse events */
}

/* Connection control point handles - above all other layers for easy interaction */
svg#connectionHandlesSvg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000; /* Above components for interaction */
    overflow: visible;
    pointer-events: none; /* Allow clicks to pass through, except on handles */
}

svg#connectionHandlesSvg circle {
    pointer-events: auto; /* Handles are interactive */
    transition: r 0.15s ease; /* Smooth hover effect */
}

/* Bus bar lines should be clickable and draggable - even though they're below components */
svg#busBarsSvg .bus-bar-line {
    pointer-events: auto; /* Bus bar lines are interactive */
    cursor: move !important;  /* Entire bus bar line is draggable for group drag */
    /* Increase stroke width for easier clicking */
    stroke-width: 1;
}

svg#busBarsSvg .bus-bar-line:hover {
    stroke: #3498db; /* Highlight on hover */
    stroke-width: 4;
    cursor: move !important; /* 4-directional arrow cursor */
}

/* Bus bar group drag handle - kept for backward compatibility but fully invisible */
/* The entire bus bar line is now draggable, so this handle is no longer needed visually */
svg#busBarsSvg .bus-bar-group-drag-handle {
    pointer-events: auto;
    cursor: move;
    stroke: transparent; /* Always invisible */
    stroke-width: 10;
}

svg#busBarsSvg .bus-bar-group-drag-handle:hover {
    stroke: transparent; /* Stay invisible on hover - no visual feedback needed */
    stroke-width: 10;
}

/* Bus bar connection nodes (circles) */
svg#busBarsSvg .bus-bar-connection-node,
svg#connectionsSvg .bus-bar-connection-node {
    pointer-events: auto; /* Make nodes draggable for horizontal movement */
    cursor: ew-resize; /* Show horizontal resize cursor */
    transition: all 0.2s ease; /* Smooth transition on hover */
}

svg#busBarsSvg .bus-bar-connection-node:hover,
svg#connectionsSvg .bus-bar-connection-node:hover {
    fill: #3498db; /* Blue on hover to indicate interactivity */
    stroke: #2980b9; /* Darker blue border */
    stroke-width: 2;
    r: 6; /* Slightly larger on hover */
    filter: drop-shadow(0 0 4px rgba(52, 152, 219, 0.6)); /* Glow effect */
}

/* ==================== COMPONENT PALETTE ==================== */

/* Search Container */
.search-container {
    margin-bottom: 15px;
}

.component-search {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: white;
    color: #2c3e50;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.component-search:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.component-search::placeholder {
    color: #95a5a6;
    font-style: italic;
}

/* Component Palette Container */
.component-palette-container {
    height: 500px;
    overflow-y: auto;
    overflow-x: hidden;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: white;
    margin-bottom: 25px;
    padding: 10px;
}

.component-palette-container::-webkit-scrollbar {
    width: 6px;
}

.component-palette-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.component-palette-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.component-palette-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.component-palette-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.component-palette-btn {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px 8px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-height: 85px;
    position: relative;
}

.component-palette-btn:hover {
    border-color: #3498db;
    background: #f0f8ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.25);
}

.component-palette-btn.selected {
    border-color: #3498db;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.component-palette-btn svg {
    max-width: 50px;
    max-height: 50px;
    width: auto;
    height: auto;
    flex-shrink: 0;
}

.component-palette-btn span {
    font-size: 10px;
    font-weight: 600;
    color: #2c3e50;
    text-align: center;
    line-height: 1.2;
    max-width: 100%;
    word-wrap: break-word;
}

/* Hidden components during search */
.component-palette-btn.hidden {
    display: none;
}

.component-details-title {
    font-size: 16px;
    color: #2c3e50;
    margin: 25px 0 15px 0;
    font-weight: 600;
    padding-bottom: 10px;
    border-bottom: 2px solid #3498db;
}

/* ==================== RADIO BUTTONS ==================== */

.radio-group {
    display: flex;
    gap: 15px;
    margin-top: 8px;
    align-items: center;
    justify-content: flex-start;
    max-width: 100%;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
    line-height: 18px;
    flex-shrink: 0;
}

.radio-label input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
    vertical-align: middle;
}

/* ==================== PROPERTIES PANEL ==================== */

.properties-panel {
    background: #f8f9fa;
    border-left: 1px solid #e0e0e0;
    padding: 25px;
    overflow-y: auto;
    overflow-x: hidden;
    transition: all 0.3s ease;
}

.properties-panel h2 {
    font-size: 18px;
    color: #2c3e50;
    margin: 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #3498db;
}

.property-item {
    margin-bottom: 20px;
    background: white;
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid #3498db;
}

.property-label {
    font-size: 12px;
    color: #7f8c8d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.property-value {
    font-size: 15px;
    color: #2c3e50;
    font-weight: 600;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #95a5a6;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

/* Property Panel Input Styles */
.property-input, .property-select {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: white;
    color: #2c3e50;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

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

.property-input:hover, .property-select:hover {
    border-color: #bdc3c7;
}

.property-select {
    cursor: pointer;
}

.property-input {
    font-weight: 600;
}

.property-actions {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Remove margins from buttons inside property-actions since gap handles spacing */
.property-actions .btn {
    margin: 0 !important;
}

/* Property section title */
.property-section-title {
    font-size: 13px;
    font-weight: 700;
    color: #7f8c8d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 20px 0 10px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #e0e0e0;
}

.property-section-title:first-child {
    margin-top: 0;
}

/* Collapsible Section Styles */
.collapsible-section {
    margin-bottom: 12px;
}

.property-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: #ffffff;
    color: #2c3e50;
    border: 1px solid #dce0e3;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    margin-bottom: 0;
}

.property-section-header:hover {
    background: #f8f9fa;
    border-color: #bdc3c7;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.property-section-header:active {
    transform: scale(0.99);
}

.section-title-text {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #7f8c8d;
}

.section-toggle-icon {
    font-size: 11px;
    transition: transform 0.2s ease;
    font-weight: bold;
    color: #95a5a6;
}

.property-section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

.property-section-content.expanded {
    max-height: 5000px;
    opacity: 1;
    padding-top: 10px;
}

/* Property Value with Action Button */
.property-value-with-action {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.btn-replace-type {
    padding: 6px 12px;
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.btn-replace-type:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
}

/* ==================== SEARCHABLE DROPDOWN ==================== */

.searchable-dropdown {
    position: relative;
    width: 100%;
}

.dropdown-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #e0e0e0;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.dropdown-option {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
    color: #2c3e50;
    transition: background-color 0.2s ease;
}

.dropdown-option:hover {
    background-color: #f8f9fa;
}

.dropdown-option:last-child {
    border-bottom: none;
}

.dropdown-option.selected {
    background-color: #3498db;
    color: white;
}

/* Hide dropdown when not focused */
.searchable-dropdown:not(.focused) .dropdown-options {
    display: none !important;
}

/* No selection message in properties panel */
.no-selection {
    text-align: center;
    color: #95a5a6;
    font-style: italic;
    padding: 40px 20px;
    margin: 20px 0;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px dashed #ddd;
}

/* ==========================================
   Drop Zone Indicator Styles
   ========================================== */

.drop-zone-indicator {
    pointer-events: none;
    z-index: 10000;
    animation: dropZonePulse 0.6s ease-in-out infinite;
}

@keyframes dropZonePulse {
    0%, 100% {
        opacity: 1;
        transform: scaleY(1);
    }
    50% {
        opacity: 0.7;
        transform: scaleY(1.2);
    }
}

