/* ========================================
   TEMPLATE GALLERY MODAL STYLES
   ======================================== */

.template-gallery-container {
    width: 1000px; /* Wider for gallery */
    height: 700px;
}

.template-search-container input:focus {
    border-color: var(--app-icon-active-color) !important;
    box-shadow: 0 0 0 3px var(--app-icon-active-bg);
}

/* Grid Container */
.template-grid-container {
    padding: 24px !important;
}

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

/* Template Cards */
.template-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    display: flex;
    flex-direction: column;
}

.template-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
    border-color: var(--app-icon-active-color);
}

.template-card:hover .template-thumbnail {
    transform: scale(1.05);
}

.template-thumbnail {
    width: 100%;
    height: 110px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease;
    border-bottom: 1px solid var(--border-color);
}

.template-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.template-info {
    padding: 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.template-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.template-description {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 30px;
}

.template-category-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--app-icon-active-bg);
    color: var(--app-icon-active-color);
    font-size: 10px;
    font-weight: 600;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 8px;
    align-self: flex-start;
}

/* Action Buttons */
.template-favorite-btn,
.template-delete-btn,
.template-ncil-btn {
    position: absolute;
    width: 32px;
    height: 32px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
    opacity: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    color: var(--text-secondary);
}

.template-card:hover .template-favorite-btn,
.template-card:hover .template-delete-btn,
.template-card:hover .template-ncil-btn {
    opacity: 1;
}

.template-favorite-btn {
    top: 8px;
    right: 8px;
}

.template-delete-btn {
    top: 8px;
    left: 8px;
}

.template-ncil-btn {
    top: 48px;
    left: 8px;
}

.template-favorite-btn:hover,
.template-delete-btn:hover,
.template-ncil-btn:hover {
    transform: scale(1.1);
    background: var(--bg-secondary);
}

.template-favorite-btn.active {
    background: #ff6b6b;
    color: white;
    border-color: #ff6b6b;
    opacity: 1 !important;
}

.template-delete-btn:hover {
    background: #ff4d4d;
    color: white;
    border-color: #ff4d4d;
}

.template-ncil-btn:hover {
    background: var(--app-icon-active-color);
    color: white;
    border-color: var(--app-icon-active-color);
}

.template-favorite-btn svg,
.template-delete-btn svg,
.template-ncil-btn svg {
    width: 14px;
    height: 14px;
}

/* Empty State */
.template-empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.template-empty-state .empty-icon {
    font-size: 48px;
    opacity: 0.3;
}

.template-empty-state h3 {
    font-size: 18px;
    color: var(--text-primary);
    margin: 0;
}

.template-empty-state p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

/* Mobile Responsive handled by settings-modal-container media queries */

/* Save Template Modal Styles - Keeping these but updating variables */
.save-template-modal-content {
    position: relative;
    z-index: 1;
    width: min(480px, 92vw);
    background: var(--bg-secondary);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: modalSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: var(--text-primary);
}

.save-template-modal-content .template-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.save-template-modal-content .template-modal-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.save-template-form {
    padding: 20px 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.save-template-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.save-template-form .form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.save-template-form .form-group input,
.save-template-form .form-group select,
.save-template-form .form-group textarea {
    padding: 9px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
    resize: vertical;
}

.save-template-form .form-group input:focus,
.save-template-form .form-group select:focus,
.save-template-form .form-group textarea:focus {
    border-color: var(--app-icon-active-color);
    box-shadow: 0 0 0 3px var(--app-icon-active-bg);
}

.save-template-form .form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 4px;
}

.save-template-form .btn-cancel {
    padding: 9px 18px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.save-template-form .btn-cancel:hover {
    background: var(--nav-item-hover);
    border-color: var(--border-color);
}

.save-template-form .btn-save {
    padding: 9px 18px;
    border: none;
    background: var(--app-icon-active-color);
    color: white;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.save-template-form .btn-save:hover {
    opacity: 0.9;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}
