﻿@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

.dp-app-container {
    font-family: 'Roboto', sans-serif;
    display: flex;
    flex-direction: column;
    height: 800px;
    max-width: 100% !important;
    background-color: #f5f5f5;
    position: relative;
    overflow: hidden;
    color: #333 !important;
    border: 1px solid #ddd;
}

.dp-app-container.full-width {
    margin-left: calc(-50vw + 50%) !important;
    margin-right: calc(-50vw + 50%) !important;
    max-width: none !important;
    width: 100vw !important;
    border: none;
    border-radius: 0;
}

/* Header */
.dp-header {
    background-color: #fff;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    z-index: 10;
}

.dp-header-info {
    display: flex;
    flex-direction: column;
}

.dp-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 500;
    color: #333;
}

.dp-subtitle {
    margin: 0;
    font-size: 0.8rem;
    color: #666;
}

.dp-btn-primary {
    background-color: #004a99 !important;
    color: white !important;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.dp-btn-primary:hover {
    background-color: #003a7a;
}

.dp-icon-plus {
    font-size: 1.1rem;
    display: flex;
    align-items: center;
}

/* Main Area */
.dp-main {
    flex: 1;
    position: relative;
    display: flex;
}

.dp-map-container {
    flex: 1;
    height: 100%;
    width: 100%;
    background-color: #e0e0e0; /* Fallback */
}

/* Toolbar */
.dp-toolbar {
    position: absolute;
    left: 15px;
    top: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 5;
}

.dp-toolbar-right {
    position: absolute;
    right: 15px;
    top: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 5;
}

.dp-tool-btn {
    width: 42px;
    height: 42px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: all 0.2s;
}

.dp-tool-btn:hover {
    background-color: #f0f0f0;
}

.dp-tool-btn.is-active,
#dp-tool-map-type.is-active {
    background-color: #1e88e5;
    color: white;
    border-color: #1e88e5;
}

.dp-icon {
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: black;
}

.dp-icon i {
    line-height: 1;
}

/* Sidebar / Drawer */
.dp-sidebar {
    position: absolute;
    left: 65px;
    top: 15px;
    width: 280px;
    background-color: #fff;
    border-radius: 4px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    z-index: 4;
    display: flex;
    flex-direction: column;
    max-height: calc(100% - 30px);
}

.dp-sidebar-right {
    left: auto;
    right: 65px;
}

.dp-sidebar-header {
    background-color: #1e88e5;
    color: white;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
}

.dp-sidebar-header h2 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 500;
}

.dp-sidebar-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.dp-sidebar-content {
    padding: 15px;
    overflow-y: auto;
    flex: 1;
}

/* Scrollbar styles for better aesthetics */
.dp-sidebar-content::-webkit-scrollbar {
    width: 6px;
}

.dp-sidebar-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.dp-sidebar-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

.dp-sidebar-content::-webkit-scrollbar-thumb:hover {
    background: #bbb;
}

.dp-help-text {
    font-size: 0.85rem;
    margin: 0 0 10px 0;
    color: #444;
}

.dp-divider {
    border: 0;
    border-top: 1px solid #eee;
    margin: 10px 0 15px 0;
}

.dp-form-group {
    margin-bottom: 15px;
}

.dp-form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 6px;
}

.dp-select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
    font-size: 0.9rem;
    color: #333;
}

.dp-select:not([multiple]) {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
}

.dp-select[multiple] {
    height: auto;
    min-height: 120px;
    padding: 5px;
}

.dp-select option {
    padding: 6px 10px;
    border-radius: 2px;
}

.dp-select option:checked {
    background-color: #1e88e5;
    color: #fff;
}

.dp-select:focus {
    outline: none;
    border-color: #1e88e5;
}

/* Form Inputs */
.dp-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9rem;
    color: #333;
    box-sizing: border-box;
}

.dp-input:focus {
    outline: none;
    border-color: #1e88e5;
}

.dp-btn-outline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 20px;
    border: 1px solid #1e88e5;
    border-radius: 4px;
    background-color: transparent;
    color: #1e88e5;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.dp-btn-outline:hover {
    background-color: #f0f7ff;
}

.dp-upload-container {
    margin-top: 20px;
    display: flex;
    justify-content: flex-start;
}

/* Slider Style */
.dp-slider {
    width: 100%;
    margin: 10px 0;
    cursor: pointer;
}

/* Layers selection */
.dp-layers-title {
    font-size: 0.9rem;
    font-weight: 700;
    margin: 0 0 12px 0;
    color: #333;
}

.dp-layer-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    margin-bottom: 12px;
}

.dp-layer-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid transparent;
    transition: background-color 0.2s, border-bottom-color 0.2s;
    padding: 5px 8px;
    border-radius: 4px;
}

.dp-layer-main:hover {
    background-color: #f0f7ff;
}

.dp-layer-main.is-expanded {
    background-color: #f0f7ff;
    border-bottom-color: #eee;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.dp-category-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #333;
}

.dp-category-toggle {
    font-size: 0.7rem;
    color: #1e88e5;
    transition: transform 0.2s;
}

.dp-layer-main.is-expanded .dp-category-toggle {
    transform: rotate(180deg);
}

.dp-layer-submenu {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 0;
    background-color: #fafafa;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
    padding-top: 8px;
    padding-bottom: 8px;
}

.dp-layer-subitem {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dp-layer-subitem input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    margin: 0;
}

.dp-layer-subitem label {
    font-size: 0.85rem !important;
    color: #555;
    cursor: pointer;
    margin-bottom: 0 !important;
    font-weight: 400 !important;
}

/* Checkbox List for Communes */
.dp-checkbox-list {
    border: 1px solid #ccc;
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
    padding: 8px;
    background-color: #fff;
}

.dp-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

.dp-checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    margin: 0;
}

.dp-checkbox-item label {
    font-size: 0.85rem !important;
    color: #333;
    cursor: pointer;
    margin-bottom: 0 !important;
    font-weight: 400 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dp-info-text {
    font-size: 0.8rem;
    color: #777;
    font-style: italic;
    margin: 0;
}

/* MapLibre GL Draw overrides to hide default controls but keep functionality */
.mapboxgl-ctrl-group:has(.mapbox-gl-draw_polygon) {
    display: none !important;
}

/* Responsividad básica */
@media (max-width: 600px) {
    .dp-sidebar {
        left: 15px;
        top: 70px;
        width: calc(100% - 30px);
    }
}

/* Modal de Selección de Región */
.dp-region-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 5px;
}

.dp-region-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.dp-region-option:hover {
    background-color: #f0f7ff;
    border-color: #1e88e5;
}

.dp-region-option.is-selected {
    background-color: #e3f2fd;
    border-color: #1e88e5;
    box-shadow: 0 0 0 1px #1e88e5;
}

.dp-region-option input[type="radio"] {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
}

.dp-region-option label {
    flex: 1;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95rem !important;
    margin: 0;
}

.dp-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    padding: 0;
    line-height: 1;
}

.dp-modal-box-footer {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
}

.dp-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Modal de Procesamiento (Caja centrada) */
.dp-modal-box {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.dp-modal-box-content {
    background-color: #fff;
    width: 90%;
    max-width: 500px;
    border-radius: 4px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    overflow: hidden;
}

.dp-modal-box-header {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dp-modal-box-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 500;
    color: #333;
}

.dp-modal-box-body {
    padding: 20px;
    text-align: left;
}

.dp-modal-box-body p {
    margin: 0 0 20px 0;
    font-size: 0.95rem;
    color: #444;
    line-height: 1.5;
}

/* Circular Progress Bar */
.dp-progress-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px 0;
}

.dp-circular-progress {
    position: relative;
    height: 80px;
    width: 80px;
    border-radius: 50%;
    background: conic-gradient(#004a99 0deg, #ededed 0deg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.dp-circular-progress::before {
    content: "";
    position: absolute;
    height: 60px;
    width: 60px;
    border-radius: 50%;
    background-color: #fff;
}

.dp-progress-value {
    position: relative;
    font-size: 1rem;
    font-weight: 500;
    color: #333;
}

/* Modal Fullscreen (Reporte) */
.dp-modal-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #fff;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    z-index: 10000; /* Por encima del de procesamiento */
    overflow-y: auto;
}
.dp-report-overlay-content {
    width: 100%;
    max-width: 1200px;
    padding: 200px 30px 20px;
    background-color: #fff;
    display: flex;
    flex-direction: column;
}

.dp-report-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid #333;
    padding-bottom: 15px;
    margin-bottom: 30px;
}

.dp-report-main-title {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 700;
    color: #444;
}

.dp-report-subtitle {
    margin: 5px 0 0 0;
    font-size: 0.9rem;
    color: #666;
}

.dp-report-header-actions {
    display: flex;
    gap: 15px;
}

.dp-btn-report-outline {
    background: #fff;
    border: 1px solid #004a99;
    color: #004a99;
    padding: 8px 25px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.dp-btn-report-outline:hover {
    background: #f0f7ff;
}

.dp-btn-report-primary {
    background: #004a99;
    border: 1px solid #004a99;
    color: #fff !important;
    padding: 8px 25px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
}

.dp-btn-report-primary:hover {
    background: #003570;
}

.dp-report-body {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Evitar espacios en blanco al inicio del PDF */
#dp-report-preview-view {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Manejo de visibilidad durante la generación del PDF */
.dp-printing-active #dp-report-edit-view {
    display: none !important;
}

.dp-printing-active #dp-report-preview-view {
    display: block !important;
}

.dp-report-form-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.dp-report-form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dp-report-form-group label {
    font-size: 0.9rem;
    font-weight: 700;
    color: #333;
}

.dp-report-input, .dp-report-select {
    padding: 10px !important;
    border: 1px solid #999 !important;
    border-radius: 4px !important;
    font-size: 0.9rem;
    width: 100%;
}

.dp-report-form-grid > .dp-report-form-group:nth-child(n+3) {
    grid-template-columns: 1fr;
}

/* Re-adjust grid to match image rows better */
.dp-report-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.dp-report-form-group.full-width {
    grid-column: span 1; /* Match image where it's not actually full width but first item */
}

/* Vista de Previsualización */
.dp-preview-title-container {
    text-align: center;
    margin-bottom: 30px;
    padding: 0;
    margin-top: 0;
}

.dp-preview-h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 5px;
    color: #333;
}

.dp-preview-status-badge {
    display: inline-block;
    padding: 4px 12px;
    background-color: #fff9c4;
    border: 1px solid #fbc02d;
    border-radius: 4px;
    font-size: 0.9rem;
    color: #856404;
    font-weight: 500;
}

.dp-preview-info-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    background-color: #fff;
    padding: 20px;
    border: 1px solid #eee;
    border-radius: 8px;
    margin-bottom: 30px;
}

.dp-preview-info-item.full-width {
    grid-column: span 4;
}

.dp-preview-info-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.dp-preview-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: #333;
    text-transform: none;
}

.dp-preview-value {
    font-size: 0.95rem;
    color: #666;
}

.dp-preview-risk-container {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.9rem;
    color: #666;
}

.dp-risk-row {
    display: flex;
    justify-content: space-between;
    max-width: 150px;
}

/* Print Styles */
@media print {
    @page {
        margin: 1cm;
        size: auto;
    }
    html, body {
        height: auto !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    body * {
        visibility: hidden;
    }
    #dp-modal-report, #dp-modal-report * {
        visibility: visible;
    }
    #dp-modal-report {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
        overflow: visible !important;
        display: block !important;
        z-index: 99999 !important;
    }
    .dp-modal-fullscreen {
        display: none !important;
    }
    #dp-modal-report.dp-modal-fullscreen {
        display: block !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
    }
    .dp-report-overlay-content {
        padding: 0 !important;
        margin: 0 !important;
        max-width: none !important;
        box-shadow: none !important;
        width: 100% !important;
        display: block !important;
        position: relative !important;
        top: 0 !important;
    }
    .dp-report-body {
        display: block !important;
        overflow: visible !important;
        background: white !important;
        width: 100% !important;
        max-width: none !important;
        padding: 0 !important;
        margin: 0 !important;
        position: relative !important;
    }
    #dp-report-edit-view {
        display: none !important;
    }
    #dp-report-preview-view {
        display: block !important;
        margin-top: 0 !important;
        padding-top: 0 !important;
        break-before: avoid !important;
        page-break-before: avoid !important;
        position: relative !important;
        top: 0 !important;
    }
    /* Estilos específicos para el título del informe en la previsualización */
    .dp-preview-title-container {
        margin-top: 0 !important;
        padding-top: 0 !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
    }
    .dp-preview-h1 {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }
    .dp-report-header-actions, .dp-report-subtitle, .dp-section-toggle, .dp-report-header-actions * {
        display: none !important;
    }
    .dp-report-header {
        border-bottom: 1px solid #eee !important;
        margin-bottom: 20px !important;
        display: none !important; /* Ocultar el encabezado del modal en impresión */
    }
    .dp-report-main-title {
        font-size: 1.2rem !important;
        margin: 0 !important;
    }
    /* Asegurar que el mapa sea visible al imprimir */
    .dp-report-mini-map {
        break-inside: avoid !important;
        page-break-inside: avoid !important;
        height: 500px !important; /* Aumentar un poco para impresión */
        width: 100% !important;
        border: 1px solid #eee !important;
        position: relative !important;
        overflow: hidden !important;
        break-before: auto !important; /* Asegurar que no fuerce salto */
        page-break-before: auto !important;
    }
    .dp-report-mini-map canvas {
        display: none !important;
    }
    .dp-report-mini-map .dp-print-map-image {
        display: block !important;
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }
    .dp-report-table {
        break-inside: auto;
        width: 100% !important;
    }
    .dp-report-table tr {
        break-inside: avoid;
        break-after: auto;
    }
    .dp-report-table-container, .dp-report-table-wrapper {
        overflow: visible !important;
        display: block !important;
        width: 100% !important;
        max-height: none !important;
        height: auto !important;
    }
    .dp-report-section {
        break-before: page !important;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        border: 1px solid #eee !important;
        display: block !important;
        page-break-before: always !important; /* Compatibilidad */
        padding-top: 0 !important;
    }
    .dp-report-section:first-of-type {
        break-before: auto !important;
        page-break-before: auto !important;
    }
    .dp-report-section-header {
        margin-top: 0 !important;
        padding-top: 10px !important;
        padding-bottom: 10px !important;
    }
    .dp-report-section-header h3 {
        margin: 0 !important;
    }
    .dp-report-section-content {
        display: block !important;
        visibility: visible !important;
        padding: 10px 20px !important;
    }
    .dp-report-section[style*="display: none"] {
        display: none !important;
    }
    /* Forzar fondos para impresión */
    .dp-preview-status-badge {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    .dp-preview-info-grid {
        border: 1px solid #eee !important;
    }
}

/* Adjusting grid to be more precise based on visual */
.dp-report-form-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}
/* Second row: 1fr 1fr */
/* Third row: 1fr 1fr */

.dp-report-section {
    border: 1px solid #eee;
    background-color: #fff;
}

.dp-report-section-header {
    background-color: #e0e0e0;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.dp-report-section-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.dp-report-section-content {
    padding: 20px;
}

.dp-infography-title {
    margin: 0 0 15px 0;
    font-size: 1rem;
    font-weight: 700;
}

.dp-report-mini-map {
    width: 100%;
    height: 400px;
    background-color: #f9f9f9;
    margin-bottom: 10px;
    border: 1px solid #ddd;
}

.dp-report-map-caption {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 30px;
}

.dp-report-table-container {
    overflow-x: auto;
}

.dp-report-table {
    width: 100%;
    border-collapse: collapse;
}

.dp-table-main-title {
    background-color: #004a99;
    color: #fff;
    padding: 12px;
    text-align: center;
    font-weight: 700;
    font-size: 1rem;
    border: none;
}

.dp-table-header-row-1 th {
    background-color: #1e88e5;
    color: #fff;
    padding: 12px 10px;
    border: none;
    font-weight: 500;
    font-size: 0.9rem;
    text-align: center;
}

.dp-table-header-row-2 th {
    background-color: #448aff;
    color: #fff;
    padding: 12px 10px;
    border: none;
    font-weight: 400;
    font-size: 0.85rem;
    text-align: center;
}

.dp-report-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
    color: #333;
    text-align: center;
}

.dp-report-table td:first-child {
    text-align: left;
    background-color: #f5f5f5;
    font-weight: 500;
}

.dp-report-table tbody tr:nth-child(even) {
    background-color: #fff;
}

.dp-report-table tr td:first-child {
    width: auto;
}

.dp-no-data-msg {
    text-align: center;
    padding: 20px;
    color: #666;
    background: #f9f9f9;
    border: 1px dashed #ccc;
    border-radius: 4px;
}

@media (max-width: 900px) {
    .dp-report-form-grid {
        grid-template-columns: 1fr;
    }
}
