:root {
    --color-bg: #f4f5f7;
    --color-header-bg: #1f2a37;
    --color-header-text: #f4f5f7;
    --color-sidebar-bg: #ffffff;
    --color-border: #d9dde3;
    --color-text: #1f2a37;
    --color-text-muted: #5b6572;
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-error-bg: #fdecec;
    --color-error-text: #b3261e;
    --color-danger: #b3261e;
    --sidebar-width: 340px;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
}

body {
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--color-text);
    background: var(--color-bg);
    display: flex;
    flex-direction: column;
}

.app-header {
    background: var(--color-header-bg);
    color: var(--color-header-text);
    padding: 0.75rem 1.25rem;
    flex: 0 0 auto;
}

.app-header h1 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
}

.app-body {
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
}

.sidebar {
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    background: var(--color-sidebar-bg);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 1rem;
    gap: 1.25rem;
}

#map {
    flex: 1 1 auto;
    min-width: 0;
}

.search-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.field {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.field-row {
    display: flex;
    gap: 0.75rem;
}

.field-small {
    flex: 1 1 0;
}

label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

input[type="text"] {
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.95rem;
    width: 100%;
}

input[type="text"]:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: -1px;
}

button {
    padding: 0.55rem 0.75rem;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}

button:hover:not(:disabled) {
    background: var(--color-primary-hover);
}

button:disabled {
    background: #a9b3c1;
    cursor: not-allowed;
}

.suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    margin: 0.2rem 0 0;
    padding: 0;
    list-style: none;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.suggestions li {
    padding: 0.5rem 0.6rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.suggestions li:hover,
.suggestions li.active {
    background: #eef2ff;
}

.suggestions .suggestion-meta {
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

.form-message {
    margin: 0;
    font-size: 0.85rem;
    min-height: 1.1em;
}

.form-message.error {
    color: var(--color-error-text);
    background: var(--color-error-bg);
    padding: 0.5rem 0.6rem;
    border-radius: 6px;
}

.form-message.info {
    color: var(--color-text-muted);
}

.parcelles-panel {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 0;
}

.parcelles-panel h2 {
    font-size: 0.9rem;
    margin: 0;
    color: var(--color-text-muted);
}

.parcelles-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
}

.parcelle-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 0.5rem 0.6rem;
    cursor: pointer;
}

.parcelle-item:hover {
    background: #f8f9fb;
}

.parcelle-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex: 0 0 auto;
}

.parcelle-info {
    flex: 1 1 auto;
    min-width: 0;
}

.parcelle-info .parcelle-title {
    font-weight: 600;
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.parcelle-info .parcelle-sub {
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

.parcelle-remove {
    flex: 0 0 auto;
    background: none;
    color: var(--color-danger);
    font-weight: 700;
    padding: 0.15rem 0.5rem;
}

.parcelle-remove:hover {
    background: var(--color-error-bg);
}

.parcelle-popup h3 {
    margin: 0 0 0.4rem;
    font-size: 0.95rem;
}

.parcelle-popup table {
    border-collapse: collapse;
    font-size: 0.85rem;
}

.parcelle-popup td {
    padding: 0.1rem 0.4rem 0.1rem 0;
    vertical-align: top;
}

.parcelle-popup td:first-child {
    color: var(--color-text-muted);
    white-space: nowrap;
}

@media (max-width: 720px) {
    .app-body {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        flex: 0 0 auto;
        max-height: 45vh;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
    }
}
