* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #1a1a2e;
    color: #eee;
    height: 100vh;
    overflow: hidden;
}

#app {
    display: flex;
    height: 100vh;
}

#sidebar {
    width: 320px;
    background: #16213e;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border-right: 1px solid #0f3460;
}

h1 {
    font-size: 1.4rem;
    color: #e94560;
    margin-bottom: 8px;
}

.description {
    font-size: 0.9rem;
    color: #aaa;
    line-height: 1.5;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

label {
    font-size: 0.85rem;
    color: #ccc;
    font-weight: 500;
}

input[type="text"],
select {
    padding: 10px 12px;
    border: 1px solid #0f3460;
    border-radius: 6px;
    background: #1a1a2e;
    color: #fff;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

input[type="text"]:focus,
select:focus {
    outline: none;
    border-color: #e94560;
}

.search-box-wrapper {
    position: relative;
}

.search-box {
    display: flex;
    gap: 6px;
}

.search-box input {
    flex: 1;
}

.suggestions-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #1a1a2e;
    border: 1px solid #0f3460;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.suggestions-dropdown.active {
    display: block;
}

.suggestion-item {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    border-bottom: 1px solid #0f3460;
    transition: background 0.15s;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item.selected {
    background: #0f3460;
}

.suggestion-item .suggestion-main {
    color: #fff;
}

.suggestion-item .suggestion-detail {
    color: #888;
    font-size: 0.75rem;
    margin-top: 2px;
}

.icon-btn {
    padding: 10px 14px;
    border: 1px solid #0f3460;
    border-radius: 6px;
    background: #0f3460;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: #1a4a7a;
    border-color: #1a4a7a;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

button {
    padding: 12px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.primary-btn {
    background: #e94560;
    color: white;
}

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

.primary-btn:disabled {
    background: #555;
    cursor: not-allowed;
    opacity: 0.7;
}

.secondary-btn {
    background: #0f3460;
    color: #ccc;
}

.secondary-btn:hover {
    background: #1a4a7a;
    color: #fff;
}

.status-box {
    padding: 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    display: none;
}

.status-box.info {
    background: #0f3460;
    border-left: 3px solid #3498db;
    display: block;
}

.status-box.success {
    background: #0a3d2a;
    border-left: 3px solid #27ae60;
    display: block;
}

.status-box.error {
    background: #3d0a0a;
    border-left: 3px solid #e74c3c;
    display: block;
}

.status-box.warning {
    background: #3d2a0a;
    border-left: 3px solid #f39c12;
    display: block;
}

.results-box {
    background: #1a1a2e;
    border: 1px solid #0f3460;
    border-radius: 6px;
    padding: 12px;
}

.results-box h3 {
    font-size: 0.95rem;
    margin-bottom: 10px;
    color: #e94560;
}

/* Mode tabs */
.mode-tabs {
    display: flex;
    gap: 4px;
    background: #1a1a2e;
    padding: 4px;
    border-radius: 6px;
}

.mode-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #888;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn:hover {
    color: #ccc;
}

.mode-btn.active {
    background: #e94560;
    color: white;
}

/* Statistics */
#results-summary {
    font-size: 0.9rem;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #0f3460;
}

#results-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.stat-item {
    background: #0f3460;
    padding: 10px;
    border-radius: 4px;
    text-align: center;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: bold;
    color: #e94560;
}

.stat-label {
    font-size: 0.7rem;
    color: #888;
    margin-top: 4px;
}

#results-list {
    max-height: 150px;
    overflow-y: auto;
}

.result-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    margin-bottom: 4px;
    background: #1a1a2e;
    border-radius: 4px;
    font-size: 0.8rem;
}

.result-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.result-info {
    flex: 1;
}

.result-area {
    color: #888;
    font-size: 0.7rem;
}

.result-parcel {
    color: #45e991;
    font-size: 0.7rem;
    margin-top: 2px;
}

.result-address {
    color: #aaa;
    font-size: 0.65rem;
    margin-top: 1px;
}

/* Checkbox styling */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.85rem;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #e94560;
    cursor: pointer;
}

/* Parcel options sub-menu */
.parcel-options {
    margin-left: 24px;
    margin-top: 8px;
    padding: 8px 12px;
    background: #1a1a2e;
    border-radius: 4px;
    border-left: 2px solid #45e991;
}

.parcel-options .sub-option {
    font-size: 0.8rem;
    margin-bottom: 6px;
}

.parcel-options .sub-option:last-child {
    margin-bottom: 0;
}

.parcel-options .sub-option span {
    color: #aaa;
}

/* Parcel breakdown display */
.parcel-breakdown-box {
    background: #1a1a2e;
    border: 1px solid #45e991;
    border-radius: 6px;
    padding: 12px;
}

.parcel-breakdown-box h3 {
    font-size: 0.9rem;
    margin-bottom: 10px;
    color: #45e991;
}

#parcel-breakdown-list {
    max-height: 180px;
    overflow-y: auto;
}

.parcel-group {
    padding: 10px;
    margin-bottom: 6px;
    background: #0f3460;
    border-radius: 4px;
    border-left: 3px solid #45e991;
}

.parcel-group.unassigned {
    background: #2a2a3e;
    border-left-color: #888;
}

.parcel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.parcel-id {
    color: #45e991;
    font-weight: 600;
}

.parcel-count {
    color: #e94560;
    font-weight: bold;
}

.parcel-address {
    font-size: 0.75rem;
    color: #888;
    margin-top: 4px;
}

.parcel-owner {
    font-size: 0.75rem;
    color: #aaa;
    margin-top: 2px;
    font-style: italic;
}

/* Enhanced prompt display */
.enhanced-prompt {
    font-size: 0.75rem;
    color: #45e991;
    background: #1a2e1a;
    padding: 6px 10px;
    border-radius: 4px;
    margin-top: 6px;
    border-left: 2px solid #45e991;
    word-wrap: break-word;
}

/* Export controls */
.export-box {
    background: #1a1a2e;
    border: 1px solid #0f3460;
    border-radius: 6px;
    padding: 12px;
}

.export-box h3 {
    font-size: 0.9rem;
    margin-bottom: 10px;
    color: #e94560;
}

.export-buttons {
    display: flex;
    gap: 6px;
}

.export-btn {
    flex: 1;
    padding: 8px 10px;
    background: #0f3460;
    border: 1px solid #1a4a7a;
    border-radius: 4px;
    color: #ccc;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.export-btn:hover {
    background: #1a4a7a;
    color: #fff;
}

/* Session controls */
.session-controls {
    background: #1a1a2e;
    border: 1px solid #0f3460;
    border-radius: 6px;
    padding: 12px;
}

.session-controls h3 {
    font-size: 0.9rem;
    margin-bottom: 10px;
    color: #e94560;
}

.session-buttons {
    display: flex;
    gap: 6px;
}

.session-btn {
    flex: 1;
    padding: 8px 10px;
    background: #0f3460;
    border: 1px solid #1a4a7a;
    border-radius: 4px;
    color: #ccc;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.session-btn:hover:not(:disabled) {
    background: #1a4a7a;
    color: #fff;
}

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

.session-btn.load-btn {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Tool list in instructions */
.tool-list {
    margin: 4px 0 4px 16px;
    list-style: none;
    font-size: 0.75rem;
}

.tool-list li {
    margin: 2px 0;
}

/* Click-to-segment marker */
.click-to-segment-marker {
    background: transparent;
}

.segment-point {
    width: 20px;
    height: 20px;
    background: #e94560;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.instructions {
    background: #1a1a2e;
    border-radius: 6px;
    padding: 12px;
    margin-top: auto;
}

.instructions h3 {
    font-size: 0.9rem;
    color: #e94560;
    margin-bottom: 10px;
}

.instructions ol {
    margin-left: 20px;
    font-size: 0.85rem;
    color: #aaa;
    line-height: 1.8;
}

.instructions .icon {
    display: inline-block;
    background: #0f3460;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.75rem;
}

.credits {
    text-align: center;
    font-size: 0.8rem;
    color: #666;
    padding-top: 12px;
    border-top: 1px solid #0f3460;
}

.credits a {
    color: #e94560;
    text-decoration: none;
}

.credits a:hover {
    text-decoration: underline;
}

/* API URL config */
.api-config {
    background: #1a1a2e;
    border: 1px solid #0f3460;
    border-radius: 6px;
    padding: 12px;
}

.api-url-box {
    display: flex;
    gap: 6px;
}

.api-url-box input {
    flex: 1;
    font-size: 0.8rem;
}

.api-url-box .icon-btn {
    padding: 8px 12px;
    font-size: 0.8rem;
}

.hint {
    color: #666;
    font-size: 0.7rem;
    margin-top: 4px;
}

#map-container {
    flex: 1;
    position: relative;
}

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

#coordinates {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(22, 33, 62, 0.9);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-family: 'Monaco', 'Consolas', monospace;
    color: #aaa;
    z-index: 1000;
}

/* Leaflet customizations */
.leaflet-control-zoom {
    border: none !important;
}

.leaflet-control-zoom a {
    background: #16213e !important;
    color: #fff !important;
    border: 1px solid #0f3460 !important;
}

.leaflet-control-zoom a:hover {
    background: #1a4a7a !important;
}

.leaflet-draw-toolbar a {
    background-color: #16213e !important;
    border-color: #0f3460 !important;
}

.leaflet-draw-actions a {
    background-color: #0f3460 !important;
    color: #fff !important;
}

/* Segment overlay styling */
.segment-overlay {
    fill: rgba(233, 69, 96, 0.4);
    stroke: #e94560;
    stroke-width: 2;
}

/* Selection rectangle styling */
.leaflet-draw-guide-dash {
    stroke: #e94560 !important;
}

/* Loading spinner */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.btn-loading {
    animation: pulse 1.5s infinite;
}

/* Responsive */
@media (max-width: 768px) {
    #app {
        flex-direction: column;
    }

    #sidebar {
        width: 100%;
        height: auto;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid #0f3460;
    }

    #map-container {
        height: 60vh;
    }
}
