/* ==========================================================================
   Wing Popup — Template Library Modal
   File: assets/css/template-library.css
   ========================================================================== */

/* ---- Overlay ---- */
.wdpop-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    animation: wdpopFadeIn .18s ease;
}

@keyframes wdpopFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ---- Modal shell ---- */
.wdpop-modal {
    background: #fff;
    border-radius: 8px;
    width: 100%;
    max-width: 980px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 40px rgba(0,0,0,.25);
    animation: wdpopSlideUp .2s ease;
    overflow: hidden;
}

@keyframes wdpopSlideUp {
    from { transform: translateY(24px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* ---- Header ---- */
.wdpop-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.wdpop-modal__header h2 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: #1d2327;
}

.wdpop-modal__close {
    background: none;
    border: none;
    font-size: 26px;
    line-height: 1;
    color: #72777c;
    cursor: pointer;
    padding: 0 4px;
    transition: color .15s;
}

.wdpop-modal__close:hover {
    color: #d63638;
}

/* ---- Toolbar (search) ---- */
.wdpop-modal__toolbar {
    padding: 14px 24px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

#wdpop-search {
    width: 100%;
    max-width: 320px;
    padding: 8px 12px;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    font-size: 13px;
    box-sizing: border-box;
}

#wdpop-search:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

/* ---- Scrollable body ---- */
.wdpop-modal__body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* ---- Grid ---- */
.wdpop-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

@media (max-width: 700px) {
    .wdpop-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Card ---- */
.wdpop-card {
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color .18s, box-shadow .18s;
    background: #fafafa;
}

.wdpop-card:hover {
    border-color: #2271b1;
    box-shadow: 0 4px 16px rgba(34,113,177,.15);
}

/* Preview image area — square aspect ratio */
.wdpop-card__thumb {
    width: 100%;
    /* aspect-ratio: 1 / 1; */
    overflow: hidden;
    background: #f0f0f1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wdpop-card__thumb img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
    transition: transform .25s ease;
}

.wdpop-card:hover .wdpop-card__thumb img {
    transform: scale(1.04);
}

/* Placeholder when no image */
.wdpop-card__thumb--placeholder {
    font-size: 40px;
    color: #c3c4c7;
    user-select: none;
}

/* Card footer */
.wdpop-card__footer {
    padding: 12px 14px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wdpop-card__title {
    font-size: 13px;
    font-weight: 600;
    color: #1d2327;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wdpop-card__desc {
    font-size: 12px;
    color: #72777c;
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* "Use This Template" button */
.wdpop-use-btn {
    display: block;
    width: 100%;
    padding: 8px 0;
    background: #2271b1;
    color: #fff !important;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background .15s;
    margin-top: 4px;
}

.wdpop-use-btn:hover:not(:disabled) {
    background: #135e96;
}

.wdpop-use-btn:disabled {
    background: #a7aaad;
    cursor: not-allowed;
}

/* ---- States ---- */
.wdpop-loading,
.wdpop-empty,
.wdpop-error {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: #72777c;
    font-size: 14px;
}

.wdpop-error {
    color: #d63638;
}

/* ---- Footer ---- */
.wdpop-modal__footer {
    padding: 14px 24px;
    border-top: 1px solid #e5e7eb;
    text-align: right;
    flex-shrink: 0;
}

.wdpop-modal__close-btn {
    min-width: 80px;
}

/* ---- "Insert Template" button tweak in list table ---- */
#wdpop-open-library {
    vertical-align: middle;
    text-decoration: none !important;
}