/**
 * ========================================
 * LEAFLET POPUP - GLOBAL STYLING
 * ========================================
 * Modern, Professional & Responsive Popup Design
 * Compatible with Velzon Theme Branding
 *
 * Features:
 * - Auto-pan to prevent clipping
 * - Max-width/height with scrollable content
 * - Clean modern design with soft shadows
 * - Consistent branding colors
 * - Dark mode support
 * ========================================
 */

/* ========================================
   POPUP CONTAINER & WRAPPER
   ======================================== */

/* Main popup wrapper - prevent overflow */
.leaflet-popup {
    margin-bottom: 20px;
}

/* Popup content wrapper - set max dimensions */
.leaflet-popup-content-wrapper {
    border-radius: 12px !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12),
                0 2px 8px rgba(0, 0, 0, 0.08) !important;
    padding: 0 !important;
    overflow: hidden;
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.05);

    /* Prevent popup from being too large */
    max-width: 420px !important;
    max-height: 500px !important;
}

/* Popup content - scrollable if content is long */
.leaflet-popup-content {
    margin: 0 !important;
    max-width: 420px !important;
    max-height: 500px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;

    /* Custom scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: rgba(104, 124, 254, 0.3) transparent;
}

/* Webkit scrollbar styling */
.leaflet-popup-content::-webkit-scrollbar {
    width: 6px;
}

.leaflet-popup-content::-webkit-scrollbar-track {
    background: transparent;
}

.leaflet-popup-content::-webkit-scrollbar-thumb {
    background: rgba(104, 124, 254, 0.3);
    border-radius: 3px;
}

.leaflet-popup-content::-webkit-scrollbar-thumb:hover {
    background: rgba(104, 124, 254, 0.5);
}

/* Popup tip (arrow) */
.leaflet-popup-tip {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-top: none;
    border-left: none;
}

/* Close button */
.leaflet-popup-close-button {
    color: #ffffff !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    padding: 4px 8px !important;
    text-align: center !important;
    width: 28px !important;
    height: 28px !important;
    line-height: 20px !important;
    z-index: 10 !important;
    opacity: 0.9 !important;
    transition: all 0.2s ease;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    top: 8px !important;
    right: 8px !important;
    position: absolute !important;
}

.leaflet-popup-close-button:hover {
    opacity: 1 !important;
    background: rgba(0, 0, 0, 0.3);
    transform: scale(1.05);
}

/* ========================================
   POPUP HEADER STYLING
   ======================================== */

.popup-header,
.popup-header-edit,
.leaflet-popup-header {
    background: linear-gradient(135deg, #687cfe 0%, #764ba2 100%);
    color: #ffffff;
    padding: 14px 16px;
    font-weight: 600;
    font-size: 15px;
    border-radius: 12px 12px 0 0;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(104, 124, 254, 0.15);
}

.popup-header i,
.popup-header-edit i,
.leaflet-popup-header i {
    font-size: 18px;
    opacity: 0.95;
}

/* ========================================
   POPUP CONTENT BODY
   ======================================== */

.popup-content,
.popup-content-edit,
.leaflet-popup-body {
    padding: 16px;
    font-size: 13px;
    line-height: 1.6;
    color: #495057;
}

/* Content rows */
.popup-content .row,
.popup-content-edit .row,
.leaflet-popup-body .row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 6px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    gap: 12px;
}

.popup-content .row:last-child,
.popup-content-edit .row:last-child,
.leaflet-popup-body .row:last-child {
    border-bottom: none;
}

/* Labels */
.popup-content .label,
.popup-content-edit .label,
.leaflet-popup-body .label {
    font-weight: 600;
    color: #495057;
    min-width: 110px;
    width: 110px;
    flex-shrink: 0;
}

/* Values */
.popup-content .value,
.popup-content-edit .value,
.leaflet-popup-body .value {
    color: #212529;
    text-align: right;
    font-weight: 500;
    flex-grow: 1;
    word-wrap: break-word;
}

/* ========================================
   STATUS BADGES
   ======================================== */

.status-badge,
.popup-status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Status: Tersalurkan - Warning/Pending (Kuning lembut) */
.status-tersalurkan {
    background: linear-gradient(135deg, #f7b731 0%, #fa8231 100%);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(247, 183, 49, 0.35);
}

/* Status: Diterima - Success (Hijau) */
.status-diterima {
    background: linear-gradient(135deg, #0ab39c 0%, #059669 100%);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(10, 179, 156, 0.35);
}

/* Status: Ditolak - Danger (Merah) */
.status-ditolak {
    background: linear-gradient(135deg, #f06548 0%, #dc2626 100%);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(240, 101, 72, 0.35);
}

/* ========================================
   INFO ITEMS
   ======================================== */

.popup-info-item {
    padding: 8px 0;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.popup-info-item i {
    color: #687cfe;
    font-size: 16px;
    margin-top: 2px;
    flex-shrink: 0;
}

.popup-info-item .info-label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 2px;
    font-size: 12px;
}

.popup-info-item .info-value {
    color: #212529;
    font-size: 13px;
}

/* ========================================
   POPUP FOOTER (Optional)
   ======================================== */

.popup-footer {
    padding: 12px 16px;
    background: #f8f9fa;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.popup-footer .btn {
    font-size: 12px;
    padding: 6px 14px;
    border-radius: 6px;
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */

@media (max-width: 576px) {
    .leaflet-popup-content-wrapper {
        max-width: 90vw !important;
        max-height: 70vh !important;
    }

    .leaflet-popup-content {
        max-width: 90vw !important;
        max-height: 70vh !important;
    }

    .popup-header,
    .popup-header-edit,
    .leaflet-popup-header {
        padding: 12px 14px;
        font-size: 14px;
    }

    .popup-content,
    .popup-content-edit,
    .leaflet-popup-body {
        padding: 12px;
        font-size: 12px;
    }
}

/* ========================================
   DARK MODE SUPPORT
   ======================================== */

[data-bs-theme="dark"] .leaflet-popup-content-wrapper {
    background: #1f2937 !important;
    border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .leaflet-popup-tip {
    background: #1f2937 !important;
    border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .popup-content,
[data-bs-theme="dark"] .popup-content-edit,
[data-bs-theme="dark"] .leaflet-popup-body {
    color: #e5e7eb;
}

[data-bs-theme="dark"] .popup-content .label,
[data-bs-theme="dark"] .popup-content-edit .label,
[data-bs-theme="dark"] .leaflet-popup-body .label {
    color: #9ca3af;
}

[data-bs-theme="dark"] .popup-content .value,
[data-bs-theme="dark"] .popup-content-edit .value,
[data-bs-theme="dark"] .leaflet-popup-body .value {
    color: #f3f4f6;
}

[data-bs-theme="dark"] .popup-content .row,
[data-bs-theme="dark"] .popup-content-edit .row,
[data-bs-theme="dark"] .leaflet-popup-body .row {
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

[data-bs-theme="dark"] .popup-footer {
    background: #111827;
    border-top-color: rgba(255, 255, 255, 0.05);
}

/* ========================================
   ANIMATION & TRANSITIONS
   ======================================== */

.leaflet-popup {
    animation: popupFadeIn 0.3s ease-out;
}

@keyframes popupFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Smooth transitions */
.leaflet-popup-content-wrapper,
.popup-header,
.popup-content .row {
    transition: all 0.2s ease;
}

/* ========================================
   LOADING STATE (Optional)
   ======================================== */

.popup-loading {
    padding: 30px;
    text-align: center;
    color: #687cfe;
}

.popup-loading i {
    font-size: 24px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ========================================
   CUSTOM MARKER PIN STYLES
   ======================================== */

.custom-marker,
.custom-marker-edit {
    background: transparent;
    border: none;
}

.marker-pin,
.marker-pin-edit {
    width: 32px;
    height: 42px;
    position: relative;
    background: #ffffff;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid #687cfe; /* Default - akan di-override inline */
    transition: all 0.3s ease;
}

.marker-pin:hover,
.marker-pin-edit:hover {
    transform: rotate(-45deg) scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.marker-pin i,
.marker-pin-edit i {
    transform: rotate(45deg);
    font-size: 18px;
    color: #687cfe; /* Default - akan di-override inline */
    display: block;
}

/* Marker pulsing animation - hanya outline/border yang pulsing */
.marker-pulse {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50% 50% 50% 0;
    background: transparent; /* Transparan - tidak menutupi icon */
    border: 2px solid rgba(104, 124, 254, 0.6); /* Default - outline yang terlihat */
    animation: pulseOutline 2s ease-in-out infinite;
    z-index: -1;
    pointer-events: none;
}

/* Fallback untuk marker tanpa inline style */
.marker-pin::before,
.marker-pin-edit::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50% 50% 50% 0;
    background: transparent;
    border: 2px solid rgba(104, 124, 254, 0.5);
    animation: pulseOutline 2s ease-in-out infinite;
    z-index: -1;
}

/* ========================================
   PUBLIC PAGE MARKER STYLES
   Optimized untuk visibility dengan heatmap
   ======================================== */

.custom-marker-public {
    background: transparent;
    border: none;
}

.marker-pin-public {
    width: 32px;
    height: 42px;
    position: relative;
    background: #ffffff;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid #687cfe; /* Default - di-override inline */
    transition: all 0.3s ease;
    z-index: 600; /* Di atas heatmap (500) tapi di bawah controls */
}

.marker-pin-public:hover {
    transform: rotate(-45deg) scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
    z-index: 650; /* Lebih tinggi saat hover */
}

.marker-pin-public i {
    transform: rotate(45deg);
    font-size: 18px;
    color: #687cfe; /* Default - di-override inline */
    display: block;
}

/* Pulsing animation untuk public marker - lebih subtle */
.marker-pulse-public {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50% 50% 50% 0;
    background: transparent;
    border: 2px solid rgba(104, 124, 254, 0.4); /* Lebih subtle dari admin */
    animation: pulseOutlineSubtle 2.5s ease-in-out infinite; /* Lebih lambat */
    z-index: -1;
    pointer-events: none;
}

/* Animation yang lebih subtle untuk public page (agar tidak ganggu heatmap) */
@keyframes pulseOutlineSubtle {
    0%, 100% {
        transform: scale(1);
        opacity: 0.6; /* Lebih subtle */
    }
    50% {
        transform: scale(1.3); /* Tidak terlalu besar */
        opacity: 0;
    }
}

/* Pulsing animation - hanya outline yang scale & fade */
@keyframes pulseOutline {
    0%, 100% {
        transform: scale(1);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.4);
        opacity: 0;
    }
}

/* Fallback animation lama untuk backward compatibility */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.3;
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

.popup-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.1);
    margin: 12px 0;
}

[data-bs-theme="dark"] .popup-divider {
    background: rgba(255, 255, 255, 0.1);
}

.popup-highlight {
    background: rgba(104, 124, 254, 0.1);
    padding: 8px 12px;
    border-radius: 6px;
    border-left: 3px solid #687cfe;
}

.popup-text-muted {
    color: #6c757d;
    font-size: 12px;
}

.popup-text-primary {
    color: #687cfe;
    font-weight: 600;
}

.popup-text-success {
    color: #0ab39c;
    font-weight: 600;
}
