* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

:root {
    --primary-color: #2196F3;
    --secondary-color: #757575;
    --danger-color: #dc3545;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --background-color: #ffffff;
    --text-color: #333333;
    --border-radius: 8px;
    --transition-speed: 0.3s;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
}

body {
    color: var(--text-color);
    background-color: #f9f9f9;
}

.container {
    max-width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

header p {
    font-size: 0.9rem;
    opacity: 0.9;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

#map-container {
    position: relative;
    flex: 1;
    width: 100%;
    height: 100%;
    min-height: 400px;
}

#map {
    width: 100%;
    height: 100%;
    min-height: 400px;
    z-index: 1;
}

.info-panel {
    background-color: var(--secondary-color);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.05);
}

.measurements {
    display: flex;
    gap: 2rem;
    margin-bottom: 1rem;
}

.measurement {
    display: flex;
    flex-direction: column;
}

.measurement span:first-child {
    font-weight: bold;
    font-size: 0.9rem;
    color: #666;
}

.measurement span:last-child {
    font-size: 1.2rem;
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

#reset-btn {
    background-color: #f44336;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

#reset-btn:hover {
    background-color: #d32f2f;
}

#save-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

#save-btn:hover {
    background-color: var(--primary-dark);
}

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

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 2000;
    opacity: 0;
    transition: opacity var(--transition-speed);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

.modal-content {
    background-color: var(--background-color);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-width: 500px;
    width: 90%;
    transform: translateY(20px);
    transition: transform var(--transition-speed);
}

.modal.active .modal-content {
    transform: translateY(0);
}

.modal h2 {
    margin: 0 0 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-color);
}

.modal h2 i {
    color: var(--primary-color);
}

.modal p {
    margin: 0 0 1rem 0;
    color: var(--secondary-color);
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    justify-content: flex-end;
}

.modal-buttons button,
.modal-buttons .whatsapp-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    transition: all var(--transition-speed);
}

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

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

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

.whatsapp-btn {
    background-color: #25D366;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    display: inline-block;
    text-decoration: none;
    text-align: center;
    transition: background-color 0.3s;
}

.whatsapp-btn:hover {
    background-color: #128C7E;
}

.whatsapp-btn::before {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-right: 8px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'%3E%3Cpath fill='white' d='M380.9 97.1C339 55.1 283.2 32 223.9 32c-122.4 0-222 99.6-222 222 0 39.1 10.2 77.3 29.6 111L0 480l117.7-30.9c32.4 17.7 68.9 27 106.1 27h.1c122.3 0 224.1-99.6 224.1-222 0-59.3-25.2-115-67.1-157zm-157 341.6c-33.2 0-65.7-8.9-94-25.7l-6.7-4-69.8 18.3L72 359.2l-4.4-7c-18.5-29.4-28.2-63.3-28.2-98.2 0-101.7 82.8-184.5 184.6-184.5 49.3 0 95.6 19.2 130.4 54.1 34.8 34.9 56.2 81.2 56.1 130.5 0 101.8-84.9 184.6-186.6 184.6zm101.2-138.2c-5.5-2.8-32.8-16.2-37.9-18-5.1-1.9-8.8-2.8-12.5 2.8-3.7 5.6-14.3 18-17.6 21.8-3.2 3.7-6.5 4.2-12 1.4-32.6-16.3-54-29.1-75.5-66-5.7-9.8 5.7-9.1 16.3-30.3 1.8-3.7.9-6.9-.5-9.7-1.4-2.8-12.5-30.1-17.1-41.2-4.5-10.8-9.1-9.3-12.5-9.5-3.2-.2-6.9-.2-10.6-.2-3.7 0-9.7 1.4-14.8 6.9-5.1 5.6-19.4 19-19.4 46.3 0 27.3 19.9 53.7 22.6 57.4 2.8 3.7 39.1 59.7 94.8 83.8 35.2 15.2 49 16.5 66.6 13.9 10.7-1.6 32.8-13.4 37.4-26.4 4.6-13 4.6-24.1 3.2-26.4-1.3-2.5-5-3.9-10.5-6.6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
}

#measurement-uid {
    display: inline-block;
    background-color: #f0f0f0;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-family: monospace;
    margin: 0.5rem 0 1.5rem;
}

#loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
    z-index: 3000;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

#loading-overlay.active {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Paneles */
.panel {
    background-color: var(--background-color);
    padding: 1rem;
    margin: 0.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.panel h2 {
    margin-top: 0;
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 15px;
}

.instructions {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 15px;
}

/* Estilos para el contenedor de búsqueda y sugerencias */
#search-container {
    position: relative;
    margin-bottom: 15px;
    display: flex;
}

#address-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px 0 0 4px;
    font-size: 14px;
}

#search-btn {
    padding: 10px 15px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    font-size: 14px;
}

#search-btn:hover {
    background-color: #45a049;
}

/* Estilos para el contenedor de sugerencias */
.suggestions-container {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    margin-top: -1px;
}

/* Estilos para los items de sugerencias */
.suggestion-item {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.suggestion-item:hover {
    background-color: #f5f5f5;
}

/* Botones */
.button-container {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.primary-btn {
    background-color: #3388ff;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.primary-btn:hover {
    background-color: #2777ee;
}

.secondary-btn {
    background-color: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
}

.secondary-btn:hover {
    background-color: #e9e9e9;
}

/* Estilos para el menú de dibujo personalizado */
.custom-draw-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(5px);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-20px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.custom-draw-controls.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-draw-actions {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.custom-draw-actions li {
    margin: 0;
}

.custom-draw-actions button {
    width: 100%;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    color: white;
}

.custom-draw-actions .action-save {
    background-color: #4CAF50;
}

.custom-draw-actions .action-reset {
    background-color: #FF9800;
}

.custom-draw-actions .action-delete-last {
    background-color: #2196F3;
}

.custom-draw-actions .action-cancel {
    background-color: #f44336;
}

.custom-draw-actions button:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.custom-measurements {
    padding: 10px;
    background-color: #f8f8f8;
    border-top: 1px solid rgba(0,0,0,0.1);
    border-radius: 4px;
    margin-top: 1rem;
}

.custom-measurements p {
    margin: 5px 0;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.custom-measurements span {
    font-weight: bold;
    color: #2196F3;
}

/* Ocultar el panel de dibujo original */
#drawing-panel {
    display: none;
}

/* Responsive */
@media (max-width: 768px) {
    .info-panel {
        flex-direction: column;
        gap: 1rem;
    }
    
    .measurements {
        width: 100%;
        justify-content: space-around;
    }
    
    button {
        width: 100%;
    }
}

/* Mejoras generales de responsividad */
@media (max-width: 768px) {
    /* Ajustes para el encabezado */
    header h1 {
        font-size: 1.3rem;
        margin-bottom: 0.3rem;
    }
    
    header p {
        font-size: 0.8rem;
    }
    
    /* Ajustes para el panel de ubicación */
    #location-panel {
        padding: 10px;
        margin-bottom: 10px;
    }
    
    #location-panel h2 {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }
    
    #search-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    #address-input {
        width: 100%;
        margin-bottom: 5px;
    }
    
    #search-btn {
        width: 100%;
        margin-left: 0;
    }
    
    .instructions {
        font-size: 0.8rem;
        margin: 5px 0;
    }
    
    /* Ajustes para el mapa */
    #map {
        height: calc(100vh - 180px);
        min-height: 300px;
    }
    
    /* Ajustes para el panel de confirmación */
    #confirmation-panel {
        padding: 10px;
    }
    
    #confirmation-panel h2 {
        font-size: 1.1rem;
    }
    
    #confirmation-panel .button-container button {
        padding: 8px 15px;
        font-size: 0.9rem;
    }
    
    /* Ajustes para el panel de medición */
    .custom-draw-controls {
        top: auto;
        bottom: 90px;
        right: 20px;
        left: 20px;
    }
    
    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }
    
    .modal-buttons {
        flex-direction: column;
    }
    
    .modal-buttons button,
    .modal-buttons .whatsapp-btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Ajustes para los controles de Leaflet */
    .leaflet-control-zoom {
        margin: 5px !important;
    }
    
    .leaflet-control-zoom a {
        width: 28px !important;
        height: 28px !important;
        line-height: 28px !important;
    }
    
    .leaflet-draw-toolbar a {
        width: 28px !important;
        height: 28px !important;
    }
}

/* Ajustes para pantallas muy pequeñas */
@media (max-width: 360px) {
    header h1 {
        font-size: 1.2rem;
    }
    
    .panel {
        padding: 8px;
    }
    
    #map {
        height: calc(100vh - 160px);
    }
    
    .custom-draw-controls {
        max-width: 120px;
    }
    
    .custom-draw-actions a {
        font-size: 11px;
        min-width: 100px;
        padding: 0 5px;
    }
    
    /* Ajustar tamaño de los botones para evitar solapamientos */
    .leaflet-control-zoom a,
    .leaflet-draw-toolbar a {
        width: 26px !important;
        height: 26px !important;
        line-height: 26px !important;
    }
}

/* Ajustes para orientación horizontal en móviles */
@media (max-height: 500px) and (orientation: landscape) {
    header {
        padding: 5px 0;
    }
    
    header h1 {
        font-size: 1.1rem;
        margin-bottom: 0;
    }
    
    header p {
        display: none; /* Ocultar descripción para ahorrar espacio */
    }
    
    #location-panel, #drawing-panel {
        padding: 5px;
        margin-bottom: 5px;
    }
    
    #location-panel h2, #drawing-panel h2 {
        font-size: 1rem;
        margin: 0 0 5px 0;
    }
    
    #map {
        height: calc(100vh - 120px);
    }
    
    .custom-draw-controls {
        top: 10px;
        right: 10px;
        transform: none;
        max-height: 80vh;
        overflow-y: auto;
    }
    
    .custom-draw-actions a {
        line-height: 32px;
        height: 32px;
    }
    
    /* Ajustar posición de los controles para evitar solapamientos */
    .leaflet-top.leaflet-left {
        top: 10px;
    }
    
    .leaflet-top.leaflet-right {
        top: 10px;
    }
}

/* Ajustes para tablets */
@media (min-width: 769px) and (max-width: 1024px) {
    .custom-draw-controls {
        right: 15px;
    }
    
    #map {
        height: calc(100vh - 200px);
    }
}

/* Estilo para la nube tipo Mario Bros */
.mario-cloud {
    position: absolute;
    background-color: white;
    border-radius: 20px;
    padding: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    border: 2px solid #88c1ff;
    z-index: 1000;
    max-width: 250px;
    text-align: center;
    animation: float 2s ease-in-out infinite;
    pointer-events: none; /* Para que no interfiera con los clics en el mapa */
}

.mario-cloud::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-top: 15px solid white;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.1));
}

.mario-cloud p {
    margin: 0;
    font-size: 14px;
    color: #333;
}

.mario-cloud strong {
    color: var(--primary-color);
    font-weight: bold;
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
    100% {
        transform: translateY(0px);
    }
}

/* Animación para el botón de dibujar polígono */
.highlight-button {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(51, 136, 255, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(51, 136, 255, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(51, 136, 255, 0);
    }
}

/* Estilos para los botones personalizados en el menú de dibujo */
.leaflet-draw-action-save a {
    background-color: #4CAF50;
    color: white !important;
}

.leaflet-draw-action-save a:hover {
    background-color: #45a049;
}

.leaflet-draw-action-reset a {
    background-color: #f44336;
    color: white !important;
}

.leaflet-draw-action-reset a:hover {
    background-color: #d32f2f;
}

.leaflet-draw-action-finish a {
    background-color: #2196F3;
    color: white !important;
}

.leaflet-draw-action-finish a:hover {
    background-color: #0b7dda;
}

.leaflet-draw-action-delete-last a {
    background-color: #ff9800;
    color: white !important;
}

.leaflet-draw-action-delete-last a:hover {
    background-color: #e68a00;
}

.leaflet-draw-action-cancel a {
    background-color: #9e9e9e;
    color: white !important;
}

.leaflet-draw-action-cancel a:hover {
    background-color: #7d7d7d;
}

/* Asegurar que los botones personalizados tengan el mismo estilo base que los originales */
.leaflet-draw-action-save,
.leaflet-draw-action-reset,
.leaflet-draw-action-finish,
.leaflet-draw-action-delete-last,
.leaflet-draw-action-cancel {
    display: block;
}

.leaflet-draw-action-save a,
.leaflet-draw-action-reset a,
.leaflet-draw-action-finish a,
.leaflet-draw-action-delete-last a,
.leaflet-draw-action-cancel a {
    display: block;
    text-align: center;
    text-decoration: none;
    font-size: 12px;
    line-height: 30px;
    height: 30px;
    padding: 0 10px;
    border-bottom: 1px solid #ccc;
}

/* Botón grande para activar el modo dibujo */
.draw-mode-button {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background-color: #fff;
    border: 2px solid #ccc;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 1000;
    transition: all 0.3s ease;
}

.draw-mode-button:hover {
    background-color: #f0f0f0;
    transform: scale(1.1);
}

.draw-mode-button.active {
    background-color: #4CAF50;
    border-color: #4CAF50;
    color: white;
}

.draw-mode-button i {
    font-size: 20px;
}

/* Ocultar controles de Leaflet.draw por defecto */
.leaflet-draw {
    display: none;
}

.input-container {
    position: relative;
    margin: 1rem 0;
}

.input-container input {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
}

.input-container .unit {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
}

.error-message {
    color: var(--danger-color);
    font-size: 0.9rem;
    margin-top: 0.5rem;
    display: none;
}

.error-message.active {
    display: block;
}

/* Panel de ubicación flotante */
.floating-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(5px);
    min-width: 250px;
    z-index: 1000;
    transition: all 0.3s ease;
}

.location-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.location-header i {
    color: #3388ff;
    font-size: 1.2rem;
}

.location-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #333;
}

#search-container {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

#address-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

#search-btn {
    background-color: #3388ff;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

#search-btn:hover {
    background-color: #2777ee;
}

.instructions {
    font-size: 0.8rem;
    color: #666;
    margin: 0;
    font-style: italic;
}

/* Ajustes responsivos */
@media (max-width: 768px) {
    .floating-panel {
        top: 10px;
        left: 10px;
        right: 10px;
        min-width: auto;
    }
    
    #search-container {
        flex-direction: column;
    }
    
    #search-btn {
        width: 100%;
    }
}
