﻿/* ===== استایل‌های کلی ===== */
* {
    box-sizing: border-box;
}

.pm-container {
    padding: 20px;
    max-width: 1300px;
    margin: 0 auto;
}

.pm-header {
    margin-bottom: 25px;
    border-bottom: 2px solid #e8e8e8;
    padding-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

    .pm-header h2 {
        margin: 0;
        color: #2c3e50;
        font-size: 24px;
    }

        .pm-header h2 i {
            color: #3498db;
        }

    .pm-header small {
        color: #7f8c8d;
        font-size: 14px;
    }

    .pm-header .badge {
        background: #3498db;
        color: white;
        padding: 5px 15px;
        border-radius: 20px;
        font-size: 14px;
    }

/* ===== فیلتر ===== */
.pm-filter {
    background: #f8f9fa;
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 25px;
    border: 1px solid #e9ecef;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

    .pm-filter .form-group {
        margin: 0;
        flex: 1;
        min-width: 150px;
    }

    .pm-filter label {
        font-size: 12px;
        font-weight: 600;
        color: #555;
        display: block;
        margin-bottom: 3px;
    }

    .pm-filter input {
        width: 100%;
        padding: 8px 12px;
        border: 1px solid #ddd;
        border-radius: 6px;
        font-size: 14px;
        transition: border 0.3s;
    }

        .pm-filter input:focus {
            border-color: #3498db;
            outline: none;
            box-shadow: 0 0 0 3px rgba(52,152,219,0.1);
        }

    .pm-filter .btn-search {
        background: #3498db;
        color: white;
        border: none;
        padding: 8px 25px;
        border-radius: 6px;
        cursor: pointer;
        font-size: 14px;
        transition: all 0.3s;
    }

        .pm-filter .btn-search:hover {
            background: #2980b9;
        }

    .pm-filter .btn-reset {
        background: #ecf0f1;
        color: #555;
        border: 1px solid #ddd;
        padding: 8px 20px;
        border-radius: 6px;
        cursor: pointer;
        font-size: 14px;
        transition: all 0.3s;
    }

        .pm-filter .btn-reset:hover {
            background: #d5dbdb;
        }

/* ===== گرید ===== */
.pm-grid-wrap {
    position: relative;
    min-height: 300px;
}

.pm-loading {
    text-align: center;
    padding: 60px 0;
}

    .pm-loading .spinner {
        display: inline-block;
        width: 40px;
        height: 40px;
        border: 4px solid #f3f3f3;
        border-top: 4px solid #3498db;
        border-radius: 50%;
        animation: spin 0.8s linear infinite;
    }

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.pm-loading p {
    color: #7f8c8d;
    margin-top: 10px;
}

.pm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 20px;
}

.pm-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    overflow: hidden;
    border: 1px solid #eee;
    transition: all 0.3s ease;
}

    .pm-card:hover {
        transform: translateY(-5px);
        box-shadow: 0 8px 30px rgba(0,0,0,0.15);
        border-color: #3498db;
    }

    .pm-card .card-img {
        height: 160px;
        background: #f5f5f5;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        position: relative;
    }

        .pm-card .card-img img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .pm-card .card-img .no-img {
            font-size: 48px;
            color: #ccc;
        }

        .pm-card .card-img .discount-badge {
            position: absolute;
            top: 10px;
            right: 10px;
            background: #e74c3c;
            color: white;
            padding: 3px 10px;
            border-radius: 20px;
            font-size: 11px;
            font-weight: 600;
        }

    .pm-card .card-body {
        padding: 14px 16px;
    }

        .pm-card .card-body h5 {
            margin: 0 0 4px 0;
            font-size: 15px;
            font-weight: 600;
            color: #2c3e50;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .pm-card .card-body .code {
            font-size: 12px;
            color: #95a5a6;
        }

        .pm-card .card-body .price {
            font-size: 16px;
            font-weight: 700;
            color: #2c3e50;
            margin-top: 6px;
        }

            .pm-card .card-body .price .old {
                font-size: 13px;
                color: #95a5a6;
                text-decoration: line-through;
                font-weight: 400;
                margin-left: 8px;
            }

        .pm-card .card-body .badge-part {
            display: inline-block;
            background: #3498db;
            color: white;
            font-size: 11px;
            padding: 2px 12px;
            border-radius: 20px;
            margin-top: 6px;
        }

        .pm-card .card-body .stock {
            font-size: 12px;
            color: #7f8c8d;
            margin-top: 4px;
        }

            .pm-card .card-body .stock .in {
                color: #27ae60;
            }

            .pm-card .card-body .stock .out {
                color: #e74c3c;
            }

    .pm-card .card-actions {
        display: flex;
        gap: 8px;
        padding: 8px 16px 14px;
        border-top: 1px solid #f0f0f0;
        flex-wrap: wrap;
    }

        .pm-card .card-actions .btn-map {
            background: #3498db;
            color: white;
            border: none;
            padding: 5px 14px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 12px;
            transition: all 0.3s;
            flex: 1;
            min-width: 80px;
        }

            .pm-card .card-actions .btn-map:hover {
                background: #2980b9;
            }

        .pm-card .card-actions .btn-product {
            background: #f8f9fa;
            color: #555;
            border: 1px solid #ddd;
            padding: 5px 14px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 12px;
            transition: all 0.3s;
            text-decoration: none;
            text-align: center;
            flex: 1;
            min-width: 80px;
        }

            .pm-card .card-actions .btn-product:hover {
                background: #e9ecef;
            }

.pm-empty {
    text-align: center;
    padding: 80px 20px;
    color: #95a5a6;
    grid-column: 1/-1;
}

    .pm-empty i {
        font-size: 56px;
        margin-bottom: 15px;
        display: block;
        color: #d5dbdb;
    }

.pm-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    padding: 25px 0 10px;
    flex-wrap: wrap;
}

    .pm-pagination button {
        min-width: 36px;
        height: 36px;
        border: 1px solid #ddd;
        border-radius: 6px;
        background: white;
        cursor: pointer;
        font-size: 14px;
        transition: all 0.2s;
        display: flex;
        align-items: center;
        justify-content: center;
    }

        .pm-pagination button:hover:not(.active):not(:disabled) {
            background: #f0f0f0;
            border-color: #adb5bd;
        }

        .pm-pagination button.active {
            background: #3498db;
            color: white;
            border-color: #3498db;
        }

        .pm-pagination button:disabled {
            opacity: 0.4;
            cursor: not-allowed;
        }

    .pm-pagination .page-info {
        font-size: 13px;
        color: #7f8c8d;
        padding: 0 10px;
    }

/* ===== مدال ===== */
.pm-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1050;
    overflow: hidden;
}

    .pm-modal.show {
        display: block;
    }

    .pm-modal .modal-dialog {
        position: relative;
        max-width: 95%;
        width: 1200px;
        margin: 30px auto;
        pointer-events: none;
        padding: 0 10px;
    }

    .pm-modal .modal-content {
        position: relative;
        display: flex;
        flex-direction: column;
        pointer-events: auto;
        background-color: #fff;
        background-clip: padding-box;
        border: 1px solid rgba(0,0,0,0.2);
        border-radius: 14px;
        outline: 0;
        overflow: hidden;
        max-height: 90vh;
    }

    .pm-modal .modal-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 24px;
        border-bottom: 1px solid #eee;
        background: #f8f9fa;
        flex-shrink: 0;
        flex-wrap: wrap;
        gap: 10px;
    }

        .pm-modal .modal-header .modal-title {
            font-size: 18px;
            margin: 0;
        }

        .pm-modal .modal-header .close {
            font-size: 28px;
            font-weight: 700;
            line-height: 1;
            color: #000;
            text-shadow: 0 1px 0 #fff;
            opacity: 0.5;
            background: none;
            border: none;
            cursor: pointer;
            padding: 0 5px;
        }

            .pm-modal .modal-header .close:hover {
                opacity: 0.75;
            }

    .pm-modal .modal-body {
        padding: 20px;
        overflow-y: auto;
        flex: 1;
    }

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1040;
}

    .modal-backdrop.fade {
        opacity: 0;
        transition: opacity 0.15s linear;
    }

        .modal-backdrop.fade.show {
            opacity: 1;
        }

/* ===== جزئیات نقشه ===== */
.pm-detail-wrap {
    display: flex;
    flex-direction: row;
    gap: 20px;
    min-height: 400px;
}

    .pm-detail-wrap .map-area {
        flex: 2.5;
        position: relative;
        border: 1px solid #e9ecef;
        border-radius: 10px;
        overflow: hidden;
        background: #fafafa;
        min-height: 350px;
    }

        .pm-detail-wrap .map-area .diagram-container {
            position: relative;
            width: 100%;
            height: 100%;
        }

            .pm-detail-wrap .map-area .diagram-container img {
                width: 100%;
                display: block;
                height: auto;
            }

            .pm-detail-wrap .map-area .diagram-container svg {
                position: absolute;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                pointer-events: none;
            }

                .pm-detail-wrap .map-area .diagram-container svg polygon {
                    cursor: default;
                    transition: all 0.3s ease;
                    pointer-events: none;
                    opacity: 0;
                    transition: opacity 0.3s ease;
                }

                    .pm-detail-wrap .map-area .diagram-container svg polygon.visible {
                        opacity: 1;
                        pointer-events: none;
                    }
                    /* حذف هاور روی پلی‌گان‌ها */
                    .pm-detail-wrap .map-area .diagram-container svg polygon:hover {
                        fill-opacity: 0.25 !important;
                        cursor: default;
                    }

    .pm-detail-wrap .parts-side {
        flex: 1;
        min-width: 180px;
        max-height: 500px;
        overflow-y: auto;
        border: 1px solid #e9ecef;
        border-radius: 10px;
        padding: 15px;
        background: #fafafa;
    }

        .pm-detail-wrap .parts-side h6 {
            margin: 0 0 12px 0;
            font-weight: 600;
            color: #2c3e50;
            border-bottom: 1px solid #eee;
            padding-bottom: 10px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
        }

            .pm-detail-wrap .parts-side h6 .count {
                font-size: 12px;
                font-weight: 400;
                color: #7f8c8d;
            }

        .pm-detail-wrap .parts-side .part-item {
            padding: 10px 12px;
            margin-bottom: 5px;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.2s ease;
            display: flex;
            justify-content: space-between;
            align-items: center;
            background: white;
            border: 1px solid #f0f0f0;
            gap: 8px;
        }

            .pm-detail-wrap .parts-side .part-item:hover {
                background: #e8f4fd;
                border-color: #3498db;
            }

            .pm-detail-wrap .parts-side .part-item.active {
                background: #d4e9ff;
                border-color: #3498db;
                box-shadow: 0 0 0 2px rgba(52,152,219,0.2);
            }

            .pm-detail-wrap .parts-side .part-item .num {
                font-weight: 600;
                font-size: 13px;
                color: #2c3e50;
                white-space: nowrap;
            }

            .pm-detail-wrap .parts-side .part-item .desc {
                font-size: 12px;
                color: #7f8c8d;
                flex: 1;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
                margin: 0 8px;
            }

            .pm-detail-wrap .parts-side .part-item .link-icon {
                color: #3498db;
                font-size: 16px;
                text-decoration: none;
                flex-shrink: 0;
                padding: 2px 6px;
                border-radius: 4px;
                transition: all 0.2s;
                background: #f0f8ff;
                border: 1px solid #d4e9ff;
            }

                .pm-detail-wrap .parts-side .part-item .link-icon:hover {
                    background: #3498db;
                    color: white;
                    border-color: #3498db;
                }

                .pm-detail-wrap .parts-side .part-item .link-icon i {
                    font-size: 13px;
                }

            .pm-detail-wrap .parts-side .part-item .show-polygon-btn {
                background: #27ae60;
                color: white;
                border: none;
                padding: 3px 10px;
                border-radius: 4px;
                cursor: pointer;
                font-size: 11px;
                transition: all 0.2s;
                flex-shrink: 0;
            }

                .pm-detail-wrap .parts-side .part-item .show-polygon-btn:hover {
                    background: #219a52;
                }

                .pm-detail-wrap .parts-side .part-item .show-polygon-btn.active-btn {
                    background: #e74c3c;
                }

                    .pm-detail-wrap .parts-side .part-item .show-polygon-btn.active-btn:hover {
                        background: #c0392b;
                    }

    .pm-detail-wrap .no-part {
        text-align: center;
        color: #95a5a6;
        padding: 40px 0;
    }

        .pm-detail-wrap .no-part i {
            font-size: 32px;
            display: block;
            margin-bottom: 10px;
        }

.pm-product-info {
    display: flex;
    gap: 15px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

    .pm-product-info .thumb {
        width: 50px;
        height: 50px;
        border-radius: 8px;
        overflow: hidden;
        flex-shrink: 0;
        border: 1px solid #eee;
    }

        .pm-product-info .thumb img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

    .pm-product-info .info {
        flex: 1;
        min-width: 150px;
    }

        .pm-product-info .info .name {
            font-weight: 600;
            font-size: 15px;
            color: #2c3e50;
        }

        .pm-product-info .info .code {
            font-size: 12px;
            color: #95a5a6;
        }

        .pm-product-info .info .product-link {
            display: inline-block;
            margin-top: 5px;
            color: #3498db;
            text-decoration: none;
            font-size: 13px;
            padding: 4px 12px;
            border: 1px solid #3498db;
            border-radius: 4px;
            transition: all 0.2s;
            background: white;
        }

            .pm-product-info .info .product-link:hover {
                background: #3498db;
                color: white;
                text-decoration: none;
            }

            .pm-product-info .info .product-link i {
                margin-left: 5px;
            }

/* ===== ریسپانسیو ===== */
@media (max-width: 992px) {
    .pm-detail-wrap {
        flex-direction: column;
    }

        .pm-detail-wrap .parts-side {
            max-height: 200px;
        }

    .pm-modal .modal-dialog {
        max-width: 98%;
        margin: 10px auto;
    }

    .pm-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

@media (max-width: 768px) {
    .pm-container {
        padding: 12px;
    }

    .pm-header h2 {
        font-size: 20px;
    }

    .pm-header small {
        font-size: 12px;
    }

    .pm-filter {
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
    }

        .pm-filter .form-group {
            min-width: auto;
        }

        .pm-filter .btn-search, .pm-filter .btn-reset {
            width: 100%;
            text-align: center;
            padding: 10px;
        }

    .pm-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }

    .pm-card .card-img {
        height: 130px;
    }

    .pm-card .card-body {
        padding: 10px 12px;
    }

        .pm-card .card-body h5 {
            font-size: 13px;
        }

    .pm-card .card-actions {
        flex-direction: column;
    }

        .pm-card .card-actions .btn-map, .pm-card .card-actions .btn-product {
            width: 100%;
            padding: 8px;
        }

    .pm-product-info {
        flex-direction: column;
        align-items: flex-start;
    }

        .pm-product-info .thumb {
            width: 40px;
            height: 40px;
        }

    .pm-modal .modal-dialog {
        margin: 5px auto;
    }

    .pm-modal .modal-header {
        padding: 12px 16px;
    }

        .pm-modal .modal-header .modal-title {
            font-size: 16px;
        }

    .pm-modal .modal-body {
        padding: 12px;
    }

    .pm-detail-wrap .map-area {
        min-height: 250px;
    }

    .pm-detail-wrap .parts-side {
        max-height: 150px;
        padding: 10px;
    }

        .pm-detail-wrap .parts-side .part-item {
            padding: 8px 10px;
            font-size: 12px;
        }
}

@media (max-width: 480px) {
    .pm-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .pm-card .card-img {
        height: 110px;
    }

    .pm-card .card-body h5 {
        font-size: 12px;
    }

    .pm-card .card-body .price {
        font-size: 14px;
    }

    .pm-card .card-body .badge-part {
        font-size: 10px;
        padding: 1px 8px;
    }

    .pm-detail-wrap .map-area {
        min-height: 200px;
    }

    .pm-pagination button {
        min-width: 30px;
        height: 30px;
        font-size: 12px;
    }

    .pm-filter input {
        font-size: 13px;
        padding: 6px 10px;
    }
}

.zoom-controls {
    position: absolute;
    bottom: 15px;
    right: 15px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 10;
}

    .zoom-controls .zoom-btn {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        border: 1px solid #ddd;
        background: white;
        cursor: pointer;
        font-size: 18px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.15);
        transition: all 0.2s ease;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #333;
        user-select: none;
    }

        .zoom-controls .zoom-btn:hover {
            background: #f0f0f0;
            transform: scale(1.05);
            box-shadow: 0 4px 12px rgba(0,0,0,0.2);
        }

        .zoom-controls .zoom-btn:active {
            transform: scale(0.95);
        }

    .zoom-controls .zoom-level {
        text-align: center;
        background: white;
        border: 1px solid #ddd;
        border-radius: 6px;
        padding: 4px 8px;
        font-size: 12px;
        color: #555;
        font-weight: 500;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        min-width: 50px;
    }

    .zoom-controls .zoom-reset-btn {
        color: #e74c3c;
    }

        .zoom-controls .zoom-reset-btn:hover {
            background: #fdf2f2;
            border-color: #e74c3c;
        }

/* ===== حالت درگ برای جابجایی ===== */
.diagram-container.dragging {
    cursor: grabbing !important;
}

    .diagram-container.dragging img {
        user-select: none;
        pointer-events: none;
    }

/* ===== ریسپانسیو برای کنترل‌های زوم ===== */
@media (max-width: 768px) {
    .zoom-controls {
        bottom: 10px;
        right: 10px;
    }

        .zoom-controls .zoom-btn {
            width: 32px;
            height: 32px;
            font-size: 16px;
        }

        .zoom-controls .zoom-level {
            font-size: 11px;
            padding: 3px 6px;
            min-width: 40px;
        }
}

@media (max-width: 480px) {
    .zoom-controls {
        bottom: 8px;
        right: 8px;
        gap: 4px;
    }

        .zoom-controls .zoom-btn {
            width: 28px;
            height: 28px;
            font-size: 14px;
        }

        .zoom-controls .zoom-level {
            font-size: 10px;
            padding: 2px 5px;
            min-width: 35px;
        }
}