body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
}

* {
    -webkit-tap-highlight-color: transparent;
}

#map {
    height: 100vh;
    width: 100vw;
}

#ui-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(4px);
    padding: 5px 10px;
    border-radius: 8px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 8px;
}

#user-info {
    font-weight: bold;
    font-size: 14px;
    color: #333;
}

#user-info:empty {
    display: none;
}

#draw-overlay, #surface-overlay {
    position: absolute;
    top: 50px;
    right: 10px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    width: 250px;
}

#draw-overlay.hidden, #surface-overlay.hidden {
    display: none;
}

#draw-overlay h4, #surface-overlay h4 {
    margin-top: 0;
}

#draw-overlay select, #surface-overlay select, .input-field {
    width: 100%;
    padding: 8px;
    margin-bottom: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.icon-btn-auth {
    padding: 5px !important;
    font-size: 18px !important;
    line-height: 1;
    min-width: 32px;
    height: 32px;
    background: transparent !important;
    border: none !important;
    border-radius: 50% !important;
    box-shadow: none !important;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, transform 0.1s;
}

.icon-btn-auth:hover {
    background-color: rgba(0, 0, 0, 0.08) !important;
    transform: scale(1.1);
}

.icon-btn-auth.active-mode {
    background-color: rgba(0, 120, 212, 0.22) !important;
    box-shadow: inset 0 0 0 1px rgba(0, 120, 212, 0.5) !important;
}

.mode-indicator {
    font-size: 12px;
    font-weight: 600;
    color: #0b5fff;
    background: rgba(11, 95, 255, 0.1);
    border: 1px solid rgba(11, 95, 255, 0.3);
    border-radius: 6px;
    padding: 4px 6px;
}

.panel {
    position: fixed;
    bottom: -100%;
    left: 0;
    width: 100%;
    height: 50vh;
    background: white;
    z-index: 1001;
    transition: bottom 0.3s ease-in-out;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
}

.panel.open {
    bottom: 0;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 15px; /* Reduced padding from 10px */
    background: #f1f1f1;
}

#panel-title {
    margin: 5px 0;
    font-size: 16px;
}

#panel-handle {
    width: 100%;
    height: 20px;
    cursor: ns-resize;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #e0e0e0;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    user-select: none;
    -webkit-user-select: none;
}

.handle-bar {
    width: 40px;
    height: 5px;
    background-color: #999;
    border-radius: 3px;
}

.panel-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
}

.panel-content h4 {
    margin: 10px 0 5px 0;
}

.control-btns {
    display: flex;
    flex-direction: column;
    margin-bottom: 20px !important;
    margin-right: 10px !important;
    box-shadow: 0 1px 5px rgba(0,0,0,0.65);
    border-radius: 4px;
    background: white;
}

.control-btns a {
    display: block;
    width: 44px;
    height: 44px;
    line-height: 44px;
    text-align: center;
    text-decoration: none;
    font-size: 24px;
    color: #333;
    border-bottom: 1px solid #ccc;
    background: white;
}

.control-btns a:last-child {
    border-bottom: none;
}

.leaflet-control {
    user-select: none;
    -webkit-user-select: none;
}

.layers-control-mobile {
    margin-bottom: 80px !important;
}

.leaflet-control-layers-toggle {
    width: 44px !important;
    height: 44px !important;
    background-image: none !important;
    background-color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border-radius: 4px;
}
.leaflet-control-layers-toggle::after {
    content: "🗺️";
    font-size: 24px;
    display: block;
    line-height: 1;
}

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}

.modal-content {
    background-color: white;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px;
    width: 80%;
    max-width: 400px;
    border-radius: 10px;
    text-align: center;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    margin-top: 0;
}

#login-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#login-form input {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 16px;
}

.btn {
    padding: 10px 15px;
    border: none;
    border-radius: 6px;
    background: #e0e0e0;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    color: #333;
    transition: background 0.2s;
}

.btn:hover {
    background: #d0d0d0;
}

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

.primary-btn:hover {
    background: #0063b1;
}

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

.close-panel-btn {
    padding: 5px 10px;
}

.parcel-main-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    background: #fff;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.icon-btn {
    background: none;
    border: none;
    color: #0078d4;
    cursor: pointer;
    font-size: 14px;
    padding: 5px;
    text-decoration: none;
}

.icon-btn:hover {
    text-decoration: underline;
}

.notes-container {
    overflow-y: auto;
    margin-bottom: 10px;
    padding: 10px;
    background: #fafafa;
    border-radius: 8px;
    border: 1px solid #eee;
}

#individual-notes {
    max-height: none; /* Laisse toujours le conteneur s'étendre, le scroll sera géré par .panel-content si besoin */
    overflow-y: visible;
}

#public-note-section {
    background: #f0f8ff;
    border-left: 4px solid #0078d4;
}

.note {
    background: #fff;
    margin-bottom: 8px;
    padding: 10px;
    border-radius: 6px;
    border-left: 3px solid #d40000;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.private-note {
    border-left-color: #d40000;
}

textarea {
    width: 100%;
    box-sizing: border-box;
    height: 80px;
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-family: inherit;
    resize: vertical;
}

.note-actions {
    display: flex;
    gap: 10px;
}

#add-note-section, #login-prompt {
    display: none;
    margin-top: 10px;
}

.gps-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.geo-info {
    background: white;
    padding: 2px 8px;
    border-radius: 4px;
    margin-bottom: 5px;
    margin-right: 10px;
    font-size: 12px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
    display: none;
}

.offline-badge {
    color: white;
    background-color: #d40000;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 10px;
    margin-right: 5px;
    vertical-align: middle;
}

/* Empêche la sélection de texte pendant le drag */
.no-select, .no-select * {
    user-select: none !important;
    -webkit-user-select: none !important;
}

#legend-overlay {
    position: absolute;
    bottom: 50px;
    left: 10px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    width: 220px;
    max-height: 60vh;
    overflow-y: auto;
}

#legend-overlay.hidden {
    display: none;
}

#catalog-overlay {
    position: absolute;
    top: 50px;
    right: 10px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    width: 280px;
    max-height: 60vh;
    overflow-y: auto;
}

#catalog-overlay.hidden {
    display: none;
}

.catalog-group {
    margin-bottom: 10px;
}

.catalog-group-title {
    font-size: 13px;
    font-weight: bold;
    color: #444;
    margin-bottom: 5px;
}

.catalog-item {
    margin-bottom: 4px;
    background: #f7f7f7;
    border: 1px solid #e2e2e2;
    border-radius: 6px;
    padding: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.catalog-main-btn {
    flex: 1;
    text-align: left;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px 0;
    font-size: 13px;
}

.catalog-main-btn:hover {
    color: #005bb5;
}

.catalog-actions {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.catalog-item:hover {
    background: #eaf2ff;
}

.legend-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.legend-item label {
    display: flex;
    align-items: center;
    font-size: 14px;
    cursor: pointer;
}

.legend-item input {
    margin-right: 8px;
}

.modal-admin {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}

.modal-content-admin {
    background-color: white;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px;
    width: 80%;
    max-width: 400px;
    border-radius: 10px;
    text-align: center;
    max-height: 90vh;
    overflow-y: auto;
}

#admin-form input {
    display: block;
    width: 100%;
    margin-bottom: 12px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
}

.close-btn {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-btn:hover,
.close-btn:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}
