/* ===================================
   TEMPLATES CATALOG VIEW — BloxUI Studio
   FILE: css/templates.css
   ROLE: Full-screen catalog (#templates-view) — filters sidebar and template cards
   RELATED JS: js/layout.js switchView('templates'|'editor')
   =================================== */

#templates-view {
    width: 100%;
    height: 100%;
    flex: 1;
    overflow: hidden;
}

/* ---- Left Filter Sidebar ---- */
.filters-sidebar {
    width: 230px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 18px 16px;
    overflow-y: auto;
    flex-shrink: 0;
}

.filters-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 14px;
}

.filters-sidebar .search-box {
    position: relative;
    margin-bottom: 22px;
}

.filters-sidebar .search-box input {
    width: 100%;
    background: #14161c;
    border: 1px solid #2d313e;
    border-radius: 6px;
    padding: 8px 10px 8px 32px;
    font-size: 12px;
    color: var(--text-main);
    outline: none;
    transition: 0.2s;
}

.filters-sidebar .search-box input:focus {
    border-color: var(--blue-roblox);
}

.filters-sidebar .search-box svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 14px;
    height: 14px;
}

.filter-group {
    margin-bottom: 22px;
}

.filter-group-title {
    font-size: 13px;
    font-weight: 600;
    color: #ced3e2;
    margin-bottom: 10px;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #a2aabf;
    transition: 0.15s;
}

.filter-item:hover {
    color: var(--text-main);
}

.filter-item .custom-checkbox {
    width: 15px;
    height: 15px;
    border-radius: 4px;
    border: 1.5px solid #444a5b;
    background: #15171e;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.filter-item.checked .custom-checkbox {
    background: var(--blue-roblox);
    border-color: var(--blue-roblox);
}

.filter-item.checked .custom-checkbox::after {
    content: '';
    width: 4px;
    height: 7px;
    border: solid white;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
    margin-top: -2px;
}

/* ---- Main Templates Area ---- */
.templates-content {
    flex: 1;
    padding: 25px 30px;
    overflow-y: auto;
    background: var(--bg-main);
}

.featured-title {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.8px;
    color: #ffffff;
    text-transform: uppercase;
    margin-bottom: 22px;
}

.templates-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    padding-bottom: 40px;
}

@media (max-width: 1300px) {
    .templates-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.tpl-card {
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    border-radius: 12px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.tpl-card:hover {
    transform: translateY(-3px);
    border-color: var(--blue-roblox);
    box-shadow: 0 0 0 1.5px var(--blue-roblox), 0 8px 25px rgba(41, 121, 255, 0.25);
}

.tpl-card.highlight {
    border-color: var(--blue-roblox);
    box-shadow: 0 0 0 1px var(--blue-roblox), 0 8px 25px rgba(41, 121, 255, 0.15);
}

.tpl-preview-box {
    width: 100%;
    height: 190px;
    border-radius: 8px;
    overflow: hidden;
    background: #13151b;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #2d3240;
    margin-bottom: 14px;
}

.tpl-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.tpl-info {
    margin-top: auto;
}

.tpl-name {
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 14px;
}

.tpl-actions {
    display: flex;
    gap: 10px;
}

.btn-details {
    flex: 1;
    background: #2f3442;
    color: #cfd4e2;
    border: 1px solid #3c4254;
    font-size: 12px;
    font-weight: 600;
    padding: 9px 0;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    transition: 0.15s;
}

.btn-details:hover {
    background: #393f50;
    color: #fff;
}

.btn-edit-studio {
    flex: 1.2;
    background: var(--blue-roblox);
    color: white;
    border: none;
    font-size: 12px;
    font-weight: 700;
    padding: 9px 0;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    transition: 0.15s;
    box-shadow: 0 2px 8px rgba(41, 121, 255, 0.3);
}

.btn-edit-studio:hover {
    background: var(--blue-hover);
}

/* Mock previews used as CSS fallbacks for templates without a png */
.mock-box {
    width: 85%;
    height: 75%;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid #222;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    position: relative;
}

.mock-close {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    background: #ff4d4d;
    border-radius: 4px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid #222;
}

/* ---- Template Card Badges & Metadata ---- */
.tpl-header-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.tpl-category-pill {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--blue-roblox);
    background: rgba(41, 121, 255, 0.12);
    padding: 2px 8px;
    border-radius: 4px;
}

.tpl-element-count {
    font-size: 11px;
    color: #7e889f;
}

.tpl-short-desc {
    font-size: 12px;
    line-height: 1.45;
    color: #9aa4bc;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tpl-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 10px;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(18, 20, 26, 0.85);
    border: 1px solid var(--blue-roblox);
    color: #fff;
    backdrop-filter: blur(4px);
    z-index: 2;
}

/* ---- Empty Search State ---- */
.templates-empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
}

.templates-empty-state h3 {
    font-size: 18px;
    color: #ffffff;
    margin-bottom: 8px;
}

.templates-empty-state p {
    font-size: 14px;
    color: #7e889f;
    margin-bottom: 20px;
}

.btn-reset-filters {
    background: #2a3142;
    color: #fff;
    border: 1px solid #3c465d;
    padding: 8px 18px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-reset-filters:hover {
    background: var(--blue-roblox);
    border-color: var(--blue-roblox);
}

/* ---- Template Details Modal Backdrop ---- */
.template-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(8, 10, 15, 0.75);
    backdrop-filter: blur(6px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.template-modal-backdrop.visible {
    display: flex;
}

.template-modal-card {
    background: #181c26;
    border: 1px solid #2e3649;
    border-radius: 14px;
    width: 620px;
    max-width: 92vw;
    overflow: hidden;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}

.template-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.template-modal-preview {
    height: 220px;
    background: #11141c;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #252b3a;
}

.template-modal-body {
    padding: 24px;
}

.template-modal-category {
    font-size: 12px;
    color: var(--blue-roblox);
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.template-modal-title {
    font-size: 22px;
    color: #fff;
    margin-bottom: 10px;
}

.template-modal-desc {
    font-size: 13.5px;
    color: #9aa4bc;
    line-height: 1.5;
    margin-bottom: 18px;
}

.template-modal-specs {
    background: #12151d;
    border: 1px solid #232938;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.spec-item {
    display: flex;
    justify-content: space-between;
    font-size: 12.5px;
}

.spec-label {
    color: #747e96;
}

.spec-val {
    color: #e2e8f0;
    font-weight: 600;
}

.template-modal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 22px;
}

.tpl-tag {
    font-size: 11px;
    color: #8c97af;
    background: #202636;
    padding: 3px 8px;
    border-radius: 4px;
}

.template-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.template-modal-footer .btn-cancel {
    background: #242a3a;
    border: 1px solid #363e54;
    color: #cfd4e2;
    padding: 10px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.template-modal-footer .btn-load {
    background: var(--blue-roblox);
    border: none;
    color: #fff;
    padding: 10px 24px;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(41, 121, 255, 0.35);
}