.phm-links-grid{display:grid;grid-template-columns:repeat(6,1fr);gap:1rem;align-items:start}
.phm-links-cards{
    display: grid;
    /* Use auto-fit to allow the grid to wrap and center rows with fewer items */
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    align-items: start;
    justify-content: center; /* center the whole grid inside its container */
    justify-items: center; /* center each grid cell's content */
}

/* Search wrapper with buttons */
.phm-links-search-wrapper{
    display:flex;
    flex-direction:column;
    align-items:center;
    gap:1rem;
    margin-top:1.5rem;
    margin-bottom:2rem;
    padding-top:0.5rem;
}

.phm-links-search-wrapper .phm-link-search{
    width:100%;
    max-width:720px;
    padding:0.875rem 1.25rem;
    font-size:1.125rem;
    line-height:1.6;
    color:#212529;
    background-color:#fff;
    background-clip:padding-box;
    border:2px solid #ced4da;
    border-radius:50px; /* Pill-shaped like the image */
    transition:box-shadow .15s ease-in-out, border-color .15s ease-in-out;
    box-shadow:0 2px 8px rgba(0,0,0,0.08);
}

.phm-links-search-wrapper .phm-link-search:focus{
    border-color:#86b7fe;
    outline:0;
    box-shadow:0 0 0 .25rem rgba(13,110,253,.25), 0 4px 12px rgba(0,0,0,0.1);
}

.phm-links-search-wrapper .phm-link-search::placeholder{
    color:#6c757d;
    opacity:0.7;
}

/* Quick link buttons beneath search */
.phm-quick-links{
    display:flex;
    gap:0.75rem;
    flex-wrap:wrap;
    justify-content:center;
}

.phm-quick-link-btn{
    display:inline-block;
    padding:0.5rem 1.5rem;
    font-size:0.95rem;
    font-weight:600;
    color:#fff;
    background-color:#0d6efd;
    border:1px solid #0d6efd;
    border-radius:0.375rem;
    text-decoration:none;
    transition:background-color .15s ease, border-color .15s ease, transform .15s ease, box-shadow .15s ease;
    box-shadow:0 2px 4px rgba(13,110,253,0.2);
}

.phm-quick-link-btn:hover{
    background-color:#0b5ed7;
    border-color:#0a58ca;
    transform:translateY(-2px);
    box-shadow:0 4px 8px rgba(13,110,253,0.3);
    color:#fff;
    text-decoration:none;
}

.phm-quick-link-btn:active{
    transform:translateY(0);
    box-shadow:0 2px 4px rgba(13,110,253,0.2);
}

/* Make link items look like Bootstrap cards */
.phm-link-item{
    background:#fff;
    border:1px solid #e9ecef; /* bootstrap card border */
    box-shadow:0 .125rem .25rem rgba(0,0,0,.04);
    padding:1rem;
    border-radius:.5rem;
    transition:transform .15s ease, box-shadow .15s ease, border-color .15s ease;
    display:flex;
    flex-direction:column;
    align-items:center;
    gap:.75rem;
    text-align:center;
}
.phm-link-item:hover{
    transform:translateY(-4px);
    box-shadow:0 .5rem 1rem rgba(0,0,0,.08);
    border-color:#dee2e6;
}

.phm-link-icon-wrap{display:flex;justify-content:center;align-items:center;margin-bottom:.25rem}
.phm-link-icon{border-radius:.375rem;display:block}

.phm-link-title{margin:0}
.phm-link-title a{color:#0d6efd;font-weight:600;text-decoration:none}
.phm-link-title a:hover{text-decoration:underline;color:#0a58ca}

/* Popup modal search spacing */
.phm-popup-content .phm-links-search{margin-bottom:1rem}
.phm-link-item{padding:0.75rem;border:1px solid #eee;border-radius:6px;display:flex;flex-direction:column;align-items:center;gap:0.5rem;text-align:center}
.phm-link-icon{width:250px;height:70px;object-fit:contain;border-radius:8px;display:block;margin-left:auto;margin-right:auto}

/* Grid view: make icons square and smaller (100x100) */
.phm-links-grid .phm-link-icon{
    width:100px;
    height:100px;
    /* show the entire image without cropping */
    object-fit:contain;
    /* neutral background so contained images don't show empty space awkwardly */
    background-color: #fafafa;
    padding:6px; /* visual inset to avoid tight edges for contained images */
    box-sizing: border-box;
    border-radius:8px;
    display:block;
    margin-left:auto;
    margin-right:auto;
}
.phm-link-item .phm-link-title {
    font-weight: 600;
    margin-top: -6px;
    color: #dcdcdc;
}
.phm-link-title a {
    color: #4a4a4a;
    font-size: 14px;
    font-style: italic;
    text-decoration: none;
    margin-top: -5px;
}

/* Popup Modal Styles */
.phm-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.phm-popup-modal {
    background: #fff;
    border-radius: 12px;
    padding: 2rem;
    max-width: 90vw;
    max-height: 90vh;
    width: 800px;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    animation: phm-popup-fade-in 0.3s ease-out;
}

.phm-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.phm-popup-title {
    font-size: 1.4em;
    font-weight: 600;
    margin: 0;
    color: #333;
}

.phm-popup-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    color: #666;
    border-radius: 4px;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.phm-popup-close:hover {
    background-color: #f5f5f5;
    color: #333;
}

.phm-popup-content {
    line-height: 1.4;
}

.phm-popup-content .phm-links {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.phm-popup-content .phm-link-item {
    border: 1px solid #ddd;
    transition: border-color 0.2s, transform 0.2s;
}

.phm-popup-content .phm-link-item:hover {
    border-color: #0073aa;
    transform: translateY(-2px);
}

#menu-home-top {
    margin: 0 auto;
}

.menu-item { min-width: 75px; border-right: 1px solid #dcdcdc;}

.nav > li > a { border: 0px important; text-decoration: none; }


@keyframes phm-popup-fade-in {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Responsive adjustments */

/* Large tablets and small desktops (768px - 1024px) */
@media (max-width: 1024px) {
    .phm-links-grid {
        grid-template-columns: repeat(4, 1fr); /* 6 -> 4 columns */
        gap: 0.875rem;
    }
    
    .phm-links-cards {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); /* Narrower min-width */
    }
}

/* Tablets (768px and below) */
@media (max-width: 768px) {
    .phm-popup-modal {
        padding: 1.5rem;
        width: 95vw;
    }
    
    .phm-popup-content .phm-links {
        grid-template-columns: repeat(2, 1fr); /* 3 -> 2 columns in popup */
        gap: 0.75rem;
    }
    
    .phm-links-grid {
        grid-template-columns: repeat(3, 1fr); /* 6 -> 3 columns */
        gap: 0.75rem;
    }
    
    .phm-links-cards {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 0.875rem;
    }
    
    /* Adjust search bar for tablets */
    .phm-links-search-wrapper .phm-link-search {
        max-width: 100%;
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }
    
    .phm-quick-link-btn {
        padding: 0.5rem 1.25rem;
        font-size: 0.9rem;
    }
}

/* Mobile phones (576px and below) */
@media (max-width: 576px) {
    .phm-links-grid {
        grid-template-columns: repeat(2, 1fr); /* 6 -> 2 columns */
        gap: 0.625rem;
    }
    
    .phm-links-cards {
        grid-template-columns: 1fr; /* Single column for cards */
        gap: 0.75rem;
    }
    
    .phm-popup-content .phm-links {
        grid-template-columns: 1fr; /* Single column in popup */
        gap: 0.625rem;
    }
    
    /* Scale down icons for mobile */
    .phm-links-grid .phm-link-icon {
        width: 80px;
        height: 80px;
        padding: 4px;
    }
    
    .phm-link-icon {
        max-width: 100%;
        height: auto;
        max-height: 120px;
    }
    
    /* Compact search for mobile */
    .phm-links-search-wrapper {
        margin-top: 1rem;
        margin-bottom: 1.5rem;
        gap: 0.75rem;
    }
    
    .phm-links-search-wrapper .phm-link-search {
        padding: 0.625rem 1rem;
        font-size: 0.95rem;
        border-radius: 30px; /* Slightly less rounded for mobile */
    }
    
    .phm-quick-links {
        gap: 0.5rem;
        width: 100%;
    }
    
    .phm-quick-link-btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
        flex: 1; /* Make buttons equal width */
        text-align: center;
    }
    
    /* Adjust link item padding */
    .phm-link-item {
        padding: 0.625rem;
        gap: 0.5rem;
    }
    
    .phm-link-title a {
        font-size: 0.813rem; /* 13px */
    }
    
    /* Popup adjustments for mobile */
    .phm-popup-modal {
        padding: 1rem;
        max-width: 95vw;
        width: 100%;
    }
    
    .phm-popup-header {
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
    }
    
    .phm-popup-title {
        font-size: 1.2em;
    }
}

/* Extra small phones (400px and below) */
@media (max-width: 400px) {
    .phm-links-grid .phm-link-icon {
        width: 70px;
        height: 70px;
        padding: 3px;
    }
    
    .phm-link-title a {
        font-size: 0.75rem; /* 12px */
    }
    
    .phm-links-search-wrapper .phm-link-search {
        padding: 0.5rem 0.875rem;
        font-size: 0.9rem;
    }
    
    .phm-quick-link-btn {
        font-size: 0.8rem;
        padding: 0.45rem 0.875rem;
    }
}
