/* xsukax KML/KMZ Map Viewer - Custom Styles */

/* Base Styles */
body {
    padding: 0;
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f7fa;
}

/* Map Styles */
#map {
    height: calc(100vh - 200px);
    width: 100%;
    border-radius: 0;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* Header Styles */
.header {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #7e22ce 100%);
    color: white;
    padding: 2rem 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: pulse 15s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.3;
    }
}

.brand-logo {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
}

.brand-accent {
    color: #fbbf24;
    font-weight: 800;
}

.subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-top: 0.5rem;
    position: relative;
    z-index: 1;
}

/* Upload Section Styles */
.upload-section {
    background: white;
    padding: 2rem;
    border-bottom: 3px solid #e5e7eb;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.card-upload {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.5rem;
    border: 2px dashed #cbd5e1;
    transition: all 0.3s ease;
}

.card-upload:hover {
    border-color: #7e22ce;
    box-shadow: 0 4px 12px rgba(126, 34, 206, 0.1);
}

.file-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0;
    width: 100%;
}

.file-input-wrapper input[type=file] {
    display: none;
}

.file-input-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 46px;
    min-height: 46px;
    box-sizing: border-box;
    padding: 0 2rem;
    background: linear-gradient(135deg, #7e22ce 0%, #5b21b6 100%);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1;
    vertical-align: middle;
    box-shadow: 0 4px 12px rgba(126, 34, 206, 0.3);
}

.file-input-label:hover {
    background: linear-gradient(135deg, #6b21a8 0%, #4c1d95 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(126, 34, 206, 0.4);
}

.file-input-label i {
    margin-right: 0.5rem;
}

/* NetworkLinkControl Message Modal */
.nlc-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.nlc-modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    max-width: 460px;
    width: 90%;
    overflow: hidden;
    animation: slideUp 0.25s ease;
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.nlc-modal-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #7e22ce 100%);
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
}

.nlc-modal-header i {
    font-size: 1.2rem;
}

.nlc-modal-close {
    margin-left: auto;
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

.nlc-modal-close:hover {
    color: #fff;
}

.nlc-modal-body {
    padding: 1.25rem;
    font-size: 0.95rem;
    color: #1f2937;
    line-height: 1.6;
    max-height: 50vh;
    overflow-y: auto;
}

.nlc-modal-footer {
    padding: 0.75rem 1.25rem;
    text-align: right;
    border-top: 1px solid #e5e7eb;
}

.nlc-modal-btn {
    padding: 0.5rem 2rem;
    background: linear-gradient(135deg, #7e22ce 0%, #5b21b6 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.nlc-modal-btn:hover {
    background: linear-gradient(135deg, #6b21a8 0%, #4c1d95 100%);
    transform: translateY(-1px);
}

/* Status Message Styles */
.status-message {
    margin-top: 1rem;
    padding: 1rem 1.25rem;
    border-radius: 8px;
    display: none;
    font-weight: 500;
    border-left: 4px solid;
}

.status-message.show {
    display: flex;
    align-items: center;
}

.status-message i {
    margin-right: 0.75rem;
    font-size: 1.2rem;
}

.status-success {
    background: #d1fae5;
    color: #065f46;
    border-left-color: #10b981;
}

.status-error {
    background: #fee2e2;
    color: #991b1b;
    border-left-color: #ef4444;
}

.status-info {
    background: #dbeafe;
    color: #1e40af;
    border-left-color: #3b82f6;
}

/* Layer Info Styles */
.layer-info {
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    border-radius: 8px;
    margin-top: 1rem;
    display: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border-left: 4px solid #7e22ce;
}

.layer-info.show {
    display: flex;
    align-items: center;
}

.layer-info i {
    margin-right: 0.75rem;
    color: #7e22ce;
    font-size: 1.2rem;
}

/* Button Styles - 与 Select 按钮同高同基线 */
.clear-btn {
    margin-left: 1rem;
    height: 46px;
    min-height: 46px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 1.5rem;
    background: #ef9f44;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1;
    vertical-align: middle;
    font-family: inherit;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.clear-btn:hover {
    background: #fc9439;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.clear-btn i {
    margin-right: 0.5rem;
}

/* Feature Label Styles */
.feature-label {
    background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
    border: 2px solid #7e22ce;
    padding: 6px 14px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 13px;
    color: #1f2937;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
    pointer-events: none;
}

.leaflet-tooltip.feature-label::before {
    display: none;
}

/* Leaflet Popup 样式修正 */
.leaflet-popup .leaflet-popup-content-wrapper {
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    overflow: hidden;
}

.leaflet-popup .leaflet-popup-content {
    margin: 10px 12px;
    line-height: 1.5;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 60vh;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* KML description 里嵌入的 HTML（图片、表格等）自适应 */
.leaflet-popup .leaflet-popup-content img {
    max-width: 100%;
    height: auto;
}

.leaflet-popup .leaflet-popup-content table {
    border-collapse: collapse;
    font-size: 0.85rem;
}

.leaflet-popup .leaflet-popup-content table td,
.leaflet-popup .leaflet-popup-content table th {
    padding: 2px 4px;
    white-space: nowrap;
}

.leaflet-popup .leaflet-popup-tip-container {
    margin-top: -1px;
}

.leaflet-popup .leaflet-popup-close-button {
    top: 6px;
    right: 8px;
    color: #6b7280;
    font-size: 20px;
    z-index: 10;
}

/* MapLibre Popup Styles (保留，不影响 Leaflet) */
.maplibregl-popup.feature-label-popup {
    pointer-events: none;
}

.maplibregl-popup.feature-label-popup .maplibregl-popup-content {
    padding: 0;
    background: transparent;
    box-shadow: none;
}

.maplibregl-popup.feature-label-popup .maplibregl-popup-tip {
    display: none;
}

.maplibregl-popup.custom-popup .maplibregl-popup-content {
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* MapLibre Map Container */
#map {
    height: calc(100vh - 200px);
    width: 100%;
    border-radius: 0;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

.maplibregl-ctrl-group {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.maplibregl-ctrl-group button {
    width: 32px;
    height: 32px;
    border-radius: 0;
}

.maplibregl-ctrl-group button:first-child {
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.maplibregl-ctrl-group button:last-child {
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

/* Info Badge Styles */
.info-badge {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    background: #7e22ce;
    color: white;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

/* Map Container Styles */
.map-container {
    padding: 1.5rem;
    background: white;
    margin: 0;
}

/* Footer Styles */
.footer-note {
    text-align: center;
    padding: 1rem;
    color: #6b7280;
    font-size: 0.85rem;
    background: #f9fafb;
}

.footer-note a {
    color: #7e22ce;
    text-decoration: none;
    font-weight: 600;
}

.footer-note a:hover {
    text-decoration: underline;
}

/* ===================== RAG Spatial Q&A Panel ===================== */

.rag-toggle-btn {
    position: fixed;
    right: 24px;
    bottom: 80px;
    z-index: 1000;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7e22ce 0%, #5b21b6 100%);
    color: white;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(126, 34, 206, 0.45);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rag-toggle-btn:hover {
    transform: scale(1.12);
    box-shadow: 0 6px 24px rgba(126, 34, 206, 0.55);
}

.rag-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 380px;
    max-width: 100vw;
    background: #fff;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    animation: ragSlideIn 0.28s ease;
}

@keyframes ragSlideIn {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}

.rag-panel-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.9rem 1.1rem;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #7e22ce 100%);
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
    flex-shrink: 0;
}

.rag-panel-header i { font-size: 1.15rem; }

.rag-panel-close {
    margin-left: auto;
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

.rag-panel-close:hover { color: #fff; }

.rag-panel-body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.rag-mode-selector {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    flex-shrink: 0;
}

.rag-mode-label {
    font-weight: 600;
    font-size: 0.82rem;
    color: #374151;
    margin-bottom: 0.2rem;
}

.rag-mode-options {
    display: flex;
    gap: 0.7rem;
    font-size: 0.82rem;
    flex-wrap: wrap;
}

.rag-mode-options label {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    cursor: pointer;
    color: #4b5563;
}

.rag-status {
    padding: 0.4rem 1rem;
    font-size: 0.78rem;
    color: #6b7280;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.rag-status-ok  { color: #059669; }
.rag-status-error { color: #dc2626; }

.rag-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.7rem;
    min-height: 80px;
}

.rag-chat-msg {
    margin-bottom: 0.7rem;
    padding: 0.55rem 0.85rem;
    border-radius: 10px;
    font-size: 0.88rem;
    line-height: 1.55;
    max-width: 95%;
    white-space: pre-wrap;
    word-break: break-word;
}

.rag-chat-user {
    background: #ede9fe;
    color: #4c1d95;
    margin-left: auto;
    text-align: right;
    border-bottom-right-radius: 2px;
}

.rag-chat-assistant {
    background: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: 2px;
}

.rag-chat-error {
    background: #fee2e2;
    color: #991b1b;
}

.rag-entity-link {
    color: #7e22ce;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.rag-entity-link:hover {
    color: #5b21b6;
}

.rag-chat-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #6b7280;
}

.rag-loading-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.rag-loading-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #7e22ce;
    animation: rag-dot 0.6s ease-in-out infinite both;
}

.rag-loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.rag-loading-dots span:nth-child(3) { animation-delay: 0.3s; }

.rag-chat-loading .rag-loading-text {
    flex: 1;
}

@keyframes rag-dot {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

.rag-input-area.rag-input-loading input,
.rag-input-area.rag-input-loading button {
    opacity: 0.65;
    pointer-events: none;
    cursor: not-allowed;
}

.rag-hits-list {
    border-top: 1px solid #e5e7eb;
    max-height: 42%;
    overflow-y: auto;
    flex-shrink: 0;
}

.rag-hit-item {
    padding: 0.55rem 1rem;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: background 0.15s;
}

.rag-hit-item:hover {
    background: #f5f3ff;
}

.rag-hit-name {
    font-weight: 600;
    font-size: 0.84rem;
    color: #7e22ce;
}

.rag-hit-score {
    font-size: 0.74rem;
    color: #6b7280;
}

.rag-hit-why {
    font-size: 0.74rem;
    color: #9ca3af;
    margin-top: 0.1rem;
}

.rag-no-hits {
    padding: 1rem;
    text-align: center;
    color: #9ca3af;
    font-size: 0.85rem;
}

.rag-input-area {
    display: flex;
    padding: 0.65rem;
    border-top: 2px solid #e5e7eb;
    background: #f9fafb;
    gap: 0.45rem;
    flex-shrink: 0;
}

.rag-input-area input {
    flex: 1;
    padding: 0.55rem 0.85rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.88rem;
    outline: none;
    transition: border 0.2s;
}

.rag-input-area input:focus {
    border-color: #7e22ce;
    box-shadow: 0 0 0 2px rgba(126, 34, 206, 0.12);
}

.rag-input-area button {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #7e22ce 0%, #5b21b6 100%);
    color: white;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.rag-input-area button:hover {
    background: linear-gradient(135deg, #6b21a8 0%, #4c1d95 100%);
    transform: translateY(-1px);
}

.rag-input-area .rag-summarize-btn {
    width: auto;
    min-width: 52px;
    padding: 0 0.6rem;
    font-size: 0.8rem;
    background: #0d9488;
}

.rag-input-area .rag-summarize-btn:hover {
    background: #0f766e;
}

@media (max-width: 480px) {
    .rag-panel { width: 100vw; }
}
