/**
 * Frontend Styles
 *
 * @package LoveCatz_Map_Pinpoints
 */

/* Map Container */
.lcmp-map-container {
    margin: 20px 0;
    width: 100%;
    position: relative; /* anchors the quick-add pin form overlay */
}

.lcmp-map {
    width: 100%;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* No Locations Message */
.lcmp-no-locations {
    padding: 30px;
    text-align: center;
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    color: #6c757d;
    font-size: 16px;
}

/* Leaflet Popup Customization */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.2);
}

.leaflet-popup-content {
    margin: 15px 20px;
    line-height: 1.6;
    min-width: 200px;
}

.leaflet-popup-tip {
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.2);
}

/* Popup Content Styles */
.lcmp-popup {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.lcmp-popup-title {
    margin: 0 0 12px 0;
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    line-height: 1.4;
}

.lcmp-popup-description {
    margin: 12px 0;
    color: #555;
    font-size: 14px;
    line-height: 1.6;
}

.lcmp-popup-description p {
    margin: 8px 0;
}

.lcmp-popup-description p:first-child {
    margin-top: 0;
}

.lcmp-popup-description p:last-child {
    margin-bottom: 0;
}

.lcmp-popup-address {
    margin: 12px 0 0 0;
    padding: 10px;
    background: #f8f9fa;
    border-left: 3px solid #2271b1;
    border-radius: 4px;
    font-size: 13px;
    color: #495057;
}

/* Free-text comment / product list shown inside a pin popup */
.lcmp-pin-comment {
    margin: 10px 0;
    padding: 10px 12px;
    background: #f8f9fa;
    border-left: 3px solid #c30b82;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.55;
    color: #495057;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.lcmp-popup-address:before {
    content: "📍 ";
    margin-right: 5px;
}

/* Marker Cluster Styles
   Rendered by LCMP.initMap via a custom iconCreateFunction. The outer element
   carries .lcmp-cluster (+ a size class) and the inner div holds the count. */
.lcmp-cluster {
    background: transparent;
    border: none;
}

.lcmp-cluster-inner {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #2271b1;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    border: 3px solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    transition: transform 0.15s ease;
}

.lcmp-cluster:hover .lcmp-cluster-inner {
    transform: scale(1.1);
}

/* 10-99 markers */
.lcmp-cluster-medium .lcmp-cluster-inner {
    background: #f59e0b;
}

/* 100+ markers */
.lcmp-cluster-large .lcmp-cluster-inner {
    background: #dc2626;
}

/* Responsive Styles */
@media screen and (max-width: 768px) {
    .lcmp-popup-content {
        min-width: 150px;
    }
    
    .lcmp-popup-title {
        font-size: 16px;
    }
    
    .lcmp-popup-description {
        font-size: 13px;
    }
}

@media screen and (max-width: 480px) {
    .lcmp-map-container {
        margin: 15px 0;
    }
    
    .lcmp-popup-title {
        font-size: 15px;
    }
    
    .lcmp-popup-description {
        font-size: 12px;
    }
    
    .lcmp-popup-address {
        font-size: 12px;
        padding: 8px;
    }
}

/* Accessibility */
.leaflet-container a.leaflet-popup-close-button {
    color: #333;
    font-size: 18px;
    padding: 8px;
}

.leaflet-container a.leaflet-popup-close-button:hover,
.leaflet-container a.leaflet-popup-close-button:focus {
    color: #000;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

/* Loading State */
.lcmp-map-loading {
    position: relative;
}

.lcmp-map-loading:before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2271b1;
    border-radius: 50%;
    animation: lcmp-spin 1s linear infinite;
    z-index: 1000;
}

@keyframes lcmp-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Print Styles */
@media print {
    .leaflet-control-container {
        display: none;
    }
    
    .lcmp-map {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* Interactive Map Controls */
.lcmp-map-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.lcmp-btn {
    padding: 10px 20px;
    background: #fff;
    border: 2px solid #2271b1;
    border-radius: 6px;
    color: #2271b1;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.lcmp-btn:hover {
    background: #f0f6fc;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(34, 113, 177, 0.15);
}

.lcmp-btn.active {
    background: #2271b1;
    color: #fff;
}

.lcmp-btn .lcmp-icon {
    font-size: 16px;
}

/* Map Mode Cursors */
.lcmp-mode-add .leaflet-container {
    cursor: crosshair !important;
}

.lcmp-mode-remove .leaflet-container {
    cursor: pointer !important;
}

/* Custom Marker Pins
   ---------------------------------------------------------------------------
   The pin is a 30x30 SQUARE with one un-rounded corner, rotated -45deg so that
   corner points straight down. It must be square — the previous 30x42 box made
   `border-radius` produce a stretched, elliptical head, which is what read as
   "distorted".

   Geometry, so the tip lands exactly on the coordinate:
     - rotating a 30x30 square by 45deg yields a bounding box of 30*sqrt(2) ≈ 42.4px
     - the tip sits sqrt(2)/2 * 30 ≈ 21.2px below the square's centre,
       i.e. at local (15, 36.2)
     - the divIcon's iconAnchor is [15, 42], so shifting the square down by
       42 - 36.2 = 5.8px puts the tip on the anchor. The old
       `left:50%; top:50%; margin:-42px 0 0 -15px` pushed the pin ~21px too high,
       so markers floated above their real position. */
.lcmp-marker-pin {
    width: 30px;
    height: 30px;
    border-radius: 50% 50% 50% 0;
    background: #c30b82;
    position: absolute;
    left: 0;
    top: 5.8px;
    transform: rotate(-45deg);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.lcmp-marker-pin:after {
    content: '';
    width: 14px;
    height: 14px;
    /* (30 - 14) / 2 = 8px — centres the dot, so the -45deg rotation leaves it
       in the middle of the head instead of off to one side. */
    margin: 8px 0 0 8px;
    background: #fff;
    position: absolute;
    border-radius: 50%;
}

.lcmp-marker-pin.lcmp-temp {
    background: #ff6b6b;
}

.lcmp-marker-pin.lcmp-permanent {
    background: #2271b1;
}

.lcmp-custom-marker, .lcmp-temp-marker, .lcmp-permanent-marker {
    background: transparent;
    border: none;
}

/* Popup Styles for Temporary Markers */
.lcmp-popup-temp .lcmp-popup-coords {
    margin: 10px 0;
    padding: 8px;
    background: #f0f6fc;
    border-radius: 4px;
    font-size: 12px;
    color: #555;
    font-family: monospace;
}

.lcmp-popup-remove {
    margin-top: 12px;
    padding: 8px 16px;
    background: #dc3545;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    width: 100%;
    transition: background 0.2s ease;
}

.lcmp-popup-remove:hover {
    background: #c82333;
}

/* Notification Messages */
.lcmp-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    font-size: 14px;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
    max-width: 350px;
}

.lcmp-notification-show {
    opacity: 1;
    transform: translateX(0);
}

.lcmp-notification-success {
    border-left: 4px solid #28a745;
}

.lcmp-notification-error {
    border-left: 4px solid #dc3545;
}

.lcmp-notification-info {
    border-left: 4px solid #2271b1;
}

/* Responsive Styles for Interactive Controls */
@media screen and (max-width: 768px) {
    .lcmp-map-controls {
        gap: 8px;
    }
    
    .lcmp-btn {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .lcmp-notification {
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

@media screen and (max-width: 480px) {
    .lcmp-btn {
        flex: 1;
        justify-content: center;
    }

    /* The marker pin is deliberately NOT scaled down here: the divIcon's
       iconAnchor is a fixed [15, 42] in frontend.js, so shrinking the CSS pin
       without moving the anchor would push the tip off the coordinate. */
}

/* Quick Add Pin Form
   Overlay panel shown after clicking the map in "add" mode, letting the user
   type a short description (keterangan) for the new point. */
.lcmp-pin-form {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 900;
    align-items: center;
    justify-content: center;
}

.lcmp-pin-form-show {
    display: flex;
}

.lcmp-pin-form-inner {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    width: 320px;
    max-width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.lcmp-pin-form-title {
    margin: 0 0 12px;
    font-size: 16px;
    font-weight: 600;
    color: #1d2327;
}

.lcmp-pin-form-label {
    display: block;
    font-size: 13px;
    margin-bottom: 6px;
    color: #555;
}

.lcmp-pin-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

.lcmp-pin-input:focus {
    border-color: #2271b1;
    outline: none;
    box-shadow: 0 0 0 1px #2271b1;
}

.lcmp-pin-coords {
    margin-top: 8px;
    font-size: 12px;
    color: #777;
    font-family: Consolas, Monaco, monospace;
}

.lcmp-pin-actions {
    margin-top: 16px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.lcmp-pin-btn {
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid transparent;
}

.lcmp-pin-cancel {
    background: #fff;
    border-color: #ccd0d4;
    color: #555;
}

.lcmp-pin-cancel:hover {
    background: #f6f7f7;
}

.lcmp-pin-save {
    background: #2271b1;
    border-color: #2271b1;
    color: #fff;
}

.lcmp-pin-save:hover {
    background: #135e96;
}

@media screen and (max-width: 480px) {
    .lcmp-pin-form-inner {
        padding: 16px;
    }
    
    .lcmp-pin-actions {
        justify-content: stretch;
    }
    
    .lcmp-pin-btn {
        flex: 1;
    }
}
