/* ==========================================================================
   ESTILOS GENERALES Y MAPA
   ========================================================================== */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #0d1117;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#map {
    width: 100vw;
    height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* Lupa Activa */
.lupa-activa {
    background-color: #00f3ff !important;
    color: #111 !important;
    box-shadow: 0 0 10px #00f3ff !important;
}

/* ==========================================================================
   MÓDULO DE AUTENTICACIÓN (LOGIN) - CONFIGURACIÓN PANTALLA COMPLETA TOTAL
   ========================================================================== */
#login-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    background: url('SPIDERR.jpg') no-repeat center center / cover;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999 !important;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.login-card {
    background: rgba(13, 17, 23, 0.95);
    border: 1px solid #00f3ff;
    box-shadow: 0 0 30px rgba(0, 243, 255, 0.25);
    border-radius: 12px;
    padding: 30px;
    width: 320px;
    color: #c9d1d9;
    backdrop-filter: blur(8px);
}

.login-card h2 {
    margin-top: 0;
    margin-bottom: 24px;
    color: #00f3ff;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-size: 18px;
    font-weight: bold;
}

.login-group {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}

.login-group label {
    font-size: 11px;
    color: #8b949e;
    text-transform: uppercase;
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

.login-group input {
    background: #0d1117;
    border: 1px solid #30363d;
    color: #f0f6fc;
    padding: 10px;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.login-group input:focus {
    border-color: #00f3ff;
}

.btn-login {
    width: 100%;
    background: #238636;
    color: #ffffff;
    border: 1px solid #2ea44f;
    padding: 10px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
    margin-top: 8px;
}

.btn-login:hover {
    background: #2ea44f;
    box-shadow: 0 0 10px rgba(46, 164, 79, 0.4);
}

.login-error {
    color: #f85149;
    font-size: 12px;
    text-align: center;
    margin-top: 12px;
    font-weight: 600;
}

/* ==========================================================================
   ESTILOS DE LA BARRA SUPERIOR E INTEGRACIÓN DE MENÚS
   ========================================================================== */
.top-menu-container {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.tactical-top-bar {
    pointer-events: auto;
    display: flex;
    gap: 8px;
    background: rgba(13, 17, 23, 0.9);
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid #00f3ff;
    box-shadow: 0 0 20px rgba(0, 243, 255, 0.3);
    backdrop-filter: blur(8px);
}

.top-bar-btn {
    background: #21262d;
    color: #ffffff;
    border: 1px solid #30363d;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 5px;
}

.top-bar-btn:hover {
    background: #161b22;
    border-color: #00f3ff;
    box-shadow: 0 0 8px rgba(0, 243, 255, 0.5);
    color: #00f3ff;
}

.top-bar-btn.active {
    background: #161b22;
    border-color: #00f3ff;
    color: #00f3ff;
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.4);
}

#mod-action-reset:hover {
    border-color: #f85149;
    box-shadow: 0 0 8px rgba(248, 81, 73, 0.5);
    color: #f85149;
}

#mod-action-logout:hover {
    border-color: #f85149;
    box-shadow: 0 0 8px rgba(248, 81, 73, 0.5);
    color: #f85149;
}

/* ==========================================================================
   DROPDOWN DEL PANEL TÁCTICO (ESTILO HUD MILITAR INTEGRADO)
   ========================================================================== */
.tactical-panel {
    pointer-events: auto;
    background: rgba(13, 17, 23, 0.95);
    color: #c9d1d9;
    padding: 16px;
    border-radius: 12px;
    width: 300px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 1px #30363d inset;
    border: 1px solid #30363d;
    user-select: none;
    backdrop-filter: blur(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tactical-panel:focus-within {
    border-color: #00f3ff;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 8px;
    border-bottom: 1px solid #21262d;
}

.panel-header h3 {
    margin: 0;
    font-size: 13px;
    color: #00f3ff;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: bold;
}

.btn-minimize {
    background: transparent;
    border: none;
    color: #8b949e;
    font-size: 16px;
    cursor: pointer;
    font-weight: bold;
    padding: 0 5px;
    line-height: 1;
    transition: color 0.2s ease;
}

.btn-minimize:hover {
    color: #f85149;
}

hr {
    border: 0;
    height: 1px;
    background: #21262d;
    margin: 12px 0;
}

.panel-group {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
}

.panel-group label {
    font-size: 11px;
    margin-bottom: 6px;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.panel-group select, 
.panel-group input[type="number"] {
    background: #0d1117;
    border: 1px solid #30363d;
    color: #f0f6fc;
    padding: 8px;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease;
}

.panel-group select:focus, 
.panel-group input[type="number"]:focus {
    border-color: #00f3ff;
}

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-picker-wrapper input[type="color"] {
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    background: none;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch {
    border: 2px solid #30363d;
    border-radius: 50%;
}

.checkbox-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

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

.d-none {
    display: none !important;
}

.layer-radio-option {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    cursor: pointer;
}

.layer-radio-option input[type="radio"] {
    cursor: pointer;
    accent-color: #00f3ff;
    width: 16px;
    height: 16px;
}

.layer-radio-option label {
    font-size: 13px;
    color: #f0f6fc;
    cursor: pointer;
    margin: 0;
    text-transform: none;
    letter-spacing: normal;
}

.sub-panel {
    background: rgba(22, 27, 34, 0.6);
    padding: 12px;
    border-radius: 8px;
    border: 1px dashed rgba(0, 243, 255, 0.4);
    margin-top: 10px;
}

.sub-label {
    font-size: 11px;
    color: #00f3ff;
    display: block;
    margin-bottom: 8px;
    text-transform: uppercase;
    font-weight: 600;
}

.file-uploader-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.btn-tactical-file {
    background: #21262d;
    color: #00f3ff;
    border: 1px solid #30363d;
    padding: 8px 12px;
    font-weight: bold;
    font-size: 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-grow: 1;
}

.btn-tactical-file:hover {
    background: #00f3ff;
    color: #0d1117;
    box-shadow: 0 0 8px rgba(0, 243, 255, 0.4);
}

#fence-preview-img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
}

#fence-file-name {
    font-size: 10px;
    color: #8b949e;
    display: block;
    margin-top: 6px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.input-row {
    display: flex;
    gap: 8px;
}

.input-col {
    display: flex;
    flex-direction: column;
    width: 50%;
}

.btn-save-tactical {
    width: 100%;
    background: #238636;
    color: #ffffff;
    border: 1px solid #2ea44f;
    padding: 10px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    font-size: 13px;
    margin-top: 8px;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-save-tactical:hover {
    background: #2ea44f;
    box-shadow: 0 0 10px rgba(46, 164, 79, 0.4);
}

.preset-preview-container {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0d1117;
    padding: 8px;
    border: 1px solid #30363d;
    border-radius: 6px;
    margin-top: 8px;
    gap: 10px;
}

/* ==========================================================================
   PANELES INTERACTIVOS EN EL MAPA (ANOTACIONES)
   ========================================================================== */
.custom-map-annotation-resizable {
    background: transparent !important;
    border: none !important;
    position: absolute;
}

.resizable-image-box-controlled {
    border: 2px dashed transparent;
    padding: 0px;
    background: transparent !important;
    resize: both;
    overflow: hidden; 
    min-width: 40px;
    min-height: 40px;
    border-radius: 6px;
    backdrop-filter: none !important;
    transition: border-color 0.2s ease, transform 0.1s ease-out;
    transform-origin: 0 0;
}

.resizable-text-box-controlled {
    border: 2px dashed transparent;
    padding: 4px;
    background: transparent !important;
    resize: both;
    overflow: hidden; 
    min-width: 80px;
    min-height: 50px;
    border-radius: 6px;
    backdrop-filter: none;
    transition: all 0.2s ease, transform 0.1s ease-out;
    transform-origin: 0 0;
}

body.show-controls .custom-map-annotation-resizable:hover .resizable-image-box-controlled,
body.show-controls .custom-map-annotation-resizable.selected-annotation .resizable-image-box-controlled {
    border-color: rgba(0, 243, 255, 0.5);
}

body.show-controls .custom-map-annotation-resizable:hover .resizable-text-box-controlled,
body.show-controls .custom-map-annotation-resizable.selected-annotation .resizable-text-box-controlled {
    border-color: rgba(0, 243, 255, 0.5);
    background: rgba(13, 17, 23, 0.8) !important;
    backdrop-filter: blur(4px);
}

body:not(.show-controls) .resizable-image-box-controlled,
body:not(.show-controls) .resizable-text-box-controlled {
    resize: none !important;
    border: none !important;
}

.tactical-img-target {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.2s ease-in-out;
}

.tactical-textarea-target {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    color: #f0f6fc;
    font-family: inherit;
    font-size: 13px;
    resize: none;
    outline: none;
    text-shadow: 1px 1px 2px #000;
}

.annotation-action-bar {
    position: absolute;
    top: -28px;
    left: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(13, 17, 23, 0.95);
    padding: 3px;
    border-radius: 6px;
    border: 1px solid #30363d;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform: translateY(5px);
}

body.show-controls .custom-map-annotation-resizable:hover .annotation-action-bar,
body.show-controls .custom-map-annotation-resizable.selected-annotation .annotation-action-bar {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.btn-annotation-action {
    background: #21262d;
    color: #f0f6fc;
    border: 1px solid #30363d;
    padding: 2px 8px;
    font-size: 11px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.1s ease;
}

.btn-annotation-action:hover {
    background: #30363d;
    color: #ffffff;
}

.btn-annotation-action.btn-rot {
    background: rgba(189, 0, 255, 0.2);
    border-color: #bd00ff;
    color: #df80ff;
}

.btn-annotation-action.btn-rot:hover {
    background: #bd00ff;
    color: #ffffff;
}

.btn-annotation-action.btn-del {
    background: rgba(248, 81, 73, 0.15);
    border-color: #f85149;
    color: #ff7b72;
}

.btn-annotation-action.btn-del:hover {
    background: #f85149;
    color: #ffffff;
}

.annotation-text-color {
    background: none;
    border: 1px solid #30363d;
    width: 22px;
    height: 20px;
    padding: 0;
    cursor: pointer;
    border-radius: 4px;
}

.annotation-text-size {
    background: #21262d;
    color: #f0f6fc;
    border: 1px solid #30363d;
    border-radius: 4px;
    font-size: 11px;
    padding: 2px 4px;
    cursor: pointer;
    outline: none;
}

/* ==========================================================================
   SISTEMA DE NOTIFICACIONES TOAST (HUD)
   ========================================================================== */
.tactical-toast {
    position: absolute;
    bottom: 30px;
    right: 30px;
    z-index: 2000;
    background: rgba(13, 17, 23, 0.95);
    border-left: 4px solid #00f3ff;
    color: #f0f6fc;
    padding: 12px 20px;
    border-radius: 6px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translateY(150%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}

.tactical-toast.show {
    transform: translateY(0);
}

.tactical-toast.toast-error {
    border-left-color: #f85149;
}

/* ==========================================================================
   MODO EXPORTACIÓN LIMPIO
   ========================================================================== */
body.exporting .tactical-top-bar,
body.exporting .tactical-panel,
body.exporting .leaflet-control-zoom,
body.exporting .leaflet-control-geocoder,
body.exporting .leaflet-control-attribution,
body.exporting .leaflet-bar,
body.exporting .leaflet-control-draw,
body.exporting .annotation-action-bar {
    display: none !important;
}

body.exporting {
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

.leaflet-control-zoom {
    z-index: 2000 !important;
    pointer-events: auto !important;
}

.leaflet-control-zoom-out {
    pointer-events: auto !important;
    cursor: pointer !important;
}

.custom-zoom-controls {
    position: absolute;
    top: 80px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.custom-zoom-controls button {
    width: 30px;
    height: 30px;
    background: white;
    border: 1px solid #ccc;
    cursor: pointer;
    font-weight: bold;
}

/* ==========================================================================
   CONTROL VISUAL DE LOS DOS BOTONES DE SIMULACIÓN INDEPENDIENTES
   ========================================================================== */
/* Hover forzado para el botón Iniciar */
#btn-run-simulation:hover {
    background: #2ea44f !important;
    border-color: #3fb950 !important;
}

/* Hover forzado para el botón Parar */
#btn-stop-simulation:hover {
    background: #bd3a3a !important;
    border-color: #e55353 !important;
}

/* Cuando el sistema entra en modo exportación, ocultamos los tiradores manuales */
body.exporting .resizer-handle-manual,
body.exporting .annotation-action-bar {
    display: none !important;
}

/* Opcional: Oculta el recuadro dashed cian para que el avión quede 100% limpio en el PDF */
body.exporting .resizable-image-box-controlled {
    border: none !important;
}


/* 1. PERMITE COMPACTAR EL TEXTO HACIA ARRIBA (Quita la restricción de altura mínima) */
.resizable-text-box-controlled,
.tactical-textarea-target {
    min-height: 0px !important;
    min-width: 0px !important;
}

/* 2. EVITA QUE EL TEXTO SE CORTE O DESBORDE EN EL CLON DEL PDF */
body.exporting .tactical-textarea-target {
    overflow: hidden !important;
    height: 100% !important;
    width: 100% !important;
}