/*
 * Templines Elements – Elementor integration styles
 */

.tste-add-templines-template-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid #d5dade;
    border-radius: 4px;
    background-color: #ffffff;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.tste-add-templines-template-button:hover {
    background-color: #151515;
    border-color: #151515;
    transform: translateY(-1px);
}

.tste-add-templines-template-button .tste-icon {
    width: 18px;
    height: 18px;
    display: block;
    background-image: url('../img/templines-icon.svg');
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    filter: brightness(0);
}

.tste-add-templines-template-button:hover .tste-icon {
    filter: brightness(100);
}

/* Modal layout */
.tste-templates-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.tste-templates-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.tste-templates-modal-container {
    position: relative;
    width: 1100px;
    max-width: calc(100% - 60px);
    height: 80vh;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(16, 24, 40, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.tste-templates-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 24px;
    border-bottom: 1px solid #eef0f4;
}

.tste-templates-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #0f172a;
}

.tste-templates-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: auto;
}

.tste-templates-tab {
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    background: #f1f5f9;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tste-templates-tab:hover {
    border-color: #cbd5f5;
}

.tste-templates-tab.is-active {
    background: #0f172a;
    color: #ffffff;
    border-color: #0f172a;
}

.tste-category-filter {
    position: relative;
    min-width: 180px;
}

.tste-category-filter-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #d7dbe2;
    background: #f8fafc;
    font-size: 13px;
    color: #1e293b;
    cursor: pointer;
    gap: 12px;
}

.tste-category-filter-toggle svg {
    width: 12px;
    height: 12px;
}

.tste-category-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 100%;
    max-height: 280px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 20;
}

.tste-category-dropdown.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.tste-category-option {
    display: block;
    padding: 10px 14px;
    font-size: 13px;
    color: #1e293b;
    cursor: pointer;
    transition: background 0.15s ease;
}

.tste-category-option:hover {
    background: #f8fafc;
}

.tste-category-option.is-active {
    background: #0f172a;
    color: #ffffff;
}

.tste-templates-modal-close {
    margin-left: auto;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: none;
    background: #e2e8f0;
    color: #0f172a;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.tste-templates-modal-close:hover {
    background: #0f172a;
    color: #ffffff;
}

.tste-templates-modal-body {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.tste-templates-content {
    position: absolute;
    inset: 0;
    padding: 24px;
    overflow-y: auto;
}

.tste-templates-content.is-hidden {
    display: none;
}

.tste-templates-empty,
.tste-templates-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    height: 100%;
    color: #475569;
    font-size: 14px;
}

.tste-spinner {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid rgba(59, 130, 246, 0.2);
    border-top-color: #2563eb;
    animation: tste-spin 0.8s linear infinite;
}

@keyframes tste-spin {
    to {
        transform: rotate(360deg);
    }
}

.tste-template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

.tste-template-card {
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tste-template-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.12);
}

.tste-template-preview {
    position: relative;
    height: 170px;
    background-color: #fff;
    background-image: url(../img/template-placeholder.svg);
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
}

.tste-template-title {
    margin: 0;
    padding: 14px 16px 0;
    font-size: 15px;
    font-weight: 600;
    color: #0f172a;
}

.tste-template-actions {
    display: flex;
    gap: 10px;
    padding: 14px 16px 18px;
}

.tste-template-actions button {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    border-radius: 6px;
    border: 1px solid #0f172a;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.tste-template-actions button.tste-preview-button {
    background: #ffffff;
    color: #0f172a;
}

.tste-template-actions button.tste-preview-button:hover {
    background: #0f172a;
    color: #ffffff;
}

.tste-template-actions button.tste-insert-button {
    background: #0f172a;
    color: #ffffff;
}

.tste-template-actions button.tste-insert-button.is-loading {
    pointer-events: none;
    opacity: 0.7;
}

.tste-template-actions button.tste-insert-button:hover {
    background: #111827;
}

/* Preview modal */
.tste-preview-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    background: rgba(15, 23, 42, 0.75);
}

.tste-preview-modal figure {
    margin: 0;
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 12px;
    overflow: hidden;
    background: #0f172a;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
    position: relative;
}

.tste-preview-modal img {
    display: block;
    width: 100%;
    height: auto;
}

.tste-preview-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.85);
    color: #ffffff;
    border: none;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.tste-preview-close:hover {
    background: rgba(15, 23, 42, 1);
}

.tste-templates-footer {
    padding: 12px 24px;
    border-top: 1px solid #eef0f4;
    font-size: 12px;
    font-weight: 500;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tste-version-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #eef2ff;
    color: #3730a3;
    font-weight: 600;
}

@media (max-width: 960px) {
    .tste-templates-modal-container {
        width: calc(100% - 40px);
        height: 88vh;
    }

    .tste-template-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}
