/* --- General Tool Styling --- */
.portal-calculator-tool {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #F5F3F6; /* Light lavender gray */
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #E9E3ED;
    max-width: 800px;
    margin: 20px auto;
    color: #3D2C4D;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.tool-title {
    text-align: center;
    color: #4B0082; /* Indigo */
    margin-top: 0;
    margin-bottom: 24px;
    font-weight: 700;
}

/* --- Input Group & Form Styling --- */
#portal-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group-wrapper {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.input-group, .advanced-options {
    background-color: #FFFFFF;
    border: 1px solid #E9E3ED;
    border-radius: 8px;
    padding: 16px;
    flex: 1;
    min-width: 280px;
}

.group-title {
    font-size: 1.1em;
    font-weight: 600;
    color: #4B0082;
    margin: -16px -16px 16px -16px;
    padding: 12px 16px;
    background-color: #F8F6F9;
    border-bottom: 1px solid #E9E3ED;
    border-radius: 8px 8px 0 0;
}

fieldset.input-group {
    padding-top: 0;
}
fieldset.input-group .group-title {
    margin: 0;
    padding: 0;
    background: none;
    border: none;
    margin-bottom: 12px;
    font-size: 1em;
}

.mode-selector {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.radio-container {
    display: flex;
    align-items: center;
}
.radio-container input[type="radio"] {
    accent-color: #9370DB; /* Medium Purple */
}
.radio-container label {
    margin-left: 8px;
    cursor: pointer;
}


.field {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
}
.field label {
    margin-bottom: 4px;
    font-size: 0.9em;
    font-weight: 500;
    color: #554466;
}
.field input[type="number"] {
    padding: 10px;
    border: 1px solid #DCD6E1;
    border-radius: 6px;
    background-color: #FDFCFE;
    font-size: 1em;
    color: #3D2C4D;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.field input[type="number"]:focus {
    outline: none;
    border-color: #9370DB;
    box-shadow: 0 0 0 3px rgba(147, 112, 219, 0.2);
}

.tooltip {
    cursor: help;
    font-weight: bold;
    color: #9370DB;
    position: relative;
    display: inline-block;
}
.tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #3D2C4D;
    color: #FFFFFF;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: normal;
    width: 200px;
    text-align: center;
    z-index: 10;
    opacity: 1;
}

/* --- Advanced Options --- */
.advanced-options summary {
    cursor: pointer;
    outline: none;
}
.advanced-options .summary-hint {
    font-weight: normal;
    font-size: 0.9em;
    color: #7a6c8a;
}
.advanced-options .info-text {
    font-size: 0.9em;
    color: #554466;
    margin-top: 0;
    margin-bottom: 16px;
    background-color: #F8F6F9;
    padding: 10px;
    border-radius: 6px;
}

/* --- Results --- */
.results-container {
    margin-top: 24px;
    background-color: #FFFFFF;
    border: 1px solid #E9E3ED;
    border-radius: 8px;
    padding: 16px;
}
.results-title {
    text-align: center;
    color: #4B0082;
    margin-top: 0;
}
.coords-display {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
    flex-wrap: wrap;
}
.coord-box {
    background-color: #F8F6F9;
    padding: 15px 25px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid #E9E3ED;
    min-width: 90px;
}
.coord-label {
    display: block;
    font-size: 0.9em;
    font-weight: 600;
    color: #554466;
    margin-bottom: 5px;
}
output {
    font-size: 1.5em;
    font-weight: 700;
    color: #9370DB;
}
.rounded-coords {
    text-align: center;
    font-size: 0.95em;
    color: #554466;
    margin-top: -10px;
}
.rounded-coords output {
    font-size: 1em;
    font-weight: 600;
    color: #4B0082;
}

/* --- Insights & Visualizer --- */
.insights-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 20px;
}
@media (min-width: 600px) {
    .insights-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

.insight-card {
    background-color: #F8F6F9;
    border: 1px solid #E9E3ED;
    border-radius: 8px;
    padding: 16px;
}
.insight-card h4 {
    margin-top: 0;
    color: #4B0082;
    border-bottom: 1px solid #E9E3ED;
    padding-bottom: 8px;
}
.insight-card p {
    font-size: 0.95em;
    line-height: 1.5;
    margin-bottom: 0;
}
.hidden {
    display: none;
}

/* --- Linking Status Indicator --- */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.status-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
}
.status-text {
    font-weight: 600;
    font-size: 1.1em;
}
/* Status Colors */
.status-indicator.safe .status-icon { background-color: #28a745; }
.status-indicator.safe .status-text { color: #28a745; }
.status-indicator.caution .status-icon { background-color: #ffc107; }
.status-indicator.caution .status-text { color: #d4a106; }
.status-indicator.danger .status-icon { background-color: #dc3545; }
.status-indicator.danger .status-text { color: #dc3545; }

/* --- Visualizer --- */
#visualizer-map-container {
    position: relative;
    width: 100%;
    padding-top: 100%; /* 1:1 Aspect Ratio */
    background-color: #fff;
    border: 1px solid #e0d9e6;
    border-radius: 4px;
    overflow: hidden;
}
#visualizer-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}
.visualizer-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    margin-top: 15px;
    font-size: 0.85em;
}
.visualizer-legend > div {
    display: flex;
    align-items: center;
    gap: 6px;
}
.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}
.legend-dot.new-portal { background-color: #9370DB; }
.legend-dot.existing-portal { background-color: #ff7f50; }
.legend-dot.link-range { background-color: rgba(255, 193, 7, 0.4); border: 1px solid #ffc107;}