/* =====================================================
   Mansons Parts Catalog – Frontend Styles
   ===================================================== */

/* Reset / Box model */
.mpc-wrap *,
.mpc-wrap *::before,
.mpc-wrap *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── WRAP ── */
.mpc-wrap {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    color: #333;
    background: #f5f5f5;
    padding: 10px;
    max-width: 100%;
}

/* ── HEADER ── */
.mpc-header {
    background: #fff;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,.1);
}
.mpc-title {
    font-size: 14px;
    font-weight: 700;
    color: #000;
    line-height: 1.4;
    margin-bottom: 8px;
}
.mpc-subtitle { font-size: 12px; color: #666; margin-bottom: 8px; }
.mpc-header-actions { display: flex; flex-direction: column; gap: 10px; }
.mpc-view-buttons   { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── BUTTONS ── */
.mpc-btn {
    padding: 10px 16px;
    border: 1px solid #ccc;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    border-radius: 3px;
    transition: all .3s;
    flex: 1;
    min-width: 110px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.mpc-btn--active  { background: #f32735; color: #fff; border-color: #f32735; }
.mpc-btn:active   { transform: scale(.98); }

/* ── MAIN CONTAINER ── */
.mpc-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #fff;
    padding: 15px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,.1);
}
.mpc-container.mpc-side-by-side { flex-direction: row; }

/* ── DIAGRAM ── */
.mpc-diagram-section {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
}
.mpc-diagram-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
    max-width: 700px;
}
.mpc-diagram-img {
    width: 100%;
    height: auto;
    display: block;
    border: 1px solid #ddd;
    background: #f9f9f9;
}

/* ── MARKER COMMON ── */
.mpc-marker {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    cursor: pointer;
    z-index: 10;
    transform: translate(-50%, -50%);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    line-height: 1;
}

/* ── DESKTOP MARKER ── */
.mpc-marker--desktop {
    width: 19px;
    height: 19px;
    background: #ffc107;
    border: 2px solid #fff;
    border-radius: 36%;
    color: #000;
    font-size: 11px;
    box-shadow: 0 2px 6px rgba(0,0,0,.3);
    transition: all .2s;
}
.mpc-marker--desktop:hover {
    transform: translate(-50%, -50%) scale(1.3);
    box-shadow: 0 0 0 3px rgba(255,193,7,.35);
    z-index: 20;
}
.mpc-marker--desktop.mpc-marker--active {
    background: #f32735;
    color: #fff;
    transform: translate(-50%, -50%) scale(1.3);
    z-index: 30;
    box-shadow: 0 0 0 3px rgba(243,39,53,.3);
}

/* ── MOBILE MARKER ── */
.mpc-marker--mobile {
    width: 11px;
    height: 11px;
    background: linear-gradient(145deg, #ffc107, #ff9800);
    border: 1px solid #fff;
    border-radius: 34%;
    color: #000;
    font-size: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,.4);
    transition: all .2s;
}
.mpc-marker--mobile.mpc-marker--active {
    background: linear-gradient(145deg, #f32735, #d50000);
    color: #fff;
    transform: translate(-50%, -50%) scale(1.3);
    z-index: 30;
    box-shadow: 0 0 0 5px rgba(243,39,53,.4);
    border: 4px solid #fff;
}
@keyframes mpcPulse {
    0%   { box-shadow: 0 0 0 0   rgba(255,193,7,.7); }
    70%  { box-shadow: 0 0 0 10px rgba(255,193,7,0);  }
    100% { box-shadow: 0 0 0 0   rgba(255,193,7,0);   }
}
.mpc-marker--mobile:not(.mpc-marker--active) { animation: mpcPulse 2s infinite; }

/* ── MOBILE HINT ── */
.mpc-mobile-hint {
    display: none;
    text-align: center;
    font-size: 12px;
    color: #666;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 5px;
}

/* ── TABLE SECTION ── */
.mpc-table-section { display: flex; flex-direction: column; overflow: hidden; }

.mpc-search-wrap {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}
.mpc-search-box {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 14px;
}
.mpc-filter-btn {
    padding: 10px 16px;
    background: #f8f9fa;
    border: 1px solid #ccc;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    touch-action: manipulation;
}

.mpc-table-container {
    overflow-x: auto;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    max-height: 500px;
    -webkit-overflow-scrolling: touch;
}
.mpc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    min-width: 600px;
}
.mpc-table thead {
    background: #2d2d2d;
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 5;
}
.mpc-table th {
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    position: relative;
    white-space: nowrap;
}
.mpc-table th::after { content: '⇅'; position: absolute; right: 5px; opacity: .5; font-size: 10px; }
.mpc-table th.mpc-sorted-asc::after  { content: '▲'; opacity: 1; }
.mpc-table th.mpc-sorted-desc::after { content: '▼'; opacity: 1; }
.mpc-table thead th:hover { background: #3d3d3d; }

.mpc-table tbody tr { border-bottom: 1px solid #e0e0e0; cursor: pointer; }
.mpc-table tbody tr:hover:not(.mpc-row--highlighted) { background: #f0f0f0; }
.mpc-table tbody tr:active { background: #f0f0f0; }
.mpc-table tbody tr.mpc-row--highlighted {
    background: #fff3cd !important;
    border-left: 3px solid #ffc107;
}
.mpc-table td { padding: 10px 8px; white-space: nowrap; }
.mpc-table td:nth-child(3) { white-space: normal; min-width: 150px; }

.mpc-part-number {
    color: #000;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    padding: 4px 0;
}
.mpc-part-number:hover { text-decoration: underline; }

/* ── PAGINATION ── */
.mpc-pagination {
    margin-top: 15px;
    font-size: 12px;
    color: #666;
    padding: 10px;
    background: #f9f9fa;
    border-radius: 3px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.mpc-pagination-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}
.mpc-page-size-select {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #fff;
    font-size: 13px;
}
.mpc-note {
    margin-top: 15px;
    font-size: 11px;
    color: #666;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 3px;
    line-height: 1.4;
}

/* ── TOOLTIP OVERLAY ── */
.mpc-tooltip-overlay {
    position: fixed;
    z-index: 999999;
    display: none;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,.5);
    pointer-events: none;
}
.mpc-tooltip-overlay.mpc-tooltip--open {
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}
.mpc-tooltip-box {
    background: #fff;
    border: 2px solid #f32735;
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0,0,0,.3);
    width: 90%;
    max-width: 400px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    margin: 20px;
}
.mpc-tooltip-box.mpc-multi { max-width: 450px; }

/* Tooltip header */
.mpc-tt-header {
    background: #f32735;
    color: #fff;
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1;
}
.mpc-tt-key {
    background: #fff;
    color: #f32735;
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}
.mpc-tt-body { padding: 16px; }

/* Single part */
.mpc-tt-single { display: flex; flex-direction: column; gap: 0; }
.mpc-part-img-wrap {
    width: 100%;
    height: 200px;
    background: #f8f8f8;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}
.mpc-part-img-wrap img { max-width: 100%; max-height: 100%; object-fit: contain; }
.mpc-part-details { display: flex; flex-direction: column; gap: 8px; }
.mpc-detail-row { display: flex; flex-direction: column; gap: 4px; }
.mpc-detail-label { font-weight: 700; color: #333; font-size: 13px; }
.mpc-detail-value { color: #333; font-size: 14px; word-wrap: break-word; }
.mpc-part-num-lg { font-size: 16px; font-weight: 700; color: #000; margin-bottom: 8px; }
.mpc-part-num-lg a { color: #f32735; text-decoration: none; }
.mpc-part-num-lg a:hover { text-decoration: underline; }

/* Multiple – grid */
.mpc-multi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}
.mpc-pn-box {
    background: #f8f8f8;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 12px 8px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    touch-action: manipulation;
}
.mpc-pn-box:hover { background: #f0f0f0; border-color: #f32735; }
.mpc-pn-box a { color: #f32735; font-weight: 700; text-decoration: none; font-size: 14px; display: block; }
.mpc-common-info { border-top: 2px solid #eee; padding-top: 12px; margin-top: 12px; }

/* Multiple – list */
.mpc-part-list { display: flex; flex-direction: column; gap: 12px; }
.mpc-list-item {
    padding: 12px;
    background: #f9f9f9;
    border-radius: 4px;
    border-left: 3px solid #f32735;
}
.mpc-list-item-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 8px;
}
.mpc-list-pn   { color: #f32735; font-weight: 700; font-size: 15px; text-decoration: none; }
.mpc-list-pn:hover { text-decoration: underline; }
.mpc-list-desc { color: #333; font-size: 14px; margin-bottom: 4px; }
.mpc-list-oem  { color: #666; font-size: 13px; font-style: italic; word-wrap: break-word; }
.mpc-list-remark { color: #f32735; font-size: 12px; margin-top: 4px; font-style: italic; }

/* Tooltip actions */
.mpc-tt-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #eee;
    flex-wrap: wrap;
}
.mpc-action-btn {
    padding: 10px 16px;
    background: #f32735;
    color: #fff;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    transition: background .2s;
    flex: 1;
    min-width: 100px;
    touch-action: manipulation;
}
.mpc-action-btn:hover   { background: #c0000d; }
.mpc-action-btn:active  { background: #a00; transform: scale(.98); }
.mpc-action-btn--sec    { background: #6c757d; }
.mpc-action-btn--sec:hover  { background: #5a6268; }

/* ══════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════ */

/* Mobile ( < 768px ) */
@media (max-width: 767px) {
    .mpc-container.mpc-side-by-side { flex-direction: column !important; }
    .mpc-side-by-side-btn           { display: none !important; }
    .mpc-btn                        { flex: 1; min-width: calc(33.333% - 8px); }
    .mpc-diagram-section            { margin-bottom: 20px; }
    .mpc-table-container            { max-height: 400px; }
    .mpc-tt-body                    { padding: 12px; }
    .mpc-action-btn                 { min-width: 80px; font-size: 13px; padding: 8px 12px; }
    .mpc-part-img-wrap              { height: 180px; }
    .mpc-title                      { font-size: 13px; }
    .mpc-marker--desktop            { display: none !important; }
    .mpc-marker--mobile             { display: flex !important; }
    .mpc-mobile-hint                { display: block; }
}

/* Tablet ( 768px – 1023px ) */
@media (min-width: 768px) and (max-width: 1023px) {
    .mpc-side-by-side-btn           { display: inline-block !important; }
    .mpc-container.mpc-side-by-side { flex-direction: row; }
    .mpc-marker--mobile             { display: none !important; }
    .mpc-marker--desktop            { display: flex !important; }
}

/* Desktop ( ≥ 768px ) */
@media (min-width: 768px) {
    .mpc-wrap    { padding: 20px; }
    .mpc-title   { font-size: 17px; }
    .mpc-header  { padding: 20px; display: flex; justify-content: space-between; align-items: center; }
    .mpc-header-actions { flex-direction: row; }
    .mpc-container { padding: 20px; }
    .mpc-container.mpc-side-by-side .mpc-diagram-section { flex: 1; }
    .mpc-container.mpc-side-by-side .mpc-table-section   { flex: 1; }
    .mpc-table   { font-size: 13px; }
    .mpc-marker--mobile  { display: none !important; }
    .mpc-marker--desktop { display: flex !important; }
    .mpc-mobile-hint     { display: none !important; }
    .mpc-pagination  { flex-direction: row; justify-content: space-between; font-size: 13px; }
    .mpc-note        { font-size: 12px; }
    .mpc-detail-row  { flex-direction: row; align-items: baseline; gap: 8px; }
    .mpc-detail-label { min-width: 80px; font-size: 14px; }
    .mpc-part-img-wrap { width: 73%; }

    /* Desktop tooltip is positioned near the marker, not fullscreen */
    .mpc-tooltip-overlay.mpc-tooltip--open {
        background: transparent;
        align-items: flex-start;
        justify-content: flex-start;
        pointer-events: none;
    }
    .mpc-tooltip-overlay.mpc-tooltip--open .mpc-tooltip-box {
        pointer-events: auto;
        width: auto;
        min-width: 300px;
        max-width: 400px;
        margin: 0;
        position: absolute;
    }
}

@media (min-width: 1024px) {
    .mpc-btn { flex: 0; }
    .mpc-side-by-side-btn { display: inline-block !important; }
}
