/* Templates Grid */
.templates-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding-bottom: 20px;
}

/* Template Tile */
.template-tile {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-color-alt);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    min-height: 140px;
    display: flex;
    flex-direction: column;
}

.template-tile:active {
    transform: scale(0.97);
}

.template-tile-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.template-tile-content {
    padding: 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    /* needed for text truncation to work in flex child */
}

.template-tile-icon {
    width: 100%;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 42px;
    color: var(--hint-color, #8e8e93);
    opacity: 0.7;
    background: rgba(0, 0, 0, 0.03);
}

.template-tile:not(.has-image) .template-tile-content {
    flex: none;
    justify-content: flex-start;
    padding-top: 5px;
}

.template-tile-title {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    margin: 0;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    display: block;
}

/* Image overlay style */
.template-tile.has-image {
    min-height: 140px;
}

.template-tile.has-image .template-tile-content {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0) 100%);
    color: #fff;
}

.template-tile.has-image .template-tile-title {
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* Favorite Icon on Tile */
.template-tile-fav {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    z-index: 2;
    font-size: 16px;
}

.template-tile-fav.active {
    color: #ff3b30;
}

/* Input Area Button */
.templates-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 24px;
    cursor: pointer;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.templates-btn:active {
    opacity: 1;
}