/**
 * Jalabyte ISP - Coverage Map Styles
 * Interactive coverage map styling for beautiful UI/UX
 */

/* =============================================================================
   Base Coverage Map Styles
   ============================================================================= */

.coverage-map-container {
    position: relative;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    min-height: 400px;
}

#coverage-map {
    width: 100%;
    height: 450px;
    border-radius: 12px;
    position: relative;
    z-index: 1;
}

/* Leaflet map customizations */
.leaflet-container {
    font-family:
        "Inter",
        -apple-system,
        BlinkMacSystemFont,
        sans-serif;
}

.leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.leaflet-popup-tip {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* =============================================================================
   Custom Markers and Icons
   ============================================================================= */

.custom-div-icon {
    border: none !important;
    background: transparent !important;
}

.custom-marker {
    transition: all 0.3s ease;
    cursor: pointer;
}

.custom-marker:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3) !important;
}

.custom-marker.olt {
    animation: pulse-olt 2s infinite;
}

.custom-marker.odp {
    animation: pulse-odp 2s infinite;
}

@keyframes pulse-olt {
    0%,
    100% {
        box-shadow: 0 2px 8px rgba(0, 102, 204, 0.3);
    }
    50% {
        box-shadow: 0 4px 16px rgba(0, 102, 204, 0.6);
    }
}

@keyframes pulse-odp {
    0%,
    100% {
        box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
    }
    50% {
        box-shadow: 0 4px 16px rgba(40, 167, 69, 0.6);
    }
}

/* User location marker */
.user-marker {
    width: 30px;
    height: 30px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    position: relative;
    animation: bounce 1s ease-out;
}

.user-marker.covered {
    border: 3px solid #28a745;
    color: #28a745;
}

.user-marker.not-covered {
    border: 3px solid #dc3545;
    color: #dc3545;
}

@keyframes bounce {
    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

/* =============================================================================
   Loading States and Disabled Elements
   ============================================================================= */

.coverage-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loader-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    min-width: 200px;
}

.loader-content i {
    font-size: 24px;
    color: #007bff;
    margin-bottom: 15px;
    display: block;
}

.loader-content span {
    font-size: 16px;
    color: #333;
    font-weight: 500;
}

/* Disabled button states */
button:disabled,
button.disabled {
    opacity: 0.6 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

button:disabled:hover,
button.disabled:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* Coverage form loading state */
.coverage-form.loading {
    pointer-events: none;
    opacity: 0.7;
}

.coverage-form.loading input {
    background-color: #f8f9fa;
}

/* Locate control disabled state */
.locate-control button:disabled {
    background-color: #e9ecef !important;
    color: #6c757d !important;
    cursor: not-allowed !important;
}

/* =============================================================================
   Notifications and Messages
   ============================================================================= */

.coverage-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    max-width: 400px;
    z-index: 10000;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: slideInRight 0.3s ease-out;
}

.coverage-notification.success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.coverage-notification.error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.coverage-notification.warning {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
}

.coverage-notification.info {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

.notification-content {
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.notification-content i {
    font-size: 18px;
    flex-shrink: 0;
}

.notification-content span {
    flex: 1;
    font-weight: 500;
}

.notification-content button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.notification-content button:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* =============================================================================
   Throttle/Debounce Visual Feedback
   ============================================================================= */

.map-container.processing {
    cursor: wait !important;
    pointer-events: none;
}

.map-container.processing::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    z-index: 1000;
    pointer-events: none;
}

/* Form throttle indicator */
.form-throttled {
    position: relative;
}

.form-throttled::after {
    content: "Mohon tunggu...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    pointer-events: none;
}

.user-marker::after {
    content: "";
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid currentColor;
    animation: radar 2s infinite;
}

@keyframes bounce {
    0% {
        transform: translateY(-20px) scale(0);
    }
    50% {
        transform: translateY(-10px) scale(1.1);
    }
    100% {
        transform: translateY(0) scale(1);
    }
}

@keyframes radar {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

/* =============================================================================
   Popup Styles
   ============================================================================= */

.coverage-popup .leaflet-popup-content {
    margin: 0;
    padding: 0;
    width: auto !important;
}

.coverage-location-popup {
    min-width: 250px;
    font-size: 14px;
}

.popup-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 16px;
    margin: -12px -16px 12px -16px;
    display: flex;
    align-items: center;
    border-radius: 8px 8px 0 0;
}

.popup-header strong {
    font-weight: 600;
}

.location-type {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.location-type.olt {
    background: #e3f2fd;
    color: #0066cc;
}

.location-type.odp {
    background: #e8f5e8;
    color: #28a745;
}

.location-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    line-height: 1.4;
}

.detail-row i {
    color: #6c757d;
    width: 16px;
    flex-shrink: 0;
    margin-top: 2px;
}

/* Coverage Result Popup */
.coverage-result {
    min-width: 280px;
    text-align: center;
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

.coverage-result.covered .result-header {
    color: #28a745;
}

.coverage-result.not-covered .result-header {
    color: #dc3545;
}

.result-message {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 12px;
    color: #495057;
}

.nearest-location {
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 6px;
    margin: 8px 0;
}

.nearest-location small {
    color: #6c757d;
}

.result-actions {
    margin-top: 16px;
}

.result-actions .btn {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s ease;
}

.result-actions .btn-primary {
    background: #007bff;
    color: white;
    border: none;
}

.result-actions .btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
}

.result-actions .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* =============================================================================
   Map Controls
   ============================================================================= */

.coverage-legend {
    background: white;
    padding: 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 14px;
    min-width: 200px;
}

.coverage-legend h5 {
    margin: 0 0 12px 0;
    font-size: 16px;
    font-weight: 600;
    color: #343a40;
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.legend-marker {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    position: relative;
    flex-shrink: 0;
}

.legend-marker.olt {
    background: #0066cc;
}

.legend-marker.odp {
    background: #28a745;
}

.legend-marker::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 2px;
}

.legend-circle {
    width: 20px;
    height: 20px;
    border: 2px solid #007bff;
    background: rgba(0, 123, 255, 0.1);
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-stats {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e9ecef;
    color: #6c757d;
    text-align: center;
}

/* Locate Control */
.locate-control {
    background: white;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    margin-bottom: 10px;
}

.locate-control button {
    background: none;
    border: none;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #495057;
    transition: all 0.3s ease;
}

.locate-control button:hover {
    background: #f8f9fa;
    color: #007bff;
}

/* =============================================================================
   Loading and Notifications
   ============================================================================= */

.coverage-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.loader-content {
    background: white;
    padding: 24px 32px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 16px;
    font-weight: 500;
    color: #495057;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.loader-content i {
    color: #007bff;
    font-size: 20px;
}

.coverage-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    max-width: 400px;
    z-index: 9998;
    animation: slideInRight 0.5s ease;
}

.notification-content {
    background: white;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border-left: 4px solid;
}

.coverage-notification.success .notification-content {
    border-left-color: #28a745;
}

.coverage-notification.error .notification-content {
    border-left-color: #dc3545;
}

.coverage-notification.warning .notification-content {
    border-left-color: #ffc107;
}

.coverage-notification.info .notification-content {
    border-left-color: #17a2b8;
}

.notification-content i {
    flex-shrink: 0;
    margin-top: 2px;
}

.coverage-notification.success i {
    color: #28a745;
}
.coverage-notification.error i {
    color: #dc3545;
}
.coverage-notification.warning i {
    color: #ffc107;
}
.coverage-notification.info i {
    color: #17a2b8;
}

.notification-content span {
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
    color: #495057;
}

.notification-content button {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    margin-left: 8px;
    flex-shrink: 0;
}

.notification-content button:hover {
    color: #495057;
}

/* =============================================================================
   Coverage Section Integration
   ============================================================================= */

.coverage .coverage-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: center;
}

.coverage-map {
    position: relative;
    min-height: 450px;
}

.coverage-map.loading::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.coverage-map.loading::after {
    content: "Memuat peta...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 11;
    font-weight: 500;
    color: #6c757d;
}

/* =============================================================================
   Responsive Design
   ============================================================================= */

@media (max-width: 768px) {
    .coverage .coverage-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .coverage-text {
        order: 1;
    }

    .coverage-map {
        order: 2;
    }

    #coverage-map {
        height: 350px;
    }

    .coverage-legend {
        padding: 12px;
        min-width: 160px;
    }

    .coverage-location-popup,
    .coverage-result {
        min-width: 200px;
    }

    .coverage-notification {
        left: 10px;
        right: 10px;
        max-width: none;
    }

    .loader-content {
        margin: 0 20px;
        padding: 20px 24px;
    }
}

@media (max-width: 480px) {
    #coverage-map {
        height: 300px;
    }

    .popup-header {
        padding: 10px 12px;
        margin: -10px -12px 10px -12px;
    }

    .coverage-legend {
        font-size: 12px;
        padding: 10px;
    }

    .legend-marker,
    .legend-circle {
        width: 16px;
        height: 16px;
    }
}

/* =============================================================================
   Animations
   ============================================================================= */

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

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* =============================================================================
   Dark Mode Support (Optional)
   ============================================================================= */

@media (prefers-color-scheme: dark) {
    .coverage-map-container {
        background: #2d3748;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }

    .coverage-legend,
    .locate-control,
    .notification-content,
    .loader-content {
        background: #2d3748;
        color: #e2e8f0;
    }

    .coverage-legend h5,
    .notification-content span {
        color: #e2e8f0;
    }

    .detail-row i {
        color: #a0aec0;
    }

    .nearest-location {
        background: #4a5568;
    }

    .legend-stats {
        border-top-color: #4a5568;
        color: #a0aec0;
    }
}

/* =============================================================================
   Coverage Tooltips
   ============================================================================= */

.coverage-tooltip {
    background: rgba(0, 0, 0, 0.8) !important;
    border: none !important;
    border-radius: 6px !important;
    color: white !important;
    font-size: 12px !important;
    padding: 6px 10px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

.coverage-tooltip::before {
    border-top-color: rgba(0, 0, 0, 0.8) !important;
}

/* =============================================================================
   Print Styles
   ============================================================================= */

@media print {
    .coverage-loader,
    .coverage-notification,
    .locate-control,
    .leaflet-control-zoom {
        display: none !important;
    }

    #coverage-map {
        height: 400px !important;
        break-inside: avoid;
    }

    .coverage-legend {
        break-inside: avoid;
    }
}
