/* ========================
   IRAN MAP WIDGET v4
   ======================== */
.imw-container {
    position: relative;
    width: 100%;
    margin: 0 auto;
}

.imw-svg-box {
    position: relative;
    width: 100%;
    line-height: 0;
    overflow: hidden;
}

.imw-svg-box > svg,
.imw-svg-box > svg.imw-svg {
    display: block;
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
}

.imw-svg-box svg path,
.imw-svg-box svg polygon {
    cursor: pointer;
    transition: fill 0.25s ease, stroke 0.25s ease, filter 0.25s ease;
}

.imw-empty {
    min-height: 350px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f9f9f9;
    border: 2px dashed #ddd;
    border-radius: 12px;
    color: #999;
    text-align: center;
    gap: 8px;
}
.imw-empty a { color: #3498db; }

/* ========================
   OVERLAY
   ======================== */
.imw-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999990;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.imw-overlay.active {
    display: block;
    opacity: 1;
}

/* ========================
   POPUP - Now as modal
   ======================== */
.imw-popup {
    position: fixed;
    z-index: 999999;
    display: none;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25), 0 4px 15px rgba(0,0,0,0.1);
    width: 380px;
    max-width: 92vw;
    direction: rtl;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    top: 50%;
    left: 50%;
    margin-right: -50%;
    transform: translate(-50%, -50%) scale(0.95);
}
.imw-popup.active {
    display: block !important;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Header */
.imw-popup-header {
    padding: 16px 20px;
    background: #2c3e50;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.imw-popup-title {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    line-height: 1.5;
    flex: 1;
}

.imw-popup-count {
    background: #27ae60;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
}

.imw-popup-close {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
    line-height: 1;
    padding: 0;
}
.imw-popup-close:hover {
    background: rgba(255,255,255,0.3);
}

/* Body */
.imw-popup-body {
    padding: 16px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Scrollbar */
.imw-popup-body::-webkit-scrollbar {
    width: 5px;
}
.imw-popup-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}
.imw-popup-body::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}
.imw-popup-body::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* ========================
   AGENCY CARD
   ======================== */
.imw-agency-card {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.imw-agency-card:last-child {
    margin-bottom: 0;
}
.imw-agency-card:hover {
    border-color: #3498db;
    box-shadow: 0 2px 8px rgba(52,152,219,0.12);
}

/* Agency Name Header */
.imw-agency-name {
    font-size: 14px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 8px;
}

.imw-agency-name::before {
    content: '';
    width: 4px;
    height: 18px;
    background: linear-gradient(180deg, #3498db, #27ae60);
    border-radius: 2px;
    flex-shrink: 0;
}

.imw-agency-number {
    background: #3498db;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: auto;
}

/* Card Row */
.imw-card-row {
    display: flex;
    gap: 8px;
    padding: 5px 0;
    align-items: flex-start;
}

.imw-card-ico {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    margin-top: 3px;
    opacity: 0.4;
}
.imw-card-ico svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.imw-card-rc {
    flex: 1;
    min-width: 0;
}

.imw-popup-label {
    font-size: 10px;
    color: #999;
    font-weight: 500;
    display: block;
    margin-bottom: 1px;
}

.imw-popup-value {
    font-size: 12px;
    color: #333;
    font-weight: 600;
    word-break: break-word;
    line-height: 1.6;
}
.imw-popup-value a {
    color: #3498db;
    text-decoration: none;
}
.imw-popup-value a:hover {
    text-decoration: underline;
}

/* No Agency */
.imw-no-agency {
    text-align: center;
    padding: 30px 20px;
    color: #999;
}
.imw-no-agency-ico {
    font-size: 36px;
    margin-bottom: 10px;
    opacity: 0.3;
}
.imw-no-agency p {
    font-size: 13px;
    line-height: 1.8;
    margin: 0;
}

/* ========================
   TOOLTIP
   ======================== */
.imw-tip {
    position: fixed;
    z-index: 999998;
    display: none;
    background: rgba(44,62,80,0.92);
    color: #fff;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    pointer-events: none;
    white-space: nowrap;
    direction: rtl;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.imw-tip.active {
    display: block !important;
    opacity: 1;
}
.imw-tip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(44,62,80,0.92);
}

/* Province has agency indicator */
.imw-has-badge {
    position: relative;
}

/* ========================
   RESPONSIVE
   ======================== */
@media (max-width: 767px) {
    .imw-popup {
        width: 94vw !important;
        max-height: 80vh !important;
        border-radius: 14px 14px 0 0;
        top: auto !important;
        bottom: 0 !important;
        left: 50% !important;
        transform: translateX(-50%) translateY(100%);
    }
    .imw-popup.active {
        transform: translateX(-50%) translateY(0);
    }
    .imw-popup-title { font-size: 14px; }
    .imw-popup-value { font-size: 11px; }
    .imw-agency-name { font-size: 13px; }
}

/* ========================
   ANIMATIONS
   ======================== */
@keyframes imw-fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.imw-agency-card {
    animation: imw-fadeIn 0.3s ease forwards;
}
.imw-agency-card:nth-child(1) { animation-delay: 0s; }
.imw-agency-card:nth-child(2) { animation-delay: 0.05s; }
.imw-agency-card:nth-child(3) { animation-delay: 0.1s; }
.imw-agency-card:nth-child(4) { animation-delay: 0.15s; }
.imw-agency-card:nth-child(5) { animation-delay: 0.2s; }
.imw-agency-card:nth-child(6) { animation-delay: 0.25s; }