/**
 * ═══════════════════════════════════════════════════════════════
 * PLAYAS QROO MONITOR v4.0 — Improved Map + Bilingual
 * ═══════════════════════════════════════════════════════════════
 */

/* ═══ RESET & WRAPPER ═══ */
.pqm-wrapper {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border-radius: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 'Helvetica Neue', Arial, sans-serif;
}

.pqm-map {
    width: 100%;
    height: calc(100vh - 48px);
    height: calc(100dvh - 48px);
    background: #e8e4df;
    z-index: 1;
}

/* ═══ STATUS BAR ═══ */
.pqm-status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 16px;
    background: linear-gradient(135deg, #0c2d48 0%, #145374 50%, #0c2d48 100%);
    color: #ffffff;
    font-size: 13px;
    z-index: 1000;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    flex-wrap: wrap;
    gap: 8px;
}

.pqm-status-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.pqm-logo {
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.3px;
    white-space: nowrap;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.pqm-badge {
    background: rgba(46, 204, 113, 0.25);
    color: #2ecc71;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid rgba(46, 204, 113, 0.4);
    white-space: nowrap;
}

.pqm-status-text {
    font-size: 10px;
    color: rgba(255,255,255,0.6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.pqm-status-center {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pqm-status-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pqm-legend-item {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.2px;
    opacity: 0.9;
}

.pqm-legend-limpio   { color: #2ecc71; }
.pqm-legend-leve     { color: #f1c40f; }
.pqm-legend-moderado { color: #e67e22; }
.pqm-legend-alto     { color: #e74c3c; }

/* ═══ LANGUAGE TOGGLE ═══ */
.pqm-lang-toggle {
    display: inline-flex;
    align-items: center;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 20px;
    overflow: hidden;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
}

.pqm-lang-btn {
    padding: 4px 12px;
    color: rgba(255,255,255,0.5);
    transition: all 0.2s;
    border: none;
    background: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 11px;
}

.pqm-lang-btn:hover {
    color: rgba(255,255,255,0.8);
}

.pqm-lang-btn.pqm-lang-active {
    background: rgba(255,255,255,0.2);
    color: #ffffff;
}

/* ═══ CONTROL BUTTONS ═══ */
.pqm-control-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.pqm-control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.35);
    transform: translateY(-1px);
}

.pqm-control-btn:active { transform: translateY(0); }

.pqm-control-btn.pqm-btn-loading {
    opacity: 0.6;
    pointer-events: none;
}

.pqm-control-btn.pqm-btn-loading svg {
    animation: pqm-spin 1s linear infinite;
}

.pqm-control-btn.pqm-btn-active {
    background: rgba(155, 89, 182, 0.4);
    border-color: rgba(155, 89, 182, 0.7);
    box-shadow: 0 0 12px rgba(155, 89, 182, 0.3);
}

.pqm-btn-label { line-height: 1; }

/* ═══ CROSSHAIR CURSOR ═══ */
.pqm-crosshair-cursor { cursor: crosshair !important; }
.pqm-crosshair-cursor .leaflet-container { cursor: crosshair !important; }

/* ═══ ADD PIN FORM ═══ */
.pqm-add-pin-form {
    position: absolute;
    top: 48px;
    left: 0;
    width: 100%;
    height: calc(100vh - 48px);
    height: calc(100dvh - 48px);
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 950;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pqm-fadeIn 0.2s ease;
}

.pqm-add-pin-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 24px;
    width: 380px;
    max-width: 90%;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.pqm-add-pin-card h4 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 700;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pqm-form-row { margin-bottom: 12px; }
.pqm-form-row label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #7f8c8d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.pqm-form-row input,
.pqm-form-row select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #dcdfe6;
    border-radius: 8px;
    font-size: 13px;
    color: #333;
    background: #f8f9fa;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.pqm-form-row input:focus,
.pqm-form-row select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
    background: #ffffff;
}

.pqm-form-row input::placeholder { color: #bdc3c7; }

.pqm-form-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.pqm-btn-save {
    background: rgba(46, 204, 113, 0.2) !important;
    border-color: rgba(46, 204, 113, 0.5) !important;
    color: #27ae60 !important;
    flex: 1;
}

.pqm-btn-save:hover { background: rgba(46, 204, 113, 0.35) !important; }

.pqm-pin-coords-text {
    margin: 10px 0 0 0;
    font-size: 11px;
    color: #95a5a6;
    text-align: center;
}

/* ═══ LOADING OVERLAY ═══ */
.pqm-loading-overlay {
    position: absolute;
    top: 48px;
    left: 0;
    width: 100%;
    height: calc(100vh - 48px);
    height: calc(100dvh - 48px);
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 900;
    animation: pqm-fadeIn 0.3s ease;
}

.pqm-loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 30px 40px;
    background: rgba(12, 45, 72, 0.95);
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.pqm-loading-content span {
    color: #ecf0f1;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.pqm-spinner-lg {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(52, 152, 219, 0.2);
    border-top-color: #3498db;
    border-radius: 50%;
    animation: pqm-spin 0.8s linear infinite;
}

@keyframes pqm-spin { to { transform: rotate(360deg); } }
@keyframes pqm-fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ═══ TOAST ═══ */
.pqm-toast {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    z-index: 1100;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s ease;
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

.pqm-toast-show { transform: translateX(-50%) translateY(0); opacity: 1; }
.pqm-toast-ok    { background: rgba(46, 204, 113, 0.95); }
.pqm-toast-error { background: rgba(231, 76, 60, 0.95); }
.pqm-toast-warn  { background: rgba(241, 196, 15, 0.95); color: #333; }
.pqm-toast-info  { background: rgba(52, 152, 219, 0.95); }

/* ═══ GPS MARKER ═══ */
.pqm-gps-marker { background: none !important; border: none !important; }

.pqm-gps-dot {
    width: 16px;
    height: 16px;
    background: #3498db;
    border: 3px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.5);
    position: relative;
    z-index: 3;
}

.pqm-gps-pulse {
    position: absolute;
    top: 50%; left: 50%;
    width: 40px; height: 40px;
    margin-top: -20px; margin-left: -20px;
    background: rgba(52, 152, 219, 0.25);
    border-radius: 50%;
    animation: pqm-pulse 2s ease-out infinite;
    z-index: 1;
}

.pqm-gps-pulse-2 { animation-delay: 0.6s; }

@keyframes pqm-pulse {
    0%   { transform: scale(0.5); opacity: 0.8; }
    100% { transform: scale(2.5); opacity: 0; }
}

.pqm-gps-tooltip .leaflet-tooltip-content { font-size: 12px; }

/* ═══ CUSTOM MARKERS ═══ */
.pqm-custom-marker { background: none !important; border: none !important; }

.pqm-marker-pin {
    width: 36px;
    height: 36px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
    border: 3px solid rgba(255, 255, 255, 0.85);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pqm-marker-pin:hover {
    transform: rotate(-45deg) scale(1.15);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.45);
}

.pqm-marker-pin svg { transform: rotate(45deg); }

.pqm-marker-shadow {
    width: 20px; height: 6px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 50%;
    margin: 2px auto 0;
    filter: blur(1px);
}

/* ═══ TYPE BADGES ═══ */
.pqm-type-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 6px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    vertical-align: middle;
}

.pqm-type-manual { background: rgba(155, 89, 182, 0.2); color: #9b59b6; }
.pqm-type-scraped { background: rgba(52, 152, 219, 0.2); color: #3498db; }
.pqm-type-known { background: rgba(52, 152, 219, 0.2); color: #3498db; }

/* ═══ LEAFLET POPUP ═══ */
.pqm-leaflet-popup .leaflet-popup-content-wrapper {
    border-radius: 12px;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    border: none;
}

.pqm-leaflet-popup .leaflet-popup-content {
    margin: 0;
    min-width: 320px;
    max-width: 400px;
    line-height: 1.5;
}

.pqm-leaflet-popup .leaflet-popup-tip { background: #ffffff; }

.pqm-leaflet-popup .leaflet-popup-close-button {
    top: 8px; right: 8px;
    z-index: 100;
    width: 28px; height: 28px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 18px;
    line-height: 28px;
    text-align: center;
    transition: background 0.2s;
}

.pqm-leaflet-popup .leaflet-popup-close-button:hover { background: rgba(0, 0, 0, 0.85); }

.pqm-popup { background: #ffffff; color: #333; }

.pqm-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, #0c2d48, #145374);
    color: #fff;
    gap: 10px;
    flex-wrap: wrap;
}

.pqm-popup-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.3;
    flex: 1;
}

.pqm-sargazo-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.pqm-sargazo-limpio   { background: rgba(46, 204, 113, 0.2);  color: #2ecc71; }
.pqm-sargazo-leve     { background: rgba(241, 196, 15, 0.2);  color: #f1c40f; }
.pqm-sargazo-moderado { background: rgba(230, 126, 34, 0.2);  color: #e67e22; }
.pqm-sargazo-alto     { background: rgba(231, 76, 60, 0.2);   color: #e74c3c; }

.pqm-video-container { padding: 0; background: #000; }
.pqm-video-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%;
    overflow: hidden;
}

.pqm-video-player {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    background: #000;
}

.pqm-video-loading {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 12px;
    gap: 10px;
    z-index: 5;
}

.pqm-video-error {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
    font-size: 12px;
    font-weight: 600;
    z-index: 5;
}

/* ═══ IFRAME CONTAINER ═══ */
.pqm-iframe-container {
    position: relative;
    width: 100%;
    background: #000;
    overflow: hidden;
}

.pqm-iframe-label {
    position: absolute;
    top: 8px; left: 8px;
    z-index: 10;
    background: rgba(231, 76, 60, 0.9);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    animation: pqm-pulse-live 2s ease-in-out infinite;
}

@keyframes pqm-pulse-live {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.pqm-iframe-player {
    display: block;
    width: 100%;
    aspect-ratio: 16/9;
    border: none;
    background: #000;
}

.pqm-iframe-fallback {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(12, 45, 72, 0.95);
    z-index: 5;
}

.pqm-iframe-fallback-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px;
    text-align: center;
    color: #bdc3c7;
    font-size: 12px;
}

.pqm-iframe-fallback-icon { font-size: 32px; opacity: 0.6; }
.pqm-iframe-fallback p { margin: 0; color: #95a5a6; }

/* ═══ LINK PREVIEW ═══ */
.pqm-link-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f0f3f6;
    border-bottom: 1px solid #e0e5eb;
}

.pqm-link-preview-icon { font-size: 28px; flex-shrink: 0; }

.pqm-link-preview-text {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    color: #555;
    line-height: 1.4;
}

.pqm-link-preview-text strong {
    color: #2c3e50;
    display: block;
    margin-bottom: 2px;
    font-size: 13px;
}

.pqm-link-preview-text span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #95a5a6;
}

/* ═══ POPUP INFO & ACTIONS ═══ */
.pqm-popup-info { padding: 10px 16px; background: #f8f9fa; border-bottom: 1px solid #ecf0f1; }
.pqm-popup-meta { display: flex; flex-direction: column; gap: 4px; }
.pqm-meta-item { font-size: 12px; color: #666; line-height: 1.4; }
.pqm-meta-item strong { color: #333; }

.pqm-popup-actions {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    flex-wrap: wrap;
}

.pqm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    line-height: 1.4;
    flex: 1;
    min-width: 0;
}

.pqm-btn-maps { background: #3498db; color: #fff; }
.pqm-btn-maps:hover {
    background: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.35);
}

.pqm-btn-source { background: #2c3e50; color: #fff; }
.pqm-btn-source:hover {
    background: #1a252f;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(44, 62, 80, 0.35);
}

.pqm-btn-delete { background: #e74c3c; color: #fff; }
.pqm-btn-delete:hover {
    background: #c0392b;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.35);
}

/* ═══ TOOLTIP ═══ */
.pqm-tooltip {
    background: rgba(12, 45, 72, 0.92) !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 8px !important;
    padding: 6px 12px !important;
    font-size: 12px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

.pqm-tooltip::before { border-top-color: rgba(12, 45, 72, 0.92) !important; }
.pqm-tooltip-status { font-size: 11px; opacity: 0.8; }

/* ═══ SIDE PANEL ═══ */
.pqm-info-panel {
    position: absolute;
    top: 48px;
    right: -400px;
    width: 380px;
    height: calc(100vh - 48px);
    height: calc(100dvh - 48px);
    background: #ffffff;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 900;
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    padding: 20px;
}

.pqm-panel-open { right: 0 !important; }

.pqm-close-btn {
    position: absolute;
    top: 10px; right: 10px;
    width: 32px; height: 32px;
    background: #ecf0f1;
    border: none;
    border-radius: 50%;
    font-size: 22px;
    line-height: 32px;
    text-align: center;
    cursor: pointer;
    color: #7f8c8d;
    transition: all 0.2s;
}

.pqm-close-btn:hover { background: #e74c3c; color: #fff; }

/* ═══ MINI STATS (panel) ═══ */
.pqm-panel-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.pqm-stat-card {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 12px;
    text-align: center;
}

.pqm-stat-card .pqm-stat-num {
    font-size: 24px;
    font-weight: 700;
    color: #0c2d48;
}

.pqm-stat-card .pqm-stat-label {
    font-size: 10px;
    font-weight: 600;
    color: #7f8c8d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.pqm-stat-card.pqm-stat-green .pqm-stat-num { color: #2ecc71; }
.pqm-stat-card.pqm-stat-yellow .pqm-stat-num { color: #f1c40f; }
.pqm-stat-card.pqm-stat-orange .pqm-stat-num { color: #e67e22; }
.pqm-stat-card.pqm-stat-red .pqm-stat-num { color: #e74c3c; }

/* ═══ TABLE in panel ═══ */
.pqm-panel-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.pqm-panel-table th {
    background: #f0f3f6;
    padding: 8px 6px;
    text-align: left;
    font-weight: 700;
    color: #2c3e50;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #e0e5eb;
}

.pqm-panel-table td {
    padding: 8px 6px;
    border-bottom: 1px solid #ecf0f1;
    color: #555;
}

.pqm-panel-table tr:hover td { background: #f8f9fa; }

.pqm-sargazo-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 640px) {
    .pqm-status-bar {
        flex-direction: column;
        height: auto;
        padding: 8px 10px;
        gap: 6px;
    }

    .pqm-status-left { width: 100%; justify-content: center; }
    .pqm-status-center { width: 100%; justify-content: center; flex-wrap: wrap; }
    .pqm-status-right { width: 100%; justify-content: center; flex-wrap: wrap; gap: 8px; }

    .pqm-map { height: calc(100% - 140px); }
    .pqm-btn-label { display: none; }
    .pqm-control-btn { padding: 6px 10px; }
    .pqm-status-text { max-width: 150px; font-size: 9px; }

    .pqm-popup-title { font-size: 13px; }
    .pqm-popup-actions { flex-direction: column; }
    .pqm-btn { width: 100%; }

    .pqm-leaflet-popup .leaflet-popup-content {
        min-width: 260px;
        max-width: 300px;
    }

    .pqm-info-panel { width: 100%; right: -100%; }

    .pqm-add-pin-card { width: 95%; padding: 18px; }

    .pqm-lang-toggle { font-size: 10px; }
    .pqm-lang-btn { padding: 3px 8px; font-size: 10px; }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .pqm-info-panel { width: 320px; }
    .pqm-status-text { max-width: 160px; }
}

/* ═══ DARK MODE ═══ */
@media (prefers-color-scheme: dark) {
    .pqm-popup-info { background: #1a2332; }
    .pqm-popup-meta .pqm-meta-item { color: #bdc3c7; }
    .pqm-popup-meta .pqm-meta-item strong { color: #ecf0f1; }
    .pqm-info-panel { background: #1a2332; color: #ecf0f1; }
    .pqm-panel-table th { background: #2c3e50; color: #ecf0f1; }
    .pqm-panel-table td { border-bottom-color: #34495e; color: #bdc3c7; }
    .pqm-panel-table tr:hover td { background: #2c3e50; }
    .pqm-stat-card { background: #2c3e50; }
    .pqm-stat-card .pqm-stat-label { color: #95a5a6; }

    .pqm-add-pin-card {
        background: #2c3e50;
        border-color: rgba(255, 255, 255, 0.1);
    }

    .pqm-add-pin-card h4 { color: #ecf0f1; }
    .pqm-form-row label { color: #95a5a6; }

    .pqm-form-row input,
    .pqm-form-row select {
        background: #34495e;
        border-color: #4a6785;
        color: #ecf0f1;
    }

    .pqm-form-row input::placeholder { color: #7f8c8d; }

    .pqm-form-row input:focus,
    .pqm-form-row select:focus {
        background: #3d566e;
        border-color: #3498db;
    }

    .pqm-pin-coords-text { color: #7f8c8d; }
}

/* ═══════════════════════════════════════════════════════════════
   CHAT EN VIVO — Widget Flotante
   ═══════════════════════════════════════════════════════════════ */

/* ─── Botón flotante ─── */
.pqm-chat-toggle {
    position: absolute;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #0c2d48 0%, #145374 50%, #1a6fa0 100%);
    color: #ffffff;
    cursor: pointer;
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35), 0 0 0 0 rgba(26, 111, 160, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: pqm-chat-pulse-ring 3s ease-out infinite;
}

.pqm-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.4), 0 0 0 8px rgba(26, 111, 160, 0.1);
}

.pqm-chat-toggle:active { transform: scale(0.95); }

.pqm-chat-toggle.pqm-chat-open {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    animation: none;
}

@keyframes pqm-chat-pulse-ring {
    0%   { box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35), 0 0 0 0 rgba(26, 111, 160, 0.5); }
    70%  { box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35), 0 0 0 14px rgba(26, 111, 160, 0); }
    100% { box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35), 0 0 0 0 rgba(26, 111, 160, 0); }
}

/* Badge de mensajes nuevos */
.pqm-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: #e74c3c;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-shadow: 0 2px 6px rgba(231, 76, 60, 0.5);
    animation: pqm-badge-bounce 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

@keyframes pqm-badge-bounce {
    0%   { transform: scale(0); }
    60%  { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ─── Widget contenedor ─── */
.pqm-chat-widget {
    position: absolute;
    bottom: 92px;
    right: 24px;
    width: 360px;
    max-height: 480px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
    z-index: 1060;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.pqm-chat-widget.pqm-chat-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ─── Header del chat ─── */
.pqm-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(135deg, #0c2d48 0%, #145374 50%, #1a6fa0 100%);
    color: #ffffff;
    flex-shrink: 0;
}

.pqm-chat-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 14px;
}

.pqm-chat-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pqm-chat-online-count {
    font-size: 11px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 5px;
}

.pqm-chat-online-count::before {
    content: '';
    width: 7px;
    height: 7px;
    background: #2ecc71;
    border-radius: 50%;
    display: inline-block;
    animation: pqm-online-blink 2s ease-in-out infinite;
}

@keyframes pqm-online-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.pqm-chat-minimize {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    transition: background 0.2s;
}

.pqm-chat-minimize:hover { background: rgba(255, 255, 255, 0.3); }

/* ─── Modal de nickname ─── */
.pqm-chat-nickname-modal {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    flex-shrink: 0;
}

.pqm-chat-nickname-inner {
    text-align: center;
    width: 100%;
}

.pqm-chat-nickname-avatar {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #3498db, #2ecc71);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
    color: #fff;
}

.pqm-chat-nickname-inner h4 {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 700;
    color: #2c3e50;
}

.pqm-chat-nickname-desc {
    margin: 0 0 16px;
    font-size: 12px;
    color: #95a5a6;
    line-height: 1.4;
}

.pqm-chat-nickname-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e5eb;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    color: #2c3e50;
    background: #f8f9fa;
    text-align: center;
    transition: all 0.2s;
    box-sizing: border-box;
    box-shadow: none;
    outline: none;
}

.pqm-chat-nickname-input:focus {
    border-color: #3498db;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.pqm-chat-nickname-input::placeholder {
    color: #bdc3c7;
    font-weight: 400;
}

.pqm-chat-nickname-btn {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #0c2d48, #145374);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.3px;
}

.pqm-chat-nickname-btn:hover {
    background: linear-gradient(135deg, #145374, #1a6fa0);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(20, 83, 116, 0.4);
}

.pqm-chat-nickname-btn:active { transform: translateY(0); }
.pqm-chat-nickname-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.pqm-chat-nickname-error {
    display: block;
    margin-top: 8px;
    font-size: 11px;
    color: #e74c3c;
    font-weight: 600;
    min-height: 16px;
}

/* ─── Barra de usuarios online ─── */
.pqm-chat-online-bar {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: #f8f9fa;
    border-bottom: 1px solid #ecf0f1;
    flex-shrink: 0;
    overflow-x: auto;
    gap: 6px;
}

.pqm-chat-online-avatars {
    display: flex;
    gap: 4px;
    flex-wrap: nowrap;
}

.pqm-chat-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #ffffff;
    flex-shrink: 0;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    position: relative;
}

.pqm-chat-avatar-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 3px 8px;
    background: rgba(12, 45, 72, 0.95);
    color: #fff;
    font-size: 10px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    margin-bottom: 4px;
}

.pqm-chat-avatar:hover .pqm-chat-avatar-tooltip { opacity: 1; }

/* ─── Área de mensajes ─── */
.pqm-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 200px;
    max-height: 320px;
    background: #ffffff;
    scroll-behavior: smooth;
}

.pqm-chat-messages::-webkit-scrollbar {
    width: 5px;
}

.pqm-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.pqm-chat-messages::-webkit-scrollbar-thumb {
    background: #dcdfe6;
    border-radius: 10px;
}

/* ─── Burbuja de mensaje ─── */
.pqm-chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: pqm-msg-in 0.25s ease;
}

.pqm-chat-msg.pqm-msg-mine {
    align-self: flex-end;
}

.pqm-chat-msg.pqm-msg-other {
    align-self: flex-start;
}

@keyframes pqm-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.pqm-chat-msg-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
    padding: 0 4px;
}

.pqm-chat-msg-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    color: #ffffff;
    flex-shrink: 0;
}

.pqm-chat-msg-nick {
    font-size: 11px;
    font-weight: 700;
    color: #2c3e50;
}

.pqm-chat-msg-time {
    font-size: 10px;
    color: #bdc3c7;
}

.pqm-chat-msg-bubble {
    padding: 9px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.45;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.pqm-msg-mine .pqm-chat-msg-bubble {
    background: linear-gradient(135deg, #0c2d48, #145374);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.pqm-msg-other .pqm-chat-msg-bubble {
    background: #f0f3f6;
    color: #333333;
    border-bottom-left-radius: 4px;
}

/* Mensaje de sistema */
.pqm-chat-msg-system {
    text-align: center;
    align-self: center;
    max-width: 90%;
}

.pqm-chat-msg-system .pqm-chat-msg-bubble {
    background: transparent;
    color: #95a5a6;
    font-size: 11px;
    font-style: italic;
    padding: 4px 10px;
}

/* ─── Estado vacío del chat ─── */
.pqm-chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #bdc3c7;
    flex: 1;
    text-align: center;
    gap: 10px;
}

.pqm-chat-empty-state p {
    margin: 0;
    font-size: 13px;
    color: #95a5a6;
}

/* ─── Input de mensaje ─── */
.pqm-chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #f8f9fa;
    border-top: 1px solid #ecf0f1;
    flex-shrink: 0;
}

.pqm-chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid #e0e5eb;
    border-radius: 20px;
    font-size: 13px;
    color: #333;
    background: #ffffff;
    transition: all 0.2s;
    outline: none;
    box-shadow: none;
}

.pqm-chat-input:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.pqm-chat-input::placeholder { color: #bdc3c7; }

.pqm-chat-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #0c2d48, #145374);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.pqm-chat-send:hover {
    background: linear-gradient(135deg, #145374, #1a6fa0);
    transform: scale(1.05);
}

.pqm-chat-send:active { transform: scale(0.95); }
.pqm-chat-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ═══ RESPONSIVE — Chat ═══ */
@media (max-width: 640px) {
    .pqm-chat-toggle {
        bottom: 16px;
        right: 16px;
        width: 50px;
        height: 50px;
    }

    .pqm-chat-widget {
        bottom: 78px;
        right: 8px;
        left: 8px;
        width: auto;
        max-height: 70vh;
        border-radius: 14px;
    }

    .pqm-chat-messages {
        max-height: 50vh;
    }
}

/* ═══ DARK MODE — Chat ═══ */
@media (prefers-color-scheme: dark) {
    .pqm-chat-widget {
        background: #1a2332;
        box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
    }

    .pqm-chat-nickname-inner h4 { color: #ecf0f1; }
    .pqm-chat-nickname-desc { color: #7f8c8d; }

    .pqm-chat-nickname-input {
        background: #34495e;
        border-color: #4a6785;
        color: #ecf0f1;
    }

    .pqm-chat-nickname-input::placeholder { color: #7f8c8d; }
    .pqm-chat-nickname-input:focus { background: #3d566e; border-color: #3498db; }

    .pqm-chat-online-bar { background: #2c3e50; border-bottom-color: #34495e; }

    .pqm-chat-messages { background: #1a2332; }

    .pqm-msg-other .pqm-chat-msg-bubble {
        background: #2c3e50;
        color: #ecf0f1;
    }

    .pqm-msg-mine .pqm-chat-msg-nick { color: #bdc3c7; }

    .pqm-chat-input-area { background: #2c3e50; border-top-color: #34495e; }

    .pqm-chat-input {
        background: #34495e;
        border-color: #4a6785;
        color: #ecf0f1;
    }

    .pqm-chat-input::placeholder { color: #7f8c8d; }
    .pqm-chat-input:focus { border-color: #3498db; background: #3d566e; }
}
