/* Map AI - Main Stylesheet */

/* Reset and Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary-color: #0d9488;
    --primary-hover: #0f766e;
    --secondary-color: #6b7280;
    --secondary-hover: #4b5563;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f9fafb;
    --panel-bg: #ffffff;
    --border-color: #e5e7eb;
    --text-color: #1f2937;
    --text-muted: #6b7280;
    --header-height: 56px;
    --status-height: 28px;
    --panel-header-height: 48px;
    --client-color: #dc2626;
    --defendant-color: #0d9488;
    --witness-color: #f97316;
    --impact-color: #eab308;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-color);
    background: var(--bg-color);
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 50px;
    background: var(--panel-bg);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.app-header h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-color);
}

.header-actions {
    display: flex;
    gap: 8px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border-color);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-large {
    padding: 12px 24px;
    font-size: 15px;
    width: 100%;
}

.btn-small {
    padding: 4px 10px;
    font-size: 12px;
}

.btn .icon {
    font-size: 14px;
}

/* Split Pane Layout */
.split-pane {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.panel {
    display: flex;
    flex-direction: column;
    background: var(--panel-bg);
    overflow: hidden;
}

.panel-left {
    width: 55%;
    min-width: 500px;
    max-width: 65%;
    border-right: 1px solid var(--border-color);
}

.panel-right {
    flex: 1;
    min-width: 300px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--panel-header-height);
    padding: 0 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.panel-header h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 50px;
}

/* Resize Handle */
.resize-handle {
    width: 6px;
    background: var(--border-color);
    cursor: col-resize;
    transition: background 0.15s;
    flex-shrink: 0;
}

.resize-handle:hover,
.resize-handle.active {
    background: var(--primary-color);
}

/* Text Input Section */
.input-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#description-input,
#location-input {
    width: 100%;
    padding: 12px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.6;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    resize: vertical;
    transition: border-color 0.15s;
}

#description-input {
    min-height: 180px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
}

#location-input {
    min-height: 100px;
}

#description-input:focus,
#location-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

#description-input::placeholder,
#location-input::placeholder {
    color: var(--text-muted);
}

/* Textarea Wrapper for Autocomplete */
.textarea-wrapper {
    position: relative;
}

/* Location Autocomplete Dropdown */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
}

.autocomplete-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

.autocomplete-icon {
    font-size: 14px;
}

.autocomplete-results {
    padding: 4px 0;
}

.autocomplete-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.1s;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: var(--bg-color);
}

.autocomplete-item-icon {
    font-size: 16px;
    margin-top: 2px;
}

.autocomplete-item-content {
    flex: 1;
    min-width: 0;
}

.autocomplete-item-main {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.autocomplete-item-secondary {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.autocomplete-loading,
.autocomplete-empty,
.autocomplete-prompt {
    padding: 16px 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.autocomplete-hint {
    padding: 8px 12px;
    background: var(--bg-color);
    border-top: 1px solid var(--border-color);
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

/* Route Suggestions Dropdown */
.route-dropdown {
    border-color: #22c55e;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.2);
}

.route-dropdown .autocomplete-header {
    background: linear-gradient(135deg, #22c55e15 0%, #16a34a10 100%);
    border-bottom-color: #22c55e30;
    color: #166534;
}

.route-dropdown .autocomplete-item:hover,
.route-dropdown .autocomplete-item.selected {
    background: #22c55e15;
}

.route-dropdown .autocomplete-item-icon {
    color: #22c55e;
}

/* Parsed Data Section */
.parsed-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.parsed-section h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#parsed-data-content {
    background: var(--bg-color);
    border-radius: 8px;
    padding: 12px;
}

.parsed-item {
    margin-bottom: 12px;
}

.parsed-item:last-child {
    margin-bottom: 0;
}

.parsed-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.parsed-value {
    font-size: 13px;
    color: var(--text-color);
}

.vehicle-card {
    background: white;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
}

.vehicle-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    margin-bottom: 6px;
}

.vehicle-icon {
    font-size: 18px;
}

.vehicle-details {
    font-size: 12px;
    color: var(--text-muted);
}

/* Markers Section */
.markers-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.markers-section h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#markers-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.marker-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--bg-color);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.marker-item:hover {
    background: var(--border-color);
}

.marker-item.selected {
    background: rgba(37, 99, 235, 0.1);
    border: 1px solid var(--primary-color);
}

.marker-icon {
    font-size: 20px;
    width: 28px;
    text-align: center;
}

.marker-info {
    flex: 1;
}

.marker-label {
    font-weight: 500;
    font-size: 13px;
}

.marker-type {
    font-size: 11px;
    color: var(--text-muted);
}

.marker-actions {
    display: flex;
    gap: 4px;
}

.marker-action-btn {
    padding: 4px 8px;
    font-size: 11px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
}

.marker-action-btn:hover {
    background: var(--border-color);
}

.marker-action-btn.delete:hover {
    background: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
}

/* Marker Rotation Controls */
.marker-rotation {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.rotate-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    font-size: 14px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.rotate-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.rotation-value {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    min-width: 35px;
    text-align: center;
}

/* Map Panel Content */
.map-panel-content {
    display: flex;
    flex-direction: column;
    padding: 16px 50px;
}

.map-form-row {
    flex-shrink: 0;
    margin-bottom: 16px;
    align-items: flex-end;
}

.map-form-row .form-section:first-child {
    flex: 0 0 160px;
}

.map-form-row .form-section {
    display: flex;
    flex-direction: column;
}

.map-form-row .form-input {
    margin-top: auto;
}

/* Map Container */
#map-container {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 300px;
}

#map {
    width: 100%;
    height: 100%;
}

.map-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
    color: var(--text-muted);
    text-align: center;
    padding: 40px;
}

.map-placeholder p {
    max-width: 300px;
    line-height: 1.6;
}

/* Map Legend */
.map-legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--text-color);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 12px;
    min-width: 220px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    z-index: 100;
}

.map-legend.hidden {
    display: none;
}

.legend-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
    cursor: move;
    user-select: none;
}

.map-legend.dragging {
    opacity: 0.9;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.legend-items-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    margin: 0 -6px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.legend-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.legend-item:last-child {
    padding-bottom: 4px;
}

.legend-color {
    width: 24px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.legend-color.client-pl {
    background: var(--client-color);
}

.legend-color.defendant-df {
    background: var(--defendant-color);
}

.legend-color.other-witness {
    width: 14px;
    height: 14px;
    background: var(--witness-color);
    border-radius: 50%;
}

.legend-color.impact-point {
    width: 18px;
    height: 18px;
    background: transparent;
    border: none;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.legend-color.impact-point::before {
    content: '💥';
    font-size: 16px;
    text-shadow: none;
}

/* Legacy legend colors for backwards compatibility */
.legend-color.user-vehicle {
    background: var(--client-color);
}

.legend-color.other-vehicle {
    background: var(--defendant-color);
}

.legend-color.pedestrian {
    background: var(--witness-color);
    border-radius: 50%;
}

.legend-text {
    flex: 1;
    line-height: 1.3;
    font-size: 12px;
    color: var(--text-color);
    cursor: text;
    padding: 2px 4px;
    margin: -2px -4px;
    border-radius: 3px;
    transition: background 0.15s ease;
    outline: none;
}

.legend-text:hover {
    background: rgba(255, 255, 255, 0.1);
}

.legend-text:focus {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 2px var(--primary-color);
}

.legend-text .vehicle-title {
    font-weight: 500;
    display: block;
}

.legend-text .vehicle-details {
    color: var(--text-muted);
    font-size: 11px;
}

/* Map Compass */
.map-compass {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(45, 55, 72, 0.95);
    color: white;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 100;
    text-align: center;
}

.map-compass.hidden {
    display: none;
}

.compass-ring {
    position: relative;
    width: 70px;
    height: 70px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    margin: 0 auto 6px;
}

.compass-direction {
    position: absolute;
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
}

.compass-direction.north {
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    color: #ef4444;
}

.compass-direction.south {
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
}

.compass-direction.east {
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
}

.compass-direction.west {
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
}

.compass-needle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 25px solid #4ade80;
    transform-origin: center bottom;
    transform: translate(-50%, -100%);
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

.compass-needle::after {
    content: '';
    position: absolute;
    top: 25px;
    left: -3px;
    width: 0;
    height: 0;
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
    border-top: 12px solid rgba(255,255,255,0.5);
}

.compass-center {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    background: #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid rgba(0, 0, 0, 0.3);
}

.compass-heading {
    font-size: 13px;
    font-weight: 600;
    color: #4ade80;
}

.compass-heading span {
    display: block;
}

.map-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.map-controls select {
    padding: 4px 8px;
    font-size: 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: white;
}

/* Status Bar */
.status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--status-height);
    padding: 0 16px;
    background: var(--panel-bg);
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-small {
    max-width: 350px;
}

.modal-validation {
    max-width: 550px;
}

/* Validation Modal Styles */
.validation-header.warning {
    background: #fef3c7;
    border-bottom-color: #f59e0b;
}

.validation-header.error {
    background: #fee2e2;
    border-bottom-color: #ef4444;
}

.validation-score {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-color);
    border-radius: 8px;
    margin-bottom: 16px;
}

.score-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: white;
}

.score-circle.high { background: var(--success-color); }
.score-circle.medium { background: var(--warning-color); }
.score-circle.low { background: var(--danger-color); }

.score-text {
    flex: 1;
}

.score-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.score-status {
    font-weight: 600;
    margin-top: 4px;
}

.validation-issues {
    margin-bottom: 16px;
}

.issue-item {
    display: flex;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
}

.issue-item:last-child {
    margin-bottom: 0;
}

.issue-item.error {
    background: #fee2e2;
    border-left: 3px solid #ef4444;
}

.issue-item.warning {
    background: #fef3c7;
    border-left: 3px solid #f59e0b;
}

.issue-item.info {
    background: #e0f2fe;
    border-left: 3px solid #0ea5e9;
}

.issue-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.issue-content {
    flex: 1;
}

.issue-field {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.issue-message {
    font-size: 13px;
}

.validation-missing {
    margin-bottom: 16px;
}

.missing-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.missing-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.missing-tag {
    padding: 4px 10px;
    background: #fef3c7;
    color: #92400e;
    border-radius: 4px;
    font-size: 12px;
}

.validation-suggestions {
    background: #f0fdf4;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
}

.suggestions-label {
    font-size: 12px;
    font-weight: 600;
    color: #166534;
    margin-bottom: 8px;
}

.suggestion-item {
    font-size: 13px;
    color: #166534;
    padding-left: 16px;
    position: relative;
    margin-bottom: 4px;
}

.suggestion-item::before {
    content: "•";
    position: absolute;
    left: 4px;
}

.validation-actions {
    display: flex;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.validation-actions .btn {
    flex: 1;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    font-size: 24px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-color);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

/* Scenes List */
.scenes-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.scene-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-color);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.scene-item:hover {
    background: var(--border-color);
}

.scene-info {
    flex: 1;
}

.scene-title {
    font-weight: 500;
    margin-bottom: 4px;
}

.scene-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.scene-actions {
    display: flex;
    gap: 8px;
}

.no-scenes {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

/* Form Groups */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-muted);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

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

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    margin-top: 16px;
    font-size: 14px;
    color: var(--text-muted);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Conditional Field Visibility - Hide fields until they have values */
.conditional-field {
    display: none !important;
}

.conditional-field.has-value {
    display: flex !important;
}

/* Special case for checkbox-section which uses flex with specific gap */
.checkbox-section.conditional-field.has-value {
    display: flex !important;
}

/* Special case for radio questions */
.form-section.radio-question.conditional-field.has-value {
    display: block !important;
}

/* Special case for additional-fields container - use block display */
.additional-fields.conditional-field.has-value {
    display: block !important;
}

.loading {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
}

/* Custom Map Marker Labels - Persistent Overlay */
.marker-label-overlay {
    position: absolute;
    transform: translateX(-50%);
    z-index: 1000;
    pointer-events: auto;
}

.marker-label-text {
    position: relative;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    white-space: pre-line;
    line-height: 1.4;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    text-align: center;
    max-width: 220px;
    min-width: 120px;
    cursor: grab;
    user-select: none;
    transition: box-shadow 0.2s ease;
}

.marker-label-text:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.7);
}

.marker-label-text:active {
    cursor: grabbing;
}

.marker-label-text strong {
    display: block;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 2px;
}

.marker-label-text::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid rgba(0, 0, 0, 0.9);
}

/* Left-aligned label (for labels offset to the right) */
.marker-label-overlay.align-left {
    transform: translateX(0);
}

.marker-label-overlay.align-left .marker-label-text::after {
    left: 20px;
}

/* Right-aligned label (for labels offset to the left) */
.marker-label-overlay.align-right {
    transform: translateX(-100%);
}

.marker-label-overlay.align-right .marker-label-text::after {
    left: auto;
    right: 20px;
}

/* MVA Form Styles */
.form-section {
    margin-bottom: 20px;
}

.form-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 4px;
}

.form-section-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.title-note {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-muted);
}

.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 16px;
}

.form-row .form-section {
    flex: 1;
    margin-bottom: 0;
}

.form-row .form-section:first-child {
    flex: 0 0 180px;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    transition: border-color 0.15s;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.5;
}

.form-textarea.large {
    min-height: 180px;
}

/* Radio Button Group */
.radio-group {
    display: flex;
    gap: 20px;
    align-items: center;
    margin-top: 0;
}

/* Tighter spacing for radio questions */
.form-section.radio-question .form-section-title,
.additional-fields .form-row .form-section.radio-question .form-section-title {
    margin-bottom: 9px;
}

.additional-fields .form-row .form-section.radio-question {
    justify-content: flex-start;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text-color);
    cursor: pointer;
}

.radio-label input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
}

/* Checkbox Group */
.checkbox-section {
    display: flex;
    gap: 40px;
    padding: 20px 0;
    border-top: 1px solid var(--border-color);
    margin-top: 20px;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-group-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 4px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-color);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
}

/* Description Section Header */
.description-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 8px;
}

.description-instruction {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Map Undo/Redo Controls */
.map-undo-redo {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    gap: 4px;
    z-index: 100;
}

/* Hide undo/redo when placeholder is visible */
.map-placeholder:not(.hidden) ~ .map-undo-redo {
    display: none;
}

.undo-redo-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-muted);
    transition: all 0.15s;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.undo-redo-btn:hover {
    background: var(--bg-color);
    color: var(--text-color);
}

.undo-redo-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Transform Controls - appears around selected elements */
.transform-controls {
    position: absolute;
    z-index: 10000;
    pointer-events: none;
    overflow: visible;
}

.transform-controls.hidden {
    display: none;
}

.transform-btn {
    position: absolute;
    width: 36px;
    height: 36px;
    border: none;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-muted);
    transition: all 0.15s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    pointer-events: auto;
}

.transform-btn:hover {
    background: var(--bg-color);
    color: var(--text-color);
    transform: scale(1.1);
}

.transform-up {
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
}

.transform-up:hover {
    transform: translateX(-50%) scale(1.1);
}

.transform-down {
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
}

.transform-down:hover {
    transform: translateX(-50%) scale(1.1);
}

.transform-left {
    left: -50px;
    top: 50%;
    transform: translateY(-50%);
}

.transform-left:hover {
    transform: translateY(-50%) scale(1.1);
}

.transform-right {
    right: -50px;
    top: 50%;
    transform: translateY(-50%);
}

.transform-right:hover {
    transform: translateY(-50%) scale(1.1);
}

.transform-actions {
    position: absolute;
    bottom: -90px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    pointer-events: auto;
}

.transform-actions .transform-btn {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    bottom: auto;
    transform: none;
}

.transform-rotate-left,
.transform-rotate-right {
    background: var(--primary-color);
    color: white;
    border-radius: 4px;
}

.transform-rotate-left:hover,
.transform-rotate-right:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

.transform-delete {
    background: #ef4444;
    color: white;
    border-radius: 4px;
    font-size: 14px;
}

.transform-delete:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.transform-confirm {
    background: #22c55e;
    color: white;
    border-radius: 6px;
}

.transform-confirm:hover {
    background: #16a34a;
    transform: scale(1.1);
}

.transform-edit {
    background: transparent;
    font-size: 16px;
}

.transform-edit:hover {
    background: rgba(59, 130, 246, 0.2);
    transform: scale(1.1);
}

/* Color Picker Group */
.color-picker-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.color-picker-group input[type="color"] {
    width: 50px;
    height: 36px;
    padding: 2px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
}

.color-presets {
    display: flex;
    gap: 6px;
}

.color-preset {
    width: 28px;
    height: 28px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
}

.color-preset:hover {
    transform: scale(1.15);
    border-color: var(--text-color);
}

.color-preset[data-color="#214ca0"] { background: #214ca0; }
.color-preset[data-color="#ef4444"] { background: #ef4444; }
.color-preset[data-color="#22c55e"] { background: #22c55e; }
.color-preset[data-color="#f97316"] { background: #f97316; }
.color-preset[data-color="#8b5cf6"] { background: #8b5cf6; }
.color-preset[data-color="#6b7280"] { background: #6b7280; }

/* Marker Info Window */
.marker-info-window {
    max-width: 250px;
    padding: 4px;
}

.marker-info-window strong {
    display: block;
    font-size: 14px;
    color: #1f2937;
    margin-bottom: 6px;
}

.marker-info-window p {
    font-size: 13px;
    color: #4b5563;
    margin: 0;
    line-height: 1.4;
}

/* Map Hint - right click instruction */
.map-hint {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 100;
    pointer-events: none;
    animation: fadeInUp 0.3s ease-out;
}

.map-hint.hidden {
    display: none;
}

.hint-icon {
    font-size: 14px;
}

.hint-text {
    white-space: nowrap;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Map Context Menu - right click dropdown */
.map-context-menu {
    position: fixed;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    min-width: 160px;
    z-index: 1000;
    overflow: hidden;
    animation: contextMenuIn 0.15s ease-out;
}

.map-context-menu.hidden {
    display: none;
}

@keyframes contextMenuIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.context-menu-title {
    padding: 10px 14px 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: none;
    font-size: 14px;
    color: var(--text-color);
    cursor: pointer;
    transition: background 0.1s;
    text-align: left;
}

.context-menu-item:hover {
    background: var(--bg-color);
}

.context-menu-item:active {
    background: var(--border-color);
}

.menu-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.menu-label {
    flex: 1;
}

/* Diagram Action Buttons */
.diagram-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    padding-top: 0;
}

.btn-accept {
    background: var(--primary-color);
    color: white;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
}

.btn-accept:hover {
    background: var(--primary-hover);
}

.btn-accept .btn-icon {
    font-size: 16px;
}

.btn-outline {
    background: white;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
}

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

/* Selection Box for Diagram Elements */
.diagram-selection-box {
    border: 2px dashed var(--client-color);
    background: rgba(220, 38, 38, 0.05);
    pointer-events: none;
}

/* Additional Form Fields Section */
.additional-fields {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.additional-fields .form-row {
    margin-bottom: 20px;
    align-items: stretch;
}

.additional-fields .form-row .form-section:first-child {
    flex: 1;
}

.additional-fields .form-row .form-section {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.additional-fields .form-row .form-section .form-section-title {
    margin-bottom: 4px;
    flex-shrink: 0;
}

.additional-fields .form-row .form-input,
.additional-fields .form-row .form-select,
.additional-fields .form-row .tag-input-container {
    margin-top: auto;
}


/* Form Select Styling */
.form-select {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    cursor: pointer;
    transition: border-color 0.15s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

/* Tag Input Container */
.tag-input-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    min-height: 44px;
    transition: border-color 0.15s;
}

.tag-input-container:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--primary-color);
    color: white;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
}

.tag-item .tag-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    color: white;
    transition: background 0.15s;
}

.tag-item .tag-remove:hover {
    background: rgba(255, 255, 255, 0.4);
}

.tag-input {
    flex: 1;
    min-width: 120px;
    border: none;
    outline: none;
    font-size: 14px;
    font-family: inherit;
    background: transparent;
    padding: 4px 0;
}

.tag-input::placeholder {
    color: var(--text-muted);
}

/* Tag Suggestions */
.tag-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.tag-suggestion {
    padding: 6px 12px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 13px;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.15s;
}

.tag-suggestion:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}


/* Responsive */
@media (max-width: 768px) {
    .split-pane {
        flex-direction: column;
    }

    .panel-left {
        width: 100%;
        max-width: none;
        min-width: auto;
        height: 50%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .panel-right {
        min-width: auto;
    }

    .resize-handle {
        width: 100%;
        height: 6px;
        cursor: row-resize;
    }

    .header-actions {
        gap: 4px;
    }

    .btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    .btn span:not(.icon) {
        display: none;
    }

    .form-row {
        flex-direction: column;
        gap: 16px;
    }

    .form-row .form-section:first-child {
        flex: 1;
    }

    .checkbox-section {
        flex-direction: column;
        gap: 20px;
    }

    .diagram-actions {
        flex-direction: column;
    }

    .legend-items-grid {
        grid-template-columns: 1fr;
    }
}