/* ================================================================
   THW — Database Plugin Stylesheet
   ================================================================ */

:root {
    --thwdb-accent:  #0274BE;
    --thwdb-accent-dk: #025fa0;
    --thwdb-danger:  #d63638;
    --thwdb-text:    #1d2327;
    --thwdb-muted:   #6c757d;
    --thwdb-border:  #e9ecef;
    --thwdb-bg:      #fff;
    --thwdb-radius:  8px;
}

/* ── Body scroll lock ────────────────────────────────────────────────────── */

body.thwdb-no-scroll { overflow: hidden; }

/* ── Popup ───────────────────────────────────────────────────────────────── */

.thwdb-popup {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.thwdb-popup__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.75);
}

.thwdb-popup__box {
    position: relative;
    z-index: 2;
    background: var(--thwdb-bg);
    border-radius: 8px;
    padding: 2rem;
    max-width: 560px;
    width: 92%;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
    max-height: 90vh;
    overflow-y: auto;
}

.thwdb-popup__title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 1rem;
    color: var(--thwdb-text);
    line-height: 1.35;
}

.thwdb-popup__content {
    font-size: .875rem;
    color: #444;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.thwdb-popup__content ul {
    margin: .5rem 0 0 1.25rem;
    padding: 0;
}

.thwdb-popup__content li {
    margin-bottom: .4rem;
}

.thwdb-popup__actions {
    display: flex;
    gap: .75rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.thwdb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .6rem 1.5rem;
    border-radius: 6px;
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border: none;
    transition: background .15s, opacity .15s;
    white-space: nowrap;
}

.thwdb-btn--refuse {
    background: #f1f3f5;
    color: var(--thwdb-text);
    border: 1px solid var(--thwdb-border);
}
.thwdb-btn--refuse:hover { background: #e9ecef; color: var(--thwdb-text); }

.thwdb-btn--agree {
    background: var(--thwdb-accent);
    color: #fff;
}
.thwdb-btn--agree:hover { background: var(--thwdb-accent-dk); }

.thwdb-btn--view {
    background: var(--thwdb-accent);
    color: #fff;
    width: 100%;
    margin-top: .5rem;
    font-size: .8rem;
}
.thwdb-btn--view:hover { background: var(--thwdb-accent-dk); color: #fff; }

.thwdb-btn--download {
    background: var(--thwdb-accent);
    color: #fff;
    padding: .75rem 2rem;
    font-size: 1rem;
    margin-top: 1.25rem;
}
.thwdb-btn--download:hover { background: var(--thwdb-accent-dk); color: #fff; }

/* ── Layout ──────────────────────────────────────────────────────────────── */

.thwdb-wrap {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 768px) {
    .thwdb-wrap { grid-template-columns: 1fr; }
}

/* ── Filters sidebar ─────────────────────────────────────────────────────── */

.thwdb-filters {
    position: sticky;
    top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.thwdb-filter-group {
    background: var(--thwdb-bg);
    border: 1px solid var(--thwdb-border);
    border-radius: 8px;
    overflow: hidden;
}

.thwdb-filter-group__title {
    font-size: .875rem;
    font-weight: 600;
    color: var(--thwdb-text);
    margin: 0;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--thwdb-border);
    background: #fff;
}

.thwdb-filter-list {
    list-style: none;
    margin: 0;
    padding: .5rem 1rem .75rem;
    display: flex;
    flex-direction: column;
    gap: .1rem;
}

.thwdb-filter-list li { margin: 0; }

/* Checkboxes */
.thwdb-check {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .3rem 0;
    cursor: pointer;
    font-size: .86rem;
    color: var(--thwdb-text);
}

.thwdb-check input { position: absolute; opacity: 0; width: 0; height: 0; }

.thwdb-check__box {
    width: 17px;
    height: 17px;
    border: 1.5px solid #adb5bd;
    border-radius: 3px;
    flex-shrink: 0;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color .12s, background .12s;
}

.thwdb-check input:checked ~ .thwdb-check__box {
    border-color: var(--thwdb-accent);
    background: var(--thwdb-accent);
}

.thwdb-check input:checked ~ .thwdb-check__box::after {
    content: '';
    display: block;
    width: 9px;
    height: 5px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg) translateY(-1px);
}

.thwdb-check__label { flex: 1; }
.thwdb-check__count { font-size: .75rem; color: var(--thwdb-muted); }

/* ── Grid ────────────────────────────────────────────────────────────────── */

.thwdb-main { position: relative; }

.thwdb-toolbar {
    margin-bottom: .75rem;
    font-size: .85rem;
    color: var(--thwdb-muted);
    min-height: 1.2em;
}

.thwdb-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    min-height: 100px;
    transition: opacity .2s;
    margin-top: 20px;
}

/* ── Grid card ───────────────────────────────────────────────────────────── */

.thwdb-card {
    background: var(--thwdb-bg);
    border: 1px solid var(--thwdb-border);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow .2s;
}

.thwdb-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); }

.thwdb-card__thumb {
    width: 100%;
    aspect-ratio: 1/1;
    overflow: hidden;
    background: #f5f5f5;
}

.thwdb-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .3s;
}

.thwdb-card:hover .thwdb-card__thumb img { transform: scale(1.04); }

.thwdb-card__thumb-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f0f0f0 0%, #e5e5e5 100%);
}

.thwdb-card__terms {
    padding: .5rem .75rem .25rem;
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
}

.thwdb-card .thwdb-btn--view {
    margin: auto .75rem .75rem;
    width: calc(100% - 1.5rem);
}

/* ── Term tags ───────────────────────────────────────────────────────────── */

.thwdb-term-tag {
    display: inline-block;
    font-size: .7rem;
    font-weight: 600;
    padding: .15em .55em;
    border-radius: 4px;
    background: #e7f3ff;
    color: var(--thwdb-accent);
    border: 1px solid #b6d9f7;
    white-space: nowrap;
}

/* ── Loader ──────────────────────────────────────────────────────────────── */

.thwdb-loader {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.65);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
    border-radius: 8px;
    z-index: 10;
}

.thwdb-loader.is-active { opacity: 1; pointer-events: all; }

.thwdb-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(2,116,190,.2);
    border-top-color: var(--thwdb-accent);
    border-radius: 50%;
    animation: thwdbSpin .7s linear infinite;
}

@keyframes thwdbSpin { to { transform: rotate(360deg); } }

.thwdb-no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: var(--thwdb-muted);
}

/* ── Single Item Page ────────────────────────────────────────────────────── */

.thwdb-single {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
    align-items: start;
    max-width: 960px;
    margin: 0 auto;
}

@media (max-width: 640px) {
    .thwdb-single { grid-template-columns: 1fr; }
}

.thwdb-single__image-wrap {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--thwdb-border);
}

.thwdb-single__image {
    width: 100%;
    height: auto;
    display: block;
}

.thwdb-single__title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 .75rem;
    color: var(--thwdb-text);
}

.thwdb-single__terms {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin-bottom: 1rem;
}

.thwdb-single__desc {
    font-size: .9rem;
    color: #444;
    line-height: 1.65;
    margin-bottom: 1rem;
}

.thwdb-single__back {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--thwdb-border);
}

.thwdb-back-link {
    font-size: .85rem;
    color: var(--thwdb-muted);
    text-decoration: none;
}

.thwdb-back-link:hover {
    color: var(--thwdb-accent);
    text-decoration: underline;
}

/* ================================================================
   Archive & Single Page Styles
   ================================================================ */

/* Breadcrumb */
#thwdb-archive-content{
    width: 100%;
}
.thwdb-breadcrumb {
    padding: 1rem 0;
    font-size: .875rem;
    color: #666;
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-wrap: wrap;
}
.thwdb-breadcrumb a { color: #0274BE; text-decoration: none; }
.thwdb-breadcrumb a:hover { text-decoration: underline; }
.thwdb-breadcrumb span { color: #999; }

/* Archive wrapper */
.thwdb-archive-wrap {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 1.5rem 3rem;
}

.thwdb-archive-layout {
    display: grid;
    grid-template-columns: 27% 1fr;
    gap: 2rem;
    align-items: start;
    margin-top: .5rem;
}

@media (max-width: 768px) {
    .thwdb-archive-layout { grid-template-columns: 1fr; }
}

/* Sidebar */
.thwdb-archive-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    position: sticky;
    top: 1.5rem;
}

/* Toolbar */
.thwdb-archive-main { 
    position: relative; 
    background-color: #fff;
    padding: 2.34em 2.67em;
}

.thwdb-archive-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.thwdb-archive-count {
    font-size: .875rem;
    color: #666;
}

.thwdb-search-input {
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: .4rem .85rem;
    font-size: .875rem;
    outline: none;
    min-width: 200px;
}
.thwdb-search-input:focus {
    border-color: #0274BE;
    box-shadow: 0 0 0 2px rgba(2,116,190,.1);
}

/* Card */
.thwdb-card__image-link {
    display: block;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: #f5f5f5;
    position: relative;
}
.thwdb-card__image-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .3s;
}
.thwdb-card:hover .thwdb-card__image-link img { transform: scale(1.04); }

.thwdb-card__no-image {
    width: 100%;
    height: 100%;
    background: #f0f0f0;
}

/*.thwdb-card__tag {
    padding: .5rem .75rem .25rem;
    font-size: .78rem;
    color: #666;
}*/

.thwdb-card__tag{
    font-size: .75rem;
    color: var(--thwsf-muted);
    font-weight: 400;
}

.thwdb-card__btn {
    display: block;
    margin: .35rem .75rem .75rem;
    padding: .55rem 2rem;
    background: #0274BE;
    color: #fff !important;
    text-align: center;
    text-decoration: none;
    font-size: .8rem;
    font-weight: 700;
    border-radius: 5px;
    letter-spacing: .04em;
    transition: background .15s;
    align-self: flex-end;
}
.thwdb-card__btn:hover { background: #025fa0; }

/* Loader */
.thwdb-loader {
    display: none;
    justify-content: center;
    padding: 2rem;
}

/* Single page */
.thwdb-single-wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem 3rem;
}

.thwdb-single-layout {
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 2.5rem;
    align-items: start;
    margin-top: 1rem;
}

@media (max-width: 860px) {
    .thwdb-single-layout { grid-template-columns: 1fr; }
}

.thwdb-single-image-wrap {
    border-radius: 8px;
    overflow: hidden;
    background: #f9f9f9;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.thwdb-single-main-img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

.thwdb-single-info-box {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
}

.thwdb-single-info-section { padding: 1.25rem 1.5rem; }

.thwdb-single-info-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1d2327;
    margin: 0 0 .75rem;
}

.thwdb-single-terms-list {
    list-style: disc;
    margin: 0 0 0 1.25rem;
    padding: 0;
}

.thwdb-single-terms-list li {
    font-size: .875rem;
    color: #444;
    padding: .2rem 0;
}

.thwdb-divider {
    border: none;
    border-top: 1px solid #e9ecef;
    margin: 0;
}

.thwdb-single-tc-text { padding: 1.25rem 1.5rem; }
.thwdb-single-tc-text p {
    font-size: .8rem;
    color: #555;
    margin: 0 0 .4rem;
    line-height: 1.5;
}
.thwdb-single-tc-text p:last-child { margin-bottom: 0; }

.thwdb-download-btn {
    display: block;
    width: calc(100% - 3rem);
    margin: 1.25rem 1.5rem;
    padding: .85rem;
    background: #0274BE;
    color: #fff !important;
    text-align: center;
    text-decoration: none;
    font-size: .9rem;
    font-weight: 700;
    letter-spacing: .05em;
    border-radius: 6px;
    text-transform: uppercase;
    transition: background .15s;
    box-sizing: border-box;
}
.thwdb-download-btn:hover { background: #025fa0; }

.thwsf-card__body{
    padding: .8rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .25rem;
}
.thwsf-card__body .thwsf-card__name{
    margin: 0;
    font-size: .9rem;
    font-weight: 600;
    line-height: 1.35;
}

.thwsf-card__body .thwsf-card__name a{
    color: #212529;
    text-decoration: none;
}

#thwdb-single-content{
    width: 100%;
}

.thwsf-card__badge--tebex{
    background: #0274BE;
    color: #fff;
}

.thwsf-card__badge{
    position: absolute;
    top: .7rem;
    left: .7rem;
    font-size: .68rem;
    font-weight: 700;
    padding: .2em .55em;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: .04em;
    pointer-events: none;
}

@media (min-width: 1600px) {
    .thwdb-archive-main {
        padding: 5.34em 6.67em;
    }
}

@media (max-width: 1200px) {
    .thwdb-grid{
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 1100px) { .thwdb-grid { grid-template-columns: repeat(2, 1fr); } }
/*@media (max-width: 570px)  { .thwdb-grid { grid-template-columns: repeat(2, 1fr); } }*/

@media (min-width: 922px) {
    .site-content .ast-container {
        max-width: 1750px;
    }
}

@media (max-width: 768px) {
    .thwdb-archive-sidebar{
        position: relative;
        top: 0rem;
    }
}

@media (max-width: 570px)  { 
    .thwdb-grid { grid-template-columns: 1fr; } 
}
