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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    color: #333;
}

.hidden {
    display: none !important;
}

/* ===== Search Bar ===== */
#search-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #fff;
    border-bottom: 1px solid #ddd;
    padding: 8px 16px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.search-container {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 10px;
    font-size: 16px;
    pointer-events: none;
}

#search-input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

#search-input:focus {
    border-color: #4a90d9;
}

#search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 8px 8px;
    list-style: none;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    z-index: 1001;
}

#search-results li {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}

#search-results li:last-child {
    border-bottom: none;
}

#search-results li:hover,
#search-results li.active {
    background: #f0f5ff;
}

#search-results li .result-label {
    font-weight: 500;
}

#search-results li .result-context {
    font-size: 12px;
    color: #888;
    margin-top: 2px;
}

/* ===== Main Layout ===== */
#app {
    position: fixed;
    top: 52px;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
}

/* ===== Panel ===== */
#panel {
    width: 320px;
    min-width: 320px;
    background: #fafafa;
    border-right: 1px solid #ddd;
    overflow-y: auto;
    padding: 16px;
}

#panel h3 {
    font-size: 14px;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 16px 0 8px;
}

#panel h3:first-child {
    margin-top: 0;
}

#panel-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: #999;
    padding: 20px;
    line-height: 1.5;
}

#parcel-list {
    list-style: none;
}

#parcel-list li {
    padding: 4px 8px;
    margin: 2px 0;
    background: #e8f0fe;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#parcel-list li .parcel-area {
    color: #666;
    font-family: -apple-system, sans-serif;
}

#area-info {
    margin: 12px 0;
    padding: 10px;
    background: #e8f0fe;
    border-radius: 6px;
    font-size: 15px;
}

#total-area {
    font-weight: 700;
    color: #2563eb;
}

/* ===== Landcover Stats ===== */
#landcover-stats .lc-row {
    display: flex;
    align-items: center;
    margin: 6px 0;
    gap: 8px;
}

#landcover-stats .lc-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

#landcover-stats .lc-bar-container {
    flex: 1;
    height: 20px;
    background: #eee;
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

#landcover-stats .lc-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

#landcover-stats .lc-label {
    width: 110px;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#landcover-stats .lc-value {
    width: 85px;
    text-align: right;
    font-size: 12px;
    color: #666;
    flex-shrink: 0;
}

/* ===== Loading ===== */
#loading-landcover {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    color: #666;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid #ddd;
    border-top: 3px solid #4a90d9;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===== Error ===== */
#landcover-error {
    padding: 10px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    color: #991b1b;
    font-size: 13px;
    margin: 8px 0;
}

/* ===== Button ===== */
.btn-clear {
    width: 100%;
    margin-top: 16px;
    padding: 10px;
    background: #ef4444;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-clear:hover {
    background: #dc2626;
}

/* ===== Address Info ===== */
#address-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 13px;
    color: #92400e;
}

#address-info .address-pin {
    font-size: 16px;
    flex-shrink: 0;
}

#address-info .address-text {
    font-weight: 500;
    word-break: break-word;
}

/* ===== Copropriete Popup ===== */
.copro-popup {
    font-size: 13px;
    line-height: 1.5;
}

.copro-popup .copro-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    color: #7c3aed;
}

.copro-popup .copro-detail {
    color: #555;
    margin: 2px 0;
}

.copro-popup .copro-detail strong {
    color: #333;
}

/* ===== Copropriete Panel ===== */
#copro-info {
    padding: 10px 12px;
    background: #f3e8ff;
    border: 1px solid #d8b4fe;
    border-radius: 6px;
    margin-bottom: 12px;
}

#copro-info h3 {
    margin: 0 0 6px;
}

.copro-panel-name {
    font-weight: 600;
    font-size: 14px;
    color: #7c3aed;
    margin-bottom: 4px;
}

.copro-panel-detail {
    font-size: 13px;
    color: #555;
    margin: 2px 0;
}

.copro-panel-detail strong {
    color: #333;
}

/* ===== Map ===== */
#map {
    flex: 1;
    z-index: 1;
}

/* Leaflet layer control override */
.leaflet-control-layers {
    border-radius: 8px !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
}

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

    #panel {
        width: 100%;
        min-width: 100%;
        max-height: 40vh;
        border-right: none;
        border-top: 1px solid #ddd;
    }
}
